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
Corresponds to `pkl.base#Object|pkl.base#Function`. The lexical scope is a chain of
`VmObjectLike` instances.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.oracle.truffle.api.frame.MaterializedFrameThe frame that was active when this object was instantiated. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedVmObjectLike(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame) -
Method Summary
Modifier and TypeMethodDescriptionabstract Objectexport()Exports this object to an external representation.abstract voidforce(boolean allowUndefinedValues, boolean recurse) Forces shallow or recursive (deep) evaluation of this object.abstract booleanSame asiterateMemberValues(org.pkl.core.runtime.VmObjectLike.MemberValueConsumer)except that it first performs a shallowforce(boolean, boolean).getCachedValue(Object key) Reads from the properties cache for this object.final com.oracle.truffle.api.frame.MaterializedFramefinal @Nullable VmObjectLikeabstract @Nullable ObjectMemberAlways prefer this method over `getMembers().get(key)`.abstract org.graalvm.collections.UnmodifiableEconomicMap<Object, ObjectMember> Returns the declared members of this object.abstract @Nullable VmObjectLikeReturns the parent object in the prototype chain.abstract booleanhasCachedValue(Object key) Prefer this method overgetCachedValue(java.lang.Object)if the value is not required.final booleanabstract booleanAlways prefer this method over `getMembers().containsKey(key)`.booleanabstract booleanabstract booleaniterateMembers(BiFunction<Object, ObjectMember, Boolean> consumer) Iterates over member definitions in order of their definition, from the top of the prototype chain downwards.abstract booleanIterates over member definitions and their values in order of their definition, from the top of the prototype chain downwards.abstract voidsetCachedValue(Object key, Object value) Writes to the properties cache for this object.final voidsetExtraStorage(@Nullable 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 Details
-
enclosingFrame
protected final com.oracle.truffle.api.frame.MaterializedFrame enclosingFrameThe frame that was active when this object was instantiated. * -
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
-
getEnclosingOwner
-
hasExtraStorage
public final boolean hasExtraStorage() -
getExtraStorage
-
setExtraStorage
-
isModuleObject
public boolean isModuleObject() -
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
Always prefer this method over `getMembers().containsKey(key)`. -
getMember
Always prefer this method over `getMembers().get(key)`. -
getMembers
Returns the declared members of this object. -
getCachedValue
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
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
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
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
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
Exports this object to an external representation. Does not export local, hidden, or external properties
-