Class DynamicObject.PutAllNode
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.object.DynamicObject.PutAllNode
- All Implemented Interfaces:
NodeInterface, Cloneable
- Enclosing class:
DynamicObject
Adds or sets multiple properties in bulk. Behaves like
DynamicObject.PutNode, but is usually more
efficient for cases like object initialization where more than a few properties are added at
once.- Since:
- 25.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Node
Node.Child, Node.Children -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DynamicObject.PutAllNodecreate()final voidexecute(DynamicObject receiver, Object[] keys, Object[] values) Adds multiple properties or sets the values of multiple existing properties at once.final voidexecuteIfAbsent(DynamicObject receiver, Object[] keys, Object[] values) Likeexecute(DynamicObject, Object[], Object[])but only adds properties that are absent.final voidexecuteIfPresent(DynamicObject receiver, Object[] keys, Object[] values) Likeexecute(DynamicObject, Object[], Object[])but only sets properties that are already present.final voidexecuteWithFlags(DynamicObject receiver, Object[] keys, Object[] values, int[] propertyFlags) Likeexecute(DynamicObject, Object[], Object[])but additionally sets property flags.final voidexecuteWithFlagsIfAbsent(DynamicObject receiver, Object[] keys, Object[] values, int[] propertyFlags) LikeexecuteIfAbsent(DynamicObject, Object[], Object[])but also sets property flags when adding a property.final voidexecuteWithFlagsIfPresent(DynamicObject receiver, Object[] keys, Object[] values, int[] propertyFlags) LikeexecuteIfPresent(DynamicObject, Object[], Object[])but also sets property flags when a property is present.static DynamicObject.PutAllNodeMethods inherited from class Node
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, reportReplace, toString
-
Constructor Details
-
PutAllNode
public PutAllNode()
-
-
Method Details
-
execute
Adds multiple properties or sets the values of multiple existing properties at once.Newly added properties will have flags 0; flags of existing properties will not be changed. Use
executeWithFlags(DynamicObject, Object[], Object[], int[])to set property flags as well.Cached property keys are compared by identity (
==), not equality (equals).Usage example:
Simple use of
DynamicObject.PutAllNodeto allocate and fill an object with properties.abstract static class ObjectInitializerNode extends Node { @CompilationFinal private Shape initialShape; @CompilationFinal(dimensions = 1) private Object[] keys; @Children private ExprNode[] valueNodes; abstract void execute(); @ExplodeLoop @Specialization void doDefault(@Cached DynamicObject.PutAllNode putAllNode) { var receiver = new MyDynamicObjectSubclass(initialShape); var values = new Object[keys.length]; for (int i = 0; i < keys.length; i++) { values[i] = valueNodes[i].execute(); } putAllNode.execute(receiver, keys, values); } }- Parameters:
keys- the property keys, compared by identity (==), not equality (equals). SeeDynamicObjectfor more information.values- the values to be set; needs to be the same length askeys- Since:
- 25.1
- See Also:
-
executeIfPresent
Likeexecute(DynamicObject, Object[], Object[])but only sets properties that are already present.- Since:
- 25.1
- See Also:
-
executeIfAbsent
Likeexecute(DynamicObject, Object[], Object[])but only adds properties that are absent.- Since:
- 25.1
- See Also:
-
executeWithFlags
public final void executeWithFlags(DynamicObject receiver, Object[] keys, Object[] values, int[] propertyFlags) Likeexecute(DynamicObject, Object[], Object[])but additionally sets property flags. If a property already exists, its flags will be updated before the value is set.- Parameters:
keys- the property keys, compared by identity (==), not equality (equals). SeeDynamicObjectfor more information.values- the values to be set; needs to be the same length askeyspropertyFlags- the property flags to be set; needs to be the same length as keys- Since:
- 25.1
-
executeWithFlagsIfPresent
public final void executeWithFlagsIfPresent(DynamicObject receiver, Object[] keys, Object[] values, int[] propertyFlags) LikeexecuteIfPresent(DynamicObject, Object[], Object[])but also sets property flags when a property is present.- Since:
- 25.1
- See Also:
-
executeWithFlagsIfAbsent
public final void executeWithFlagsIfAbsent(DynamicObject receiver, Object[] keys, Object[] values, int[] propertyFlags) LikeexecuteIfAbsent(DynamicObject, Object[], Object[])but also sets property flags when adding a property.- Since:
- 25.1
- See Also:
-
getUncached
-
create
-