public abstract class DynamicObject extends Object implements TruffleObject
Shape| Modifier | Constructor and Description |
|---|---|
protected |
DynamicObject(Shape shape)
Constructor for subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
containsKey(Object key)
Returns
true if this object contains a property with the given key. |
abstract DynamicObject |
copy(Shape currentShape)
Create a shallow copy of this object.
|
void |
define(Object key,
Object value)
Define new property or redefine existing property.
|
abstract void |
define(Object key,
Object value,
int flags)
Define new property or redefine existing property.
|
abstract void |
define(Object key,
Object value,
int flags,
LocationFactory locationFactory)
Define new property with a static location or change existing property.
|
abstract boolean |
delete(Object key)
Delete property.
|
Object |
get(Object key)
Get property value.
|
abstract Object |
get(Object key,
Object defaultValue)
Get property value.
|
Shape |
getShape()
Get the object's current shape.
|
abstract boolean |
isEmpty()
Returns
true if this object contains no properties. |
abstract boolean |
set(Object key,
Object value)
Set value of existing property.
|
abstract void |
setShapeAndGrow(Shape oldShape,
Shape newShape)
Set object shape and grow storage if necessary.
|
abstract void |
setShapeAndResize(Shape oldShape,
Shape newShape)
Set object shape and resize storage if necessary.
|
abstract int |
size()
Returns the number of properties in this object.
|
abstract boolean |
updateShape()
Ensure object shape is up-to-date.
|
protected DynamicObject(Shape shape)
public final Shape getShape()
public final Object get(Object key)
key - property identifiernull if object has no such propertypublic abstract Object get(Object key, Object defaultValue)
key - property identifierdefaultValue - return value if property is not foundpublic abstract boolean set(Object key, Object value)
key - property identifiervalue - value to be settrue if successful or false if property not foundpublic final boolean containsKey(Object key)
true if this object contains a property with the given key.public final void define(Object key, Object value)
key - property identifiervalue - value to be setpublic abstract void define(Object key, Object value, int flags)
key - property identifiervalue - value to be setflags - flags to be setpublic abstract void define(Object key, Object value, int flags, LocationFactory locationFactory)
key - property identifiervalue - value to be setflags - flags to be setlocationFactory - factory function that creates a location for a given shape and valuepublic abstract boolean delete(Object key)
key - property identifiertrue if successful or false if property not foundpublic abstract int size()
public abstract boolean isEmpty()
true if this object contains no properties.public abstract void setShapeAndGrow(Shape oldShape, Shape newShape)
oldShape - the object's current shape (must equal DynamicObject.getShape())newShape - the new shape to be setpublic abstract void setShapeAndResize(Shape oldShape, Shape newShape)
oldShape - the object's current shape (must equal DynamicObject.getShape())newShape - the new shape to be setpublic abstract boolean updateShape()
true if shape has changedpublic abstract DynamicObject copy(Shape currentShape)
currentShape - the object's current shape (must equal DynamicObject.getShape())