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
`static DebugCounter` `reshapeCount`

### Constructor Summary

Constructors
`DynamicObjectImpl​(Shape shape)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`boolean` `changeFlags​(java.lang.Object id, int newFlags)` Change property flags.
`boolean` `changeFlags​(java.lang.Object id, DynamicObject.FlagsFunction updateFunction)` Change property flags.
`protected abstract boolean` `checkExtensionArrayInvariants​(Shape newShape)` Check whether the extension arrays are in accordance with the description in the shape.
`protected DynamicObject` `clone()`
`protected abstract DynamicObject` `cloneWithShape​(Shape currentShape)`
`void` `copyProperties​(DynamicObject fromObject, Shape ancestor)`
`java.lang.String` `debugDump​(int level)`
`java.lang.String` `debugDump​(int level, int levelStop)`
`void` `define​(java.lang.Object id, java.lang.Object value, int flags)` Define new property or redefine existing property.
`void` `define​(java.lang.Object id, java.lang.Object value, int flags, LocationFactory locationFactory)` Define new property with a static location or change existing property.
`boolean` `delete​(java.lang.Object id)` Delete property.
`boolean` `equals​(java.lang.Object obj)`
`java.lang.Object` `get​(java.lang.Object id, java.lang.Object defaultValue)` Get property value.
`ShapeImpl` `getShape()` Get the object's current shape.
`java.lang.Object` `getTypeIdentifier()`
`protected abstract void` `growObjectStore​(Shape oldShape, Shape newShape)`
`protected abstract void` `growPrimitiveStore​(Shape oldShape, Shape newShape)`
`int` `hashCode()`
`protected abstract void` `initialize​(Shape initialShape)`
`boolean` `isEmpty()` Returns `true` if this object contains no properties.
`protected abstract void` `resizeObjectStore​(Shape oldShape, Shape newShape)`
`protected abstract void` `resizePrimitiveStore​(Shape oldShape, Shape newShape)`
`boolean` `set​(java.lang.Object id, java.lang.Object value)` Set value of existing property.
`protected void` `setShape​(Shape shape)`
`void` `setShapeAndGrow​(Shape oldShape, Shape newShape)` Set shape to an immediate child of the current shape, optionally growing the extension array.
`void` `setShapeAndResize​(Shape newShape)`
`void` `setShapeAndResize​(Shape oldShape, Shape newShape)` Set object shape and resize storage if necessary.
`int` `size()` Returns the number of properties in this object.
`java.lang.String` `toString()`
`boolean` `updateShape()` Ensure object shape is up-to-date.

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### 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:
  `getTypeIdentifier` in interface `TypedObject`

#### getShape

    public ShapeImpl getShape()

Description copied from interface: `DynamicObject`
Get the object's current shape.

Specified by:
  `getShape` in interface `DynamicObject`

#### 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: `DynamicObject`
Set object shape and resize storage if necessary.

Specified by:
  `setShapeAndResize` in interface `DynamicObject`
Parameters:
  `oldShape` - the object's current shape (must equal `DynamicObject.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:
  `setShapeAndGrow` in interface `DynamicObject`
Parameters:
  `oldShape` - the object's current shape (must equal `DynamicObject.getShape()`)
  `newShape` - the new shape to be set
See Also:
  `setShapeAndResize(Shape, Shape)`

#### growObjectStore

    protected abstract void growObjectStore​(Shape oldShape,
                                            Shape newShape)

#### growPrimitiveStore

    protected abstract void growPrimitiveStore​(Shape oldShape,
                                               Shape newShape)

#### resizePrimitiveStore

    protected abstract void resizePrimitiveStore​(Shape oldShape,
                                                 Shape newShape)

#### resizeObjectStore

    protected abstract void resizeObjectStore​(Shape oldShape,
                                              Shape newShape)

#### 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:
  `clone` in class `java.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: `DynamicObject`
Change property flags.

Specified by:
  `changeFlags` in interface `DynamicObject`
Parameters:
  `id` - property identifier
  `newFlags` - flags to be set
Returns:
  `true` if successful or `false` if property not found

#### changeFlags

    public boolean changeFlags​(java.lang.Object id,
                               DynamicObject.FlagsFunction updateFunction)

Description copied from interface: `DynamicObject`
Change property flags.

Specified by:
  `changeFlags` in interface `DynamicObject`
Parameters:
  `id` - property identifier
  `updateFunction` - function updating old flags to new flags
Returns:
  `true` if successful or `false` if 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:
  `toString` in class `java.lang.Object`

#### equals

    public boolean equals​(java.lang.Object obj)

Overrides:
  `equals` in class `java.lang.Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `java.lang.Object`

#### get

    public java.lang.Object get​(java.lang.Object id,
                                java.lang.Object defaultValue)

Description copied from interface: `DynamicObject`
Get property value.

Specified by:
  `get` in interface `DynamicObject`
Parameters:
  `id` - property identifier
  `defaultValue` - 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: `DynamicObject`
Set value of existing property.

Specified by:
  `set` in interface `DynamicObject`
Parameters:
  `id` - property identifier
  `value` - value to be set
Returns:
  `true` if successful or `false` if property not found

#### define

    public void define​(java.lang.Object id,
                       java.lang.Object value,
                       int flags)

Description copied from interface: `DynamicObject`
Define new property or redefine existing property.

Specified by:
  `define` in interface `DynamicObject`
Parameters:
  `id` - property identifier
  `value` - value to be set
  `flags` - flags to be set

#### define

    public void define​(java.lang.Object id,
                       java.lang.Object value,
                       int flags,
                       LocationFactory locationFactory)

Description copied from interface: `DynamicObject`
Define new property with a static location or change existing property.

Specified by:
  `define` in interface `DynamicObject`
Parameters:
  `id` - property identifier
  `value` - value to be set
  `flags` - flags to be set
  `locationFactory` - factory function that creates a location for a given shape and value

#### delete

    public boolean delete​(java.lang.Object id)

Description copied from interface: `DynamicObject`
Delete property.

Specified by:
  `delete` in interface `DynamicObject`
Parameters:
  `id` - property identifier
Returns:
  `true` if successful or `false` if property not found

#### size

    public int size()

Description copied from interface: `DynamicObject`
Returns the number of properties in this object.

Specified by:
  `size` in interface `DynamicObject`

#### isEmpty

    public boolean isEmpty()

Description copied from interface: `DynamicObject`
Returns `true` if this object contains no properties.

Specified by:
  `isEmpty` in interface `DynamicObject`

#### updateShape

    public final boolean updateShape()

Description copied from interface: `DynamicObject`
Ensure object shape is up-to-date.

Specified by:
  `updateShape` in interface `DynamicObject`
Returns:
  `true` if shape has changed