Package org.pkl.core.runtime
Class VmFunction
- java.lang.Object
-
- org.pkl.core.runtime.VmValue
-
- org.pkl.core.runtime.VmObjectLike
-
- org.pkl.core.runtime.VmFunction
-
public final class VmFunction extends VmObjectLike
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.pkl.core.runtime.VmObjectLike
VmObjectLike.ForcedMemberValueConsumer, VmObjectLike.MemberValueConsumer
-
-
Field Summary
-
Fields inherited from class org.pkl.core.runtime.VmObjectLike
enclosingFrame, extraStorage
-
-
Constructor Summary
Constructors Constructor Description VmFunction(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame, java.lang.Object thisValue, int paramCount, PklRootNode rootNode, @Nullable java.lang.Object extraStorage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Taccept(VmValueConverter<T> converter, java.lang.Iterable<java.lang.Object> path)voidaccept(VmValueVisitor visitor)java.lang.Objectapply(java.lang.Object arg1)java.lang.Objectapply(java.lang.Object arg1, java.lang.Object arg2)java.lang.StringapplyString(java.lang.Object arg1)VmFunctioncopy(int newParamCount, @Nullable PklRootNode newRootNode, @Nullable java.lang.Object newExtraStorage)booleanequals(java.lang.Object obj)Enables calling `vmValue.equals()` when not behind a Truffle boundary.java.lang.Objectexport()Exports this object to an external representation.voidforce(boolean allowUndefinedValues)Forces recursive (deep) evaluation of this value.voidforce(boolean allowUndefinedValues, boolean recurse)Forces shallow or recursive (deep) evaluation of this object.booleanforceAndIterateMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer)Same asVmObjectLike.iterateMemberValues(org.pkl.core.runtime.VmObjectLike.MemberValueConsumer)except that it first performs a shallowVmObjectLike.force(boolean, boolean).@Nullable java.lang.ObjectgetCachedValue(java.lang.Object key)Reads from the properties cache for this object.com.oracle.truffle.api.RootCallTargetgetCallTarget()@Nullable ObjectMembergetMember(java.lang.Object key)Always prefer this method over `getMembers().get(key)`.org.graalvm.collections.UnmodifiableEconomicMap<java.lang.Object,ObjectMember>getMembers()Returns the declared members of this object.intgetParameterCount()VmObjectLikegetParent()Returns the parent object in the prototype chain.java.lang.ObjectgetThisValue()VmClassgetVmClass()booleanhasCachedValue(java.lang.Object key)Prefer this method overVmObjectLike.getCachedValue(java.lang.Object)if the value is not required.inthashCode()booleanhasMember(java.lang.Object key)Always prefer this method over `getMembers().containsKey(key)`.booleaniterateAlreadyForcedMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer)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.booleaniterateMemberValues(VmObjectLike.MemberValueConsumer consumer)Iterates over member definitions and their values in order of their definition, from the top of the prototype chain downwards.voidsetCachedValue(java.lang.Object key, java.lang.Object value)Writes to the properties cache for this object.-
Methods inherited from class org.pkl.core.runtime.VmObjectLike
getEnclosingFrame, getEnclosingOwner, getEnclosingReceiver, getExtraStorage, hasExtraStorage, isModuleObject, setExtraStorage
-
Methods inherited from class org.pkl.core.runtime.VmValue
export, exportNullable, force, getPrototype, isDynamic, isListing, isMapping, isPrototype, isSequence, isTyped
-
-
-
-
Constructor Detail
-
VmFunction
public VmFunction(com.oracle.truffle.api.frame.MaterializedFrame enclosingFrame, java.lang.Object thisValue, int paramCount, PklRootNode rootNode, @Nullable java.lang.Object extraStorage)
-
-
Method Detail
-
getCallTarget
public com.oracle.truffle.api.RootCallTarget getCallTarget()
-
getParameterCount
public int getParameterCount()
-
apply
public java.lang.Object apply(java.lang.Object arg1)
-
applyString
public java.lang.String applyString(java.lang.Object arg1)
-
apply
public java.lang.Object apply(java.lang.Object arg1, java.lang.Object arg2)
-
copy
public VmFunction copy(int newParamCount, @Nullable PklRootNode newRootNode, @Nullable java.lang.Object newExtraStorage)
-
getThisValue
public java.lang.Object getThisValue()
-
getParent
public VmObjectLike getParent()
Description copied from class:VmObjectLikeReturns 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:
getParentin classVmObjectLike
-
hasMember
public boolean hasMember(java.lang.Object key)
Description copied from class:VmObjectLikeAlways prefer this method over `getMembers().containsKey(key)`.- Specified by:
hasMemberin classVmObjectLike
-
getMember
public @Nullable ObjectMember getMember(java.lang.Object key)
Description copied from class:VmObjectLikeAlways prefer this method over `getMembers().get(key)`.- Specified by:
getMemberin classVmObjectLike
-
getMembers
public org.graalvm.collections.UnmodifiableEconomicMap<java.lang.Object,ObjectMember> getMembers()
Description copied from class:VmObjectLikeReturns the declared members of this object.- Specified by:
getMembersin classVmObjectLike
-
getCachedValue
public @Nullable java.lang.Object getCachedValue(java.lang.Object key)
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
public void setCachedValue(java.lang.Object key, java.lang.Object value)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
public boolean hasCachedValue(java.lang.Object key)
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
public boolean iterateMemberValues(VmObjectLike.MemberValueConsumer consumer)
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
public boolean forceAndIterateMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer)
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 boolean iterateAlreadyForcedMemberValues(VmObjectLike.ForcedMemberValueConsumer consumer)
- Specified by:
iterateAlreadyForcedMemberValuesin classVmObjectLike
-
iterateMembers
public boolean iterateMembers(java.util.function.BiFunction<java.lang.Object,ObjectMember,java.lang.Boolean> consumer)
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
-
getVmClass
public VmClass getVmClass()
- Specified by:
getVmClassin classVmValue
-
force
public void force(boolean allowUndefinedValues, boolean recurse)Description copied from class:VmObjectLikeForces shallow or recursive (deep) evaluation of this object.- Specified by:
forcein classVmObjectLike
-
force
public void force(boolean allowUndefinedValues)
Description copied from class:VmValueForces recursive (deep) evaluation of this value.
-
export
public java.lang.Object export()
Description copied from class:VmObjectLikeExports this object to an external representation. Does not export local, hidden, or external properties- Specified by:
exportin classVmObjectLike
-
accept
public void accept(VmValueVisitor visitor)
-
accept
public <T> T accept(VmValueConverter<T> converter, java.lang.Iterable<java.lang.Object> path)
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:VmValueEnables calling `vmValue.equals()` when not behind a Truffle boundary.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-