Class DynamicObject.GetKeyArrayNode
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.object.DynamicObject.GetKeyArrayNode
- All Implemented Interfaces:
NodeInterface, Cloneable
- Enclosing class:
DynamicObject
Gets a snapshot of the object's property keys, in insertion order.
- Since:
- 25.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Node
Node.Child, Node.Children -
Method Summary
Modifier and TypeMethodDescriptioncreate()abstract Object[]execute(DynamicObject receiver) Gets a snapshot of the object's property keys, in insertion order.Methods 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
-
Method Details
-
execute
Gets a snapshot of the object's property keys, in insertion order. The returned array may have been cached and must not be mutated. Properties with aHiddenKeyare not included.Usage example:
The example below shows how the returned keys array could be translated to an interop array for use with InteropLibrary.@ExportMessage Object getMembers(boolean includeInternal, @Cached DynamicObject.GetKeyArrayNode getKeyArrayNode) { return new Keys(getKeyArrayNode.execute(this)); } @ExportLibrary(InteropLibrary.class) static final class Keys implements TruffleObject { @CompilationFinal(dimensions = 1) final Object[] keys; Keys(Object[] keys) { this.keys = keys; } @ExportMessage boolean hasArrayElements() { return true; } @ExportMessage Object readArrayElement(long index) throws InvalidArrayIndexException { if (!isArrayElementReadable(index)) { throw InvalidArrayIndexException.create(index); } return keys[(int) index]; } @ExportMessage long getArraySize() { return keys.length; } @ExportMessage boolean isArrayElementReadable(long index) { return index >= 0 && index < keys.length; } }- Returns:
- a read-only array of the object's property keys. Do not modify.
-
create
- Since:
- 25.1
-
getUncached
- Since:
- 25.1
-