Class 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 hierarchy of `VmOwner`s.
    • Field Detail

      • enclosingFrame

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

        protected @Nullable java.lang.Object extraStorage
    • Constructor Detail

      • VmObjectLike

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

      • getEnclosingFrame

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

        public final @Nullable java.lang.Object getEnclosingReceiver()
      • hasExtraStorage

        public final boolean hasExtraStorage()
      • getExtraStorage

        public final java.lang.Object getExtraStorage()
      • setExtraStorage

        public final void setExtraStorage​(@Nullable java.lang.Object extraStorage)
      • isModuleObject

        public boolean isModuleObject()
      • getParent

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

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

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

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

        public abstract @Nullable java.lang.Object getCachedValue​(java.lang.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​(java.lang.Object key,
                                            java.lang.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.
      • 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.
      • iterateMembers

        public abstract boolean iterateMembers​(java.util.function.BiFunction<java.lang.Object,​ObjectMember,​java.lang.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 java.lang.Object export()
        Exports this object to an external representation. Does not export local, hidden, or external properties
        Specified by:
        export in class VmValue