Class VmObjectLike

java.lang.Object
org.pkl.core.runtime.VmValue
org.pkl.core.runtime.VmObjectLike
Direct Known Subclasses:
VmFunction, VmObject

public abstract class VmObjectLike extends VmValue
Corresponds to `pkl.base#Object|pkl.base#Function`. The lexical scope is a chain of `VmObjectLike` instances.
  • Field Details

    • enclosingFrame

      protected final com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame
      The frame that was active when this object was instantiated. *
    • extraStorage

      @Nullable protected @Nullable Object extraStorage
  • Constructor Details

    • VmObjectLike

      protected VmObjectLike(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame)
  • Method Details

    • getEnclosingFrame

      public final com.oracle.truffle.api.frame.MaterializedFrame getEnclosingFrame()
    • getEnclosingReceiver

      @Nullable public final @Nullable Object getEnclosingReceiver()
    • getEnclosingOwner

      @Nullable public final @Nullable VmObjectLike getEnclosingOwner()
    • hasExtraStorage

      public final boolean hasExtraStorage()
    • getExtraStorage

      public Object getExtraStorage()
    • setExtraStorage

      public final void setExtraStorage(@Nullable @Nullable Object extraStorage)
    • isModuleObject

      public boolean isModuleObject()
    • getParent

      @Nullable public abstract @Nullable VmObjectLike getParent()
      Returns the parent object in the prototype chain. For each concrete subclass X of VmObjectLike, the exact return type of this method is `X|VmTyped`.
    • hasMember

      public abstract boolean hasMember(Object key)
      Always prefer this method over `getMembers().containsKey(key)`.
    • getMember

      @Nullable public abstract @Nullable ObjectMember getMember(Object key)
      Always prefer this method over `getMembers().get(key)`.
    • getMembers

      public abstract org.graalvm.collections.UnmodifiableEconomicMap<Object,ObjectMember> getMembers()
      Returns the declared members of this object.
    • getCachedValue

      @Nullable public abstract @Nullable Object getCachedValue(Object key)
      Reads from the properties cache for this object. The cache contains the values of all members defined in this object or an ancestor thereof which have been requested with this object as the receiver.
    • setCachedValue

      public abstract void setCachedValue(Object key, Object value)
      Writes to the properties cache for this object. The cache contains the values of all members defined in this object or an ancestor thereof which have been requested with this object as the receiver.
    • hasCachedValue

      public abstract boolean hasCachedValue(Object key)
      Prefer this method over getCachedValue(java.lang.Object) if the value is not required. (There is no point in calling this method to determine whether to call getCachedValue(java.lang.Object).)
    • iterateMemberValues

      public abstract boolean iterateMemberValues(VmObjectLike.MemberValueConsumer consumer)
      Iterates over member definitions and their values in order of their definition, from the top of the prototype chain downwards. If a member value has not yet been evaluated, a `null` `value` is passed to `consumer`. If a member is defined in multiple objects in the prototype chain, i.e., is overridden along the way, it is visited only once, with the initial (i.e., upmost) `member` and the final (i.e., downmost) `value`. (This peculiar behavior serves two purposes in the current implementation: it guarantees that a `hidden` property is still recognized as such when overridden, and that an element is still recognized as such when overridden with entry syntax. It also means that members are visited in order of (first) definition.) Local, hidden, and external properties are not visited. If an invocation of `consumer` returns `false`, the remaining members are not visited, and `false` is returned. Otherwise, all members are visited, and `true` is returned.
    • forceAndIterateMemberValues

      public abstract boolean forceAndIterateMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer)
      Same as iterateMemberValues(org.pkl.core.runtime.VmObjectLike.MemberValueConsumer) except that it first performs a shallow force(boolean, boolean). As a consequence, values passed to consumer are guaranteed to be non-null.
    • iterateAlreadyForcedMemberValues

      public abstract boolean iterateAlreadyForcedMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer)
    • iterateMembers

      public abstract boolean iterateMembers(BiFunction<Object,ObjectMember,Boolean> consumer)
      Iterates over member definitions in order of their definition, from the top of the prototype chain downwards. If a member is defined multiple times, each occurrence is visited. Local properties are not visited. If an invocation of `consumer` returns `false`, the remaining members are not visited, and `false` is returned. Otherwise, all members are visited, and `true` is returned.
    • force

      public abstract void force(boolean allowUndefinedValues, boolean recurse)
      Forces shallow or recursive (deep) evaluation of this object.
    • export

      public abstract Object export()
      Exports this object to an external representation. Does not export local, hidden, or external properties
      Specified by:
      export in class VmValue