DynamicObject.GetNode
public abstract static class DynamicObject.GetNode extends Node- Enclosing type
DynamicObject
Gets the value of a property or returns a default value if no such property exists.
Specialized return type variants are available for when a primitive result is expected.
See also
Methods6 + 26 inherited
Object execute(DynamicObject, Object, Object)
execute
abstractsince 25.1public abstract Object execute(DynamicObject receiver, Object key, Object defaultValue)Gets the value of an existing property or returns the provided default value if no such property exists.
Usage examples:
Simple use of GetNode with a pre-interned symbol key.
abstract static class GetSimpleNode extends Node {
abstract Object execute(DynamicObject receiver, Object key);
@Specialization
static Object doCached(MyDynamicObjectSubclass receiver, Symbol key,
@Cached DynamicObject.GetNode getNode) {
return getNode.execute(receiver, key, NULL_VALUE);
}
}Simple use of GetNode with a string key cached by equality.
abstract static class GetStringKeyNode extends Node {
abstract Object execute(DynamicObject receiver, Object key);
@Specialization(guards = "equalNode.execute(key, cachedKey, UTF_16)", limit = "3")
static Object doCached(MyDynamicObjectSubclass receiver, TruffleString key,
@Cached("key") TruffleString cachedKey,
@Cached TruffleString.EqualNode equalNode,
@Cached DynamicObject.GetNode getNode) {
return getNode.execute(receiver, cachedKey, NULL_VALUE);
}
}Parameters
receiverDynamicObject- No description.
keyObject- the property key, compared by identity (
==), not equality (equals). SeeDynamicObjectfor more information. defaultValueObject- value to be returned if the property does not exist
Returns
Object- the property's value if it exists, else
defaultValue.
int executeInt(DynamicObject, Object, Object)
executeInt
abstractsince 25.1public abstract int executeInt(
DynamicObject receiver,
Object key,
Object defaultValue
) throws UnexpectedResultExceptionGets the value of an existing property or returns the provided default value if no such property exists.
Parameters
receiverDynamicObject- No description.
keyObject- the property key, compared by identity (
==), not equality (equals). SeeDynamicObjectfor more information. defaultValueObject- the value to be returned if the property does not exist
Returns
int- the property's value if it exists, else
defaultValue.
Throws
UnexpectedResultException- if the value (or default value if the property is missing) is not an
int
long executeLong(DynamicObject, Object, Object)
executeLong
abstractsince 25.1public abstract long executeLong(
DynamicObject receiver,
Object key,
Object defaultValue
) throws UnexpectedResultExceptionGets the value of an existing property or returns the provided default value if no such property exists.
Parameters
receiverDynamicObject- No description.
keyObject- the property key, compared by identity (
==), not equality (equals). SeeDynamicObjectfor more information. defaultValueObject- the value to be returned if the property does not exist
Returns
long- the property's value if it exists, else
defaultValue.
Throws
UnexpectedResultException- if the value (or default value if the property is missing) is not an
long
double executeDouble(DynamicObject, Object, Object)
executeDouble
abstractsince 25.1public abstract double executeDouble(
DynamicObject receiver,
Object key,
Object defaultValue
) throws UnexpectedResultExceptionGets the value of an existing property or returns the provided default value if no such property exists.
Parameters
receiverDynamicObject- No description.
keyObject- the property key, compared by identity (
==), not equality (equals). SeeDynamicObjectfor more information. defaultValueObject- the value to be returned if the property does not exist
Returns
double- the property's value if it exists, else
defaultValue.
Throws
UnexpectedResultException- if the value (or default value if the property is missing) is not an
double
static DynamicObject.GetNode create()No description.
create
staticsince 25.1public static DynamicObject.GetNode create()No description.
Returns
DynamicObject.GetNode- No description.
static DynamicObject.GetNode getUncached()No description.
getUncached
staticsince 25.1public static DynamicObject.GetNode getUncached()No description.
Returns
DynamicObject.GetNode- No description.