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.
    • setReceiver

      public static void setReceiver(com.oracle.truffle.api.frame.Frame frame, Object receiver)
    • 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.
    • setOwner

      public static void setOwner(com.oracle.truffle.api.frame.Frame frame, VmObjectLike owner)
    • 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)
    • 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.)
    • 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)
    • isRenderDirective

      public static boolean isRenderDirective(VmValue value)
    • isRenderDirective

      public static boolean isRenderDirective(Object value)
    • 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(LexParseException e, String text, URI moduleUri, String moduleName)
    • toVmException

      public static VmException toVmException(LexParseException e, com.oracle.truffle.api.source.Source source, String moduleName)
    • exportDocComment

      @Nullable public static @Nullable String exportDocComment(@Nullable @Nullable com.oracle.truffle.api.source.SourceSection 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, @Nullable @Nullable 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)
    • findSlot

      public static int findSlot(com.oracle.truffle.api.frame.VirtualFrame frame, Object identifier)
    • findAuxiliarySlot

      public static int findAuxiliarySlot(com.oracle.truffle.api.frame.VirtualFrame frame, Object identifier)
    • getMapValue

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