Package com.oracle.truffle.api.object
Class PropertyGetter
java.lang.Object
com.oracle.truffle.api.object.PropertyGetter
A lightweight property getter that allows getting the value of a
DynamicObject
property without any lookup or cache dispatch. Only objects of a specific
Shape
are accepted. Therefore, it should only be
used where the object is already known to have the supported shape.- Since:
- 22.2
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
accepts
(DynamicObject receiver) Returnstrue
if thisPropertyGetter
can be used with the given receiver object to get the property's value.get
(DynamicObject receiver) Gets the property's value from the given receiver object if the object has the supportedShape
, i.e.double
getDouble
(DynamicObject receiver) Gets the property's value from the given receiver object if the object has the supportedShape
.int
getFlags()
Returns the flags associated with the property represented by this getter.int
getInt
(DynamicObject receiver) Gets the property's value from the given receiver object if the object has the supportedShape
.getKey()
Returns the key of the property represented by this getter.long
getLong
(DynamicObject receiver) Gets the property's value from the given receiver object if the object has the supportedShape
.
-
Method Details
-
accepts
Returnstrue
if thisPropertyGetter
can be used with the given receiver object to get the property's value.- Parameters:
receiver
- the receiver object- Returns:
true
if the shape of the receiver object is supported by thisPropertyGetter
.- Since:
- 22.2
- See Also:
-
get
Gets the property's value from the given receiver object if the object has the supportedShape
, i.e. the shape this property getter was created with. Otherwise, throws anIllegalArgumentException
.- Parameters:
receiver
- the receiver object- Returns:
- the property's value
- Throws:
IllegalArgumentException
- if the object does not have the expected shape.- Since:
- 22.2
-
getInt
Gets the property's value from the given receiver object if the object has the supportedShape
. Expects anint
value or throws anUnexpectedResultException
if the value is of a different type. If the object's shape is not supported, throws anIllegalArgumentException
.- Parameters:
receiver
- the receiver object- Returns:
- the property's value
- Throws:
IllegalArgumentException
- if the object does not have the expected shape.UnexpectedResultException
- if the location does not contain an int value.- Since:
- 22.2
- See Also:
-
getLong
Gets the property's value from the given receiver object if the object has the supportedShape
. Expects along
value or throws anUnexpectedResultException
if the value is of a different type. If the object's shape is not supported, throws anIllegalArgumentException
.- Parameters:
receiver
- the receiver object- Returns:
- the property's value
- Throws:
IllegalArgumentException
- if the object does not have the expected shape.UnexpectedResultException
- if the location does not contain a long value.- Since:
- 22.2
- See Also:
-
getDouble
Gets the property's value from the given receiver object if the object has the supportedShape
. Expects adouble
value or throws anUnexpectedResultException
if the value is of a different type. If the object's shape is not supported, throws anIllegalArgumentException
.- Parameters:
receiver
- the receiver object- Returns:
- the property's value
- Throws:
IllegalArgumentException
- if the object does not have the expected shape.UnexpectedResultException
- if the location does not contain a double value.- Since:
- 22.2
- See Also:
-
getKey
Returns the key of the property represented by this getter.- Since:
- 22.2
- See Also:
-
getFlags
public int getFlags()Returns the flags associated with the property represented by this getter.- Since:
- 22.2
- See Also:
-