Class VmObject

    • Field Detail

      • members

        protected final org.graalvm.collections.UnmodifiableEconomicMap<java.lang.Object,​ObjectMember> members
      • cachedValues

        protected final org.graalvm.collections.EconomicMap<java.lang.Object,​java.lang.Object> cachedValues
      • cachedHash

        protected int cachedHash
    • Constructor Detail

      • VmObject

        public VmObject​(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame,
                        @Nullable VmObject parent,
                        org.graalvm.collections.UnmodifiableEconomicMap<java.lang.Object,​ObjectMember> members,
                        org.graalvm.collections.EconomicMap<java.lang.Object,​java.lang.Object> cachedValues)
      • VmObject

        public VmObject​(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame,
                        @Nullable VmObject parent,
                        org.graalvm.collections.UnmodifiableEconomicMap<java.lang.Object,​ObjectMember> members)
    • Method Detail

      • lateInitParent

        public final void lateInitParent​(VmObject parent)
      • getParent

        public @Nullable VmObject getParent()
        Description copied from class: VmObjectLike
        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`.
        Specified by:
        getParent in class VmObjectLike
      • hasMember

        public final boolean hasMember​(java.lang.Object key)
        Description copied from class: VmObjectLike
        Always prefer this method over `getMembers().containsKey(key)`.
        Specified by:
        hasMember in class VmObjectLike
      • getMembers

        public final org.graalvm.collections.UnmodifiableEconomicMap<java.lang.Object,​ObjectMember> getMembers()
        Description copied from class: VmObjectLike
        Returns the declared members of this object.
        Specified by:
        getMembers in class VmObjectLike
      • getCachedValue

        public final @Nullable java.lang.Object getCachedValue​(java.lang.Object key)
        Description copied from class: VmObjectLike
        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.
        Specified by:
        getCachedValue in class VmObjectLike
      • setCachedValue

        public final void setCachedValue​(java.lang.Object key,
                                         java.lang.Object value)
        Description copied from class: VmObjectLike
        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.
        Specified by:
        setCachedValue in class VmObjectLike
      • iterateMemberValues

        public final boolean iterateMemberValues​(VmObjectLike.MemberValueConsumer consumer)
        Description copied from class: VmObjectLike
        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.
        Specified by:
        iterateMemberValues in class VmObjectLike
      • iterateMembers

        public final boolean iterateMembers​(java.util.function.BiFunction<java.lang.Object,​ObjectMember,​java.lang.Boolean> consumer)
        Description copied from class: VmObjectLike
        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.
        Specified by:
        iterateMembers in class VmObjectLike
      • force

        public final void force​(boolean allowUndefinedValues,
                                boolean recurse)
        Evaluates this object's members. Skips local, hidden, and external members.
        Specified by:
        force in class VmObjectLike
      • force

        public final void force​(boolean allowUndefinedValues)
        Description copied from class: VmValue
        Forces recursive (deep) evaluation of this value.
        Specified by:
        force in class VmValue
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • exportMembers

        protected final java.util.Map<java.lang.String,​java.lang.Object> exportMembers()
        Exports this object's members. Skips local members, hidden members, class definitions, and type aliases. Members that haven't been forced have a `null` value.