Class VmUtils

java.lang.Object
org.pkl.core.runtime.VmUtils

public final class VmUtils extends Object
  • Field Details

  • Method Details

    • createEmptyMaterializedFrame

      public static com.oracle.truffle.api.frame.MaterializedFrame createEmptyMaterializedFrame()
    • createContext

      public static org.graalvm.polyglot.Context createContext(Runnable initializer)
    • countLeadingWhitespace

      public static int countLeadingWhitespace(String str)
    • indent

      public static String indent(String text, String indent)
    • getReceiverOrNull

      @Nullable public static @Nullable Object getReceiverOrNull(com.oracle.truffle.api.frame.Frame frame)
      Returns the receiver of the message that was dispatched to the currently executing code.
    • getReceiver

      public static Object getReceiver(com.oracle.truffle.api.frame.Frame frame)
      Returns the receiver of the message that was dispatched to the currently executing code.
    • getObjectReceiver

      public static VmObjectLike getObjectReceiver(com.oracle.truffle.api.frame.Frame frame)
    • getTypedObjectReceiver

      public static VmTyped getTypedObjectReceiver(com.oracle.truffle.api.frame.Frame frame)
    • getOwnerOrNull

      @Nullable public static @Nullable VmObjectLike getOwnerOrNull(com.oracle.truffle.api.frame.Frame frame)
      Returns the owner of the currently executing code.
    • getOwner

      public static VmObjectLike getOwner(com.oracle.truffle.api.frame.Frame frame)
      Returns the owner of the currently executing code.
    • getMemberKey

      public static Object getMemberKey(com.oracle.truffle.api.frame.Frame frame)
      Returns a `ObjectMember`'s key while executing the corresponding `MemberNode`.
    • getModuleInfo

      public static ModuleInfo getModuleInfo(VmObjectLike composite)
    • readTextProperty

      public static String readTextProperty(VmObjectLike receiver)
    • readTextProperty

      public static String readTextProperty(Object receiver)
    • readBytesProperty

      public static VmBytes readBytesProperty(VmObjectLike receiver)
    • readMember

      public static Object readMember(VmObjectLike receiver, Object memberKey)
    • readMemberOrNull

      @Nullable public static @Nullable Object readMemberOrNull(VmObjectLike receiver, Object memberKey, boolean checkType)
    • readMemberOrNull

      @Nullable public static @Nullable Object readMemberOrNull(VmObjectLike receiver, Object memberKey, com.oracle.truffle.api.nodes.IndirectCallNode callNode)
    • readMemberOrNull

      @Nullable public static @Nullable Object readMemberOrNull(VmObjectLike receiver, Object memberKey)
    • doReadMember

      public static Object doReadMember(VmObjectLike receiver, VmObjectLike owner, Object memberKey, ObjectMember member)
      Before calling this method, always try `VmObject.getCachedValue()`. (This method writes to the cache, but doesn't read from it.)
    • readMember

      public static Object readMember(VmObjectLike receiver, Object memberKey, com.oracle.truffle.api.nodes.IndirectCallNode callNode)
    • readMemberOrNull

      @Nullable public static @Nullable Object readMemberOrNull(VmObjectLike receiver, Object memberKey, boolean checkType, com.oracle.truffle.api.nodes.IndirectCallNode callNode)
    • doReadMember

      public static Object doReadMember(VmObjectLike receiver, VmObjectLike owner, Object memberKey, ObjectMember member, boolean checkType, com.oracle.truffle.api.nodes.IndirectCallNode callNode)
      Before calling this method, always try `VmObject.getCachedValue()`. (This method writes to the cache, but doesn't read from it.)
    • copyLocals

      public static void copyLocals(com.oracle.truffle.api.frame.VirtualFrame sourceFrame, int firstSourceSlot, com.oracle.truffle.api.frame.VirtualFrame targetFrame, int firstTargetSlot, int numberOfLocalsToCopy)
      Copies numberOfLocalsToCopy locals from sourceFrame, starting at firstSourceSlot, to firstSourceSlot, starting at firstTargetSlot.
    • insertStackFrame

      public static void insertStackFrame(ObjectMember member, com.oracle.truffle.api.CallTarget location, VmException exception)
    • findMember

      @Nullable public static @Nullable ObjectMember findMember(VmObjectLike receiver, Object memberKey)
    • createThisNode

      public static ExpressionNode createThisNode(com.oracle.truffle.api.source.SourceSection sourceSection, boolean isCustomThisScope)
    • isPcfRenderDirective

      public static boolean isPcfRenderDirective(Object value)
    • getNodeInfo

      public static com.oracle.truffle.api.nodes.NodeInfo getNodeInfo(com.oracle.truffle.api.nodes.Node node)
    • getClass

      public static VmClass getClass(Object value)
    • getConfigValue

      public static String getConfigValue(com.oracle.truffle.api.TruffleLanguage.Env env, String name, String defaultValue)
    • unavailableSourceSection

      public static com.oracle.truffle.api.source.SourceSection unavailableSourceSection()
    • put

      public static org.organicdesign.fp.collections.ImMap<Object,Object> put(org.organicdesign.fp.collections.ImMap<Object,Object> map, String key, Object value)
    • createBuilder

      public static StringBuilder createBuilder()
    • appendToBuilder

      public static void appendToBuilder(StringBuilder builder, String string)
    • builderToString

      public static String builderToString(StringBuilder builder)
    • checkPositive

      public static void checkPositive(long n)
    • loadSource

      public static com.oracle.truffle.api.source.Source loadSource(ResolvedModuleKey resolvedKey)
    • createSource

      public static com.oracle.truffle.api.source.Source createSource(ModuleKey moduleKey, String text)
    • toVmException

      public static VmException toVmException(org.pkl.parser.ParserError e, String text, URI moduleUri, String moduleName)
    • toVmException

      public static VmException toVmException(org.pkl.parser.ParserError e, com.oracle.truffle.api.source.Source source, String moduleName)
    • exportDocComment

      @Nullable public static @Nullable String exportDocComment(com.oracle.truffle.api.source.SourceSection @Nullable [] docComment)
    • exportAnnotations

      public static List<PObject> exportAnnotations(List<VmTyped> annotations)
    • exportAnnotations

      public static void exportAnnotations(List<VmTyped> annotations, List<PObject> result)
    • evaluateAnnotations

      public static List<VmTyped> evaluateAnnotations(com.oracle.truffle.api.frame.VirtualFrame frame, ExpressionNode[] annotationNodes)
    • evaluateAnnotations

      public static void evaluateAnnotations(com.oracle.truffle.api.frame.VirtualFrame frame, ExpressionNode[] annotationNodes, List<VmTyped> result)
    • codePointOffsetToCharOffset

      public static int codePointOffsetToCharOffset(String string, long codePointOffset)
    • codePointOffsetToCharOffset

      public static int codePointOffsetToCharOffset(String string, long codePointOffset, int startIndex)
    • codePointOffsetFromEndToCharOffset

      public static int codePointOffsetFromEndToCharOffset(String string, long codePointOffset)
    • createDecimalFormat

      public static DecimalFormat createDecimalFormat(int fractionDigits)
    • createSyntheticObjectProperty

      public static ObjectMember createSyntheticObjectProperty(@Nullable @Nullable Identifier identifier, String qualifiedName, Object constantValue)
      Creates a constant object property that has no corresponding definition in Pkl code.
    • createSyntheticObjectEntry

      public static ObjectMember createSyntheticObjectEntry(String qualifiedName, Object constantValue)
      Creates a constant object entry that has no corresponding definition in Pkl code.
    • createSyntheticObjectElement

      public static ObjectMember createSyntheticObjectElement(String qualifiedName, Object constantValue)
      Creates a constant object element that has no corresponding definition in Pkl code.
    • createObjectProperty

      public static ObjectMember createObjectProperty(VmLanguage language, com.oracle.truffle.api.source.SourceSection sourceSection, com.oracle.truffle.api.source.SourceSection headerSection, Identifier propertyName, String qualifiedName, com.oracle.truffle.api.frame.FrameDescriptor descriptor, int modifiers, ExpressionNode bodyNode, @Nullable @Nullable PropertyTypeNode typeNode)
    • createLocalObjectProperty

      public static ObjectMember createLocalObjectProperty(VmLanguage language, com.oracle.truffle.api.source.SourceSection sourceSection, com.oracle.truffle.api.source.SourceSection headerSection, Identifier propertyName, String qualifiedName, com.oracle.truffle.api.frame.FrameDescriptor descriptor, int modifiers, ExpressionNode bodyNode, @Nullable @Nullable UnresolvedTypeNode typeNode)
    • resolveParameterTypes

      public static TypeNode[] resolveParameterTypes(com.oracle.truffle.api.frame.VirtualFrame frame, com.oracle.truffle.api.frame.FrameDescriptor descriptor, UnresolvedTypeNode[] parameterTypeNodes)
    • checkIsInstantiable

      public static void checkIsInstantiable(VmClass parentClass, @Nullable @Nullable com.oracle.truffle.api.nodes.Node parentNode)
    • compilePattern

      public static Pattern compilePattern(String pattern, com.oracle.truffle.api.nodes.Node location)
    • getKey

      public static <K, V> K getKey(Map.Entry<K,V> entry)
    • getValue

      public static <K, V> V getValue(Map.Entry<K,V> entry)
    • getDisplayUri

      public static String getDisplayUri(com.oracle.truffle.api.source.SourceSection section, StackFrameTransformer transformer)
    • getDisplayUri

      public static String getDisplayUri(URI moduleUri, StackFrameTransformer transformer)
    • createStackFrame

      public static StackFrame createStackFrame(com.oracle.truffle.api.source.SourceSection section, @Nullable @Nullable String memberName)
    • evaluateExpression

      public static Object evaluateExpression(VmTyped module, String expression, SecurityManager securityManager, ModuleResolver moduleResolver)
    • findCustomThisSlot

      public static int findCustomThisSlot(com.oracle.truffle.api.frame.VirtualFrame frame)
    • getMapValue

      public static <K, V> V getMapValue(Map<K,V> map, K key)
    • shouldRunTypeCheck

      public static boolean shouldRunTypeCheck(com.oracle.truffle.api.frame.VirtualFrame frame)
      If true, the value computed by this node is not the final value exposed to user code but will still be amended.

      Used to disable type check for to-be-amended properties. See SKIP_TYPECHECK_MARKER. IDEA: might be more appropriate to only skip constraints check