Package com.oracle.truffle.object
Class DynamicObjectImpl
- java.lang.Object
-
- com.oracle.truffle.object.DynamicObjectImpl
-
- All Implemented Interfaces:
DynamicObject,TypedObject,java.lang.Cloneable
- Direct Known Subclasses:
DynamicObjectBasic
public abstract class DynamicObjectImpl extends java.lang.Object implements DynamicObject, java.lang.Cloneable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.oracle.truffle.api.object.DynamicObject
DynamicObject.FlagsFunction
-
-
Field Summary
Fields Modifier and Type Field Description static DebugCounterreshapeCount
-
Constructor Summary
Constructors Constructor Description DynamicObjectImpl(Shape shape)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanchangeFlags(java.lang.Object id, int newFlags)Change property flags.booleanchangeFlags(java.lang.Object id, DynamicObject.FlagsFunction updateFunction)Change property flags.protected abstract booleancheckExtensionArrayInvariants(Shape newShape)Check whether the extension arrays are in accordance with the description in the shape.protected DynamicObjectclone()protected abstract DynamicObjectcloneWithShape(Shape currentShape)voidcopyProperties(DynamicObject fromObject, Shape ancestor)java.lang.StringdebugDump(int level)java.lang.StringdebugDump(int level, int levelStop)voiddefine(java.lang.Object id, java.lang.Object value, int flags)Define new property or redefine existing property.voiddefine(java.lang.Object id, java.lang.Object value, int flags, LocationFactory locationFactory)Define new property with a static location or change existing property.booleandelete(java.lang.Object id)Delete property.booleanequals(java.lang.Object obj)java.lang.Objectget(java.lang.Object id, java.lang.Object defaultValue)Get property value.ShapeImplgetShape()Get the object's current shape.java.lang.ObjectgetTypeIdentifier()protected abstract voidgrowObjectStore(Shape oldShape, Shape newShape)protected abstract voidgrowPrimitiveStore(Shape oldShape, Shape newShape)inthashCode()protected abstract voidinitialize(Shape initialShape)booleanisEmpty()Returnstrueif this object contains no properties.protected abstract voidresizeObjectStore(Shape oldShape, Shape newShape)protected abstract voidresizePrimitiveStore(Shape oldShape, Shape newShape)booleanset(java.lang.Object id, java.lang.Object value)Set value of existing property.protected voidsetShape(Shape shape)voidsetShapeAndGrow(Shape oldShape, Shape newShape)Set shape to an immediate child of the current shape, optionally growing the extension array.voidsetShapeAndResize(Shape newShape)voidsetShapeAndResize(Shape oldShape, Shape newShape)Set object shape and resize storage if necessary.intsize()Returns the number of properties in this object.java.lang.StringtoString()booleanupdateShape()Ensure object shape is up-to-date.
-
-
-
Field Detail
-
reshapeCount
public static final DebugCounter reshapeCount
-
-
Constructor Detail
-
DynamicObjectImpl
public DynamicObjectImpl(Shape shape)
-
-
Method Detail
-
getTypeIdentifier
public java.lang.Object getTypeIdentifier()
- Specified by:
getTypeIdentifierin interfaceTypedObject
-
getShape
public ShapeImpl getShape()
Description copied from interface:DynamicObjectGet the object's current shape.- Specified by:
getShapein interfaceDynamicObject
-
setShape
protected void setShape(Shape shape)
-
initialize
protected abstract void initialize(Shape initialShape)
-
setShapeAndResize
public final void setShapeAndResize(Shape newShape)
-
setShapeAndResize
public final void setShapeAndResize(Shape oldShape, Shape newShape)
Description copied from interface:DynamicObjectSet object shape and resize storage if necessary.- Specified by:
setShapeAndResizein interfaceDynamicObject- Parameters:
oldShape- the object's current shape (must equalDynamicObject.getShape())newShape- the new shape to be set
-
setShapeAndGrow
public final void setShapeAndGrow(Shape oldShape, Shape newShape)
Set shape to an immediate child of the current shape, optionally growing the extension array. Typically this would add a single property. Cannot shrink or grow more than one property at a time.- Specified by:
setShapeAndGrowin interfaceDynamicObject- Parameters:
oldShape- the object's current shape (must equalDynamicObject.getShape())newShape- the new shape to be set- See Also:
setShapeAndResize(Shape, Shape)
-
checkExtensionArrayInvariants
protected abstract boolean checkExtensionArrayInvariants(Shape newShape)
Check whether the extension arrays are in accordance with the description in the shape.
-
clone
protected final DynamicObject clone()
- Overrides:
clonein classjava.lang.Object
-
cloneWithShape
protected abstract DynamicObject cloneWithShape(Shape currentShape)
-
copyProperties
public final void copyProperties(DynamicObject fromObject, Shape ancestor)
-
changeFlags
public boolean changeFlags(java.lang.Object id, int newFlags)Description copied from interface:DynamicObjectChange property flags.- Specified by:
changeFlagsin interfaceDynamicObject- Parameters:
id- property identifiernewFlags- flags to be set- Returns:
trueif successful orfalseif property not found
-
changeFlags
public boolean changeFlags(java.lang.Object id, DynamicObject.FlagsFunction updateFunction)Description copied from interface:DynamicObjectChange property flags.- Specified by:
changeFlagsin interfaceDynamicObject- Parameters:
id- property identifierupdateFunction- function updating old flags to new flags- Returns:
trueif successful orfalseif property not found
-
debugDump
public java.lang.String debugDump(int level)
-
debugDump
public java.lang.String debugDump(int level, int levelStop)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
get
public java.lang.Object get(java.lang.Object id, java.lang.Object defaultValue)Description copied from interface:DynamicObjectGet property value.- Specified by:
getin interfaceDynamicObject- Parameters:
id- property identifierdefaultValue- return value if property is not found- Returns:
- property value or defaultValue if object has no such property
-
set
public boolean set(java.lang.Object id, java.lang.Object value)Description copied from interface:DynamicObjectSet value of existing property.- Specified by:
setin interfaceDynamicObject- Parameters:
id- property identifiervalue- value to be set- Returns:
trueif successful orfalseif property not found
-
define
public void define(java.lang.Object id, java.lang.Object value, int flags)Description copied from interface:DynamicObjectDefine new property or redefine existing property.- Specified by:
definein interfaceDynamicObject- Parameters:
id- property identifiervalue- value to be setflags- flags to be set
-
define
public void define(java.lang.Object id, java.lang.Object value, int flags, LocationFactory locationFactory)Description copied from interface:DynamicObjectDefine new property with a static location or change existing property.- Specified by:
definein interfaceDynamicObject- Parameters:
id- property identifiervalue- value to be setflags- flags to be setlocationFactory- factory function that creates a location for a given shape and value
-
delete
public boolean delete(java.lang.Object id)
Description copied from interface:DynamicObjectDelete property.- Specified by:
deletein interfaceDynamicObject- Parameters:
id- property identifier- Returns:
trueif successful orfalseif property not found
-
size
public int size()
Description copied from interface:DynamicObjectReturns the number of properties in this object.- Specified by:
sizein interfaceDynamicObject
-
isEmpty
public boolean isEmpty()
Description copied from interface:DynamicObjectReturnstrueif this object contains no properties.- Specified by:
isEmptyin interfaceDynamicObject
-
updateShape
public final boolean updateShape()
Description copied from interface:DynamicObjectEnsure object shape is up-to-date.- Specified by:
updateShapein interfaceDynamicObject- Returns:
trueif shape has changed
-
-