Package org.pkl.core.runtime
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 hierarchy of `VmOwner`s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceVmObjectLike.ForcedMemberValueConsumerstatic interfaceVmObjectLike.MemberValueConsumer
-
Field Summary
Fields Modifier and Type Field Description protected com.oracle.truffle.api.frame.MaterializedFrameenclosingFrameThe frame that was active when this object was instantiated.protected @Nullable java.lang.ObjectextraStorage
-
Constructor Summary
Constructors Modifier Constructor Description protectedVmObjectLike(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.lang.Objectexport()Exports this object to an external representation.abstract voidforce(boolean allowUndefinedValues, boolean recurse)Forces shallow or recursive (deep) evaluation of this object.abstract booleanforceAndIterateMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer)Same asiterateMemberValues(org.pkl.core.runtime.VmObjectLike.MemberValueConsumer)except that it first performs a shallowforce(boolean, boolean).abstract @Nullable java.lang.ObjectgetCachedValue(java.lang.Object key)Reads from the properties cache for this object.com.oracle.truffle.api.frame.MaterializedFramegetEnclosingFrame()@Nullable VmObjectLikegetEnclosingOwner()@Nullable java.lang.ObjectgetEnclosingReceiver()java.lang.ObjectgetExtraStorage()abstract @Nullable ObjectMembergetMember(java.lang.Object key)Always prefer this method over `getMembers().get(key)`.abstract org.graalvm.collections.UnmodifiableEconomicMap<java.lang.Object,ObjectMember>getMembers()Returns the declared members of this object.abstract @Nullable VmObjectLikegetParent()Returns the parent object in the prototype chain.abstract booleanhasCachedValue(java.lang.Object key)Prefer this method overgetCachedValue(java.lang.Object)if the value is not required.booleanhasExtraStorage()abstract booleanhasMember(java.lang.Object key)Always prefer this method over `getMembers().containsKey(key)`.booleanisModuleObject()abstract booleaniterateAlreadyForcedMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer)abstract booleaniterateMembers(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.abstract booleaniterateMemberValues(VmObjectLike.MemberValueConsumer consumer)Iterates over member definitions and their values in order of their definition, from the top of the prototype chain downwards.abstract voidsetCachedValue(java.lang.Object key, java.lang.Object value)Writes to the properties cache for this object.voidsetExtraStorage(@Nullable java.lang.Object extraStorage)-
Methods inherited from class org.pkl.core.runtime.VmValue
accept, accept, equals, export, exportNullable, force, force, getPrototype, getVmClass, isDynamic, isListing, isMapping, isPrototype, isSequence, isTyped
-
-
-
-
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
-
-
Method Detail
-
getEnclosingFrame
public final com.oracle.truffle.api.frame.MaterializedFrame getEnclosingFrame()
-
getEnclosingReceiver
public final @Nullable java.lang.Object getEnclosingReceiver()
-
getEnclosingOwner
public final @Nullable VmObjectLike getEnclosingOwner()
-
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.
-
hasCachedValue
public abstract boolean hasCachedValue(java.lang.Object key)
Prefer this method overgetCachedValue(java.lang.Object)if the value is not required. (There is no point in calling this method to determine whether to callgetCachedValue(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 asiterateMemberValues(org.pkl.core.runtime.VmObjectLike.MemberValueConsumer)except that it first performs a shallowforce(boolean, boolean). As a consequence, values passed toconsumerare guaranteed to be non-null.
-
iterateAlreadyForcedMemberValues
public abstract boolean iterateAlreadyForcedMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer)
-
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.
-
-