Class DynamicObject.GetShapeFlagsNode
java.lang.Object
com.oracle.truffle.api.nodes.Node
com.oracle.truffle.api.object.DynamicObject.GetShapeFlagsNode
- All Implemented Interfaces:
NodeInterface, Cloneable
- Enclosing class:
DynamicObject
Gets the language-specific object shape flags.
- 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 intexecute(DynamicObject receiver) Gets the language-specific object shape flags previously set usingDynamicObject.SetShapeFlagsNodeorShape.Builder.shapeFlags(int).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 the language-specific object shape flags previously set usingDynamicObject.SetShapeFlagsNodeorShape.Builder.shapeFlags(int). If no shape flags were explicitly set, the default of 0 is returned. These flags may be used to tag objects that possess characteristics that need to be queried efficiently on fast and slow paths. For example, they can be used to mark objects as frozen.Usage example:
Implementing frozen object check in writeMember:
Member name equality check omitted for brevity.static final int READ_ONLY = 1; static final int MISSING = -1; static final int FROZEN = 1; @ExportMessage void writeMember(String member, Object value, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached @Shared DynamicObject.GetPropertyFlagsNode getPropertyFlagsNode, @Cached DynamicObject.PutNode putNode) throws UnknownIdentifierException, UnsupportedMessageException { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { throw UnsupportedMessageException.create(); } int flags = getPropertyFlagsNode.execute(this, member, MISSING); if (flags == MISSING) { throw UnknownIdentifierException.create(member); } else if ((flags & READ_ONLY) == READ_ONLY) { throw UnsupportedMessageException.create(); } putNode.execute(this, member, value); } @ExportMessage boolean isMemberModifiable(String member, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached @Shared DynamicObject.GetPropertyFlagsNode getPropertyFlagsNode) { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { return false; } int flags = getPropertyFlagsNode.execute(this, member, MISSING); return flags != MISSING && (flags & READ_ONLY) == 0; } @ExportMessage boolean isMemberInsertable(String member, @Cached @Shared DynamicObject.GetShapeFlagsNode getShapeFlagsNode, @Cached @Shared DynamicObject.GetPropertyFlagsNode getPropertyFlagsNode) { if ((getShapeFlagsNode.execute(this) & FROZEN) == FROZEN) { return false; } return getPropertyFlagsNode.execute(this, member, MISSING) == MISSING; }- Returns:
- shape flags
- See Also:
-
create
- Since:
- 25.1
-
getUncached
- Since:
- 25.1
-