Package org.pkl.core.runtime
Class VmObject
java.lang.Object
org.pkl.core.runtime.VmValue
org.pkl.core.runtime.VmObjectLike
org.pkl.core.runtime.VmObject
- Direct Known Subclasses:
VmDynamic,VmListingOrMapping,VmTyped
Corresponds to `pkl.base#Object`.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.pkl.core.runtime.VmObjectLike
VmObjectLike.ForcedMemberValueConsumer, VmObjectLike.MemberValueConsumer -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected final org.graalvm.collections.UnmodifiableEconomicMap<Object, ObjectMember> Fields inherited from class org.pkl.core.runtime.VmObjectLike
enclosingFrame, extraStorage -
Constructor Summary
ConstructorsConstructorDescriptionVmObject(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame, @Nullable VmObject parent, org.graalvm.collections.UnmodifiableEconomicMap<Object, ObjectMember> members) VmObject(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame, @Nullable VmObject parent, org.graalvm.collections.UnmodifiableEconomicMap<Object, ObjectMember> members, org.graalvm.collections.EconomicMap<Object, Object> cachedValues) -
Method Summary
Modifier and TypeMethodDescriptionExports this object's members.final voidforce(boolean allowUndefinedValues) Forces recursive (deep) evaluation of this value.final voidforce(boolean allowUndefinedValues, boolean recurse) Evaluates this object's members.final booleanSame asVmObjectLike.iterateMemberValues(org.pkl.core.runtime.VmObjectLike.MemberValueConsumer)except that it first performs a shallowVmObjectLike.force(boolean, boolean).getCachedValue(Object key) Reads from the properties cache for this object.final @Nullable ObjectMemberAlways prefer this method over `getMembers().get(key)`.final org.graalvm.collections.UnmodifiableEconomicMap<Object, ObjectMember> Returns the declared members of this object.Returns the parent object in the prototype chain.final booleanhasCachedValue(Object key) Prefer this method overVmObjectLike.getCachedValue(java.lang.Object)if the value is not required.final booleanAlways prefer this method over `getMembers().containsKey(key)`.final booleanfinal booleaniterateMembers(BiFunction<Object, ObjectMember, Boolean> consumer) Iterates over member definitions in order of their definition, from the top of the prototype chain downwards.final booleanIterates over member definitions and their values in order of their definition, from the top of the prototype chain downwards.final voidlateInitParent(VmObject parent) final voidsetCachedValue(Object key, Object value) Writes to the properties cache for this object.final StringtoString()Methods inherited from class org.pkl.core.runtime.VmObjectLike
export, getEnclosingFrame, getEnclosingOwner, getEnclosingReceiver, getExtraStorage, hasExtraStorage, isModuleObject, setExtraStorageMethods inherited from class org.pkl.core.runtime.VmValue
accept, accept, equals, export, exportNullable, force, getPrototype, getVmClass, isDynamic, isListing, isMapping, isPrototype, isSequence, isTyped
-
Field Details
-
parent
-
members
-
cachedValues
-
cachedHash
protected int cachedHash
-
-
Constructor Details
-
VmObject
-
VmObject
public VmObject(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame, @Nullable @Nullable VmObject parent, org.graalvm.collections.UnmodifiableEconomicMap<Object, ObjectMember> members)
-
-
Method Details
-
lateInitParent
-
getParent
Description copied from class:VmObjectLikeReturns the parent object in the prototype chain. For each concrete subclass X of VmObjectLike, the exact return type of this method is `X|VmTyped`.- Specified by:
getParentin classVmObjectLike
-
hasMember
Description copied from class:VmObjectLikeAlways prefer this method over `getMembers().containsKey(key)`.- Specified by:
hasMemberin classVmObjectLike
-
getMember
Description copied from class:VmObjectLikeAlways prefer this method over `getMembers().get(key)`.- Specified by:
getMemberin classVmObjectLike
-
getMembers
Description copied from class:VmObjectLikeReturns the declared members of this object.- Specified by:
getMembersin classVmObjectLike
-
getCachedValue
Description copied from class:VmObjectLikeReads 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:
getCachedValuein classVmObjectLike
-
setCachedValue
Description copied from class:VmObjectLikeWrites 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:
setCachedValuein classVmObjectLike
-
hasCachedValue
Description copied from class:VmObjectLikePrefer this method overVmObjectLike.getCachedValue(java.lang.Object)if the value is not required. (There is no point in calling this method to determine whether to callVmObjectLike.getCachedValue(java.lang.Object).)- Specified by:
hasCachedValuein classVmObjectLike
-
iterateMemberValues
Description copied from class:VmObjectLikeIterates 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:
iterateMemberValuesin classVmObjectLike
-
forceAndIterateMemberValues
Description copied from class:VmObjectLikeSame asVmObjectLike.iterateMemberValues(org.pkl.core.runtime.VmObjectLike.MemberValueConsumer)except that it first performs a shallowVmObjectLike.force(boolean, boolean). As a consequence, values passed toconsumerare guaranteed to be non-null.- Specified by:
forceAndIterateMemberValuesin classVmObjectLike
-
iterateAlreadyForcedMemberValues
public final boolean iterateAlreadyForcedMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer) - Specified by:
iterateAlreadyForcedMemberValuesin classVmObjectLike
-
iterateMembers
Description copied from class:VmObjectLikeIterates 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:
iterateMembersin classVmObjectLike
-
force
public final void force(boolean allowUndefinedValues, boolean recurse) Evaluates this object's members. Skips local, hidden, and external members.- Specified by:
forcein classVmObjectLike
-
force
public final void force(boolean allowUndefinedValues) Description copied from class:VmValueForces recursive (deep) evaluation of this value. -
toString
-
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.
-