Package org.jruby.runtime.ivars
Class FieldVariableAccessor
java.lang.Object
org.jruby.runtime.ivars.VariableAccessor
org.jruby.runtime.ivars.FieldVariableAccessor
- Direct Known Subclasses:
RawFieldVariableAccessor
A variable accessor that accesses a field directly;
-
Field Summary
Fields inherited from class org.jruby.runtime.ivars.VariableAccessor
classId, DUMMY_ACCESSOR, index, name, realClass
-
Constructor Summary
ConstructorsConstructorDescriptionFieldVariableAccessor
(RubyClass realClass, String name, int index, int classId, MethodHandle getter, MethodHandle setter) Construct a new FieldVariableAccessor for the given "real" class, variable name, variable index, class ID, and field offset -
Method Summary
Modifier and TypeMethodDescriptionRetrieve the variable's value from the given object.getOrNil
(Object object, ThreadContext context) Retrieve the variable's value from the given object.void
Set this variable into the given object using Unsafe to ensure safe updating of the variable table.protected MethodHandle
wrapSetter
(MethodHandle setter) Methods inherited from class org.jruby.runtime.ivars.VariableAccessor
getClassId, getIndex, getName, getOrUndefined, getVariable, toString, verify
-
Constructor Details
-
FieldVariableAccessor
public FieldVariableAccessor(RubyClass realClass, String name, int index, int classId, MethodHandle getter, MethodHandle setter) Construct a new FieldVariableAccessor for the given "real" class, variable name, variable index, class ID, and field offset- Parameters:
realClass
- the "real" classname
- the variable's nameindex
- the variable's indexclassId
- the class's IDgetter
- the getter handle for the fieldsetter
- the setter handle for the field
-
-
Method Details
-
wrapSetter
-
getGetter
-
getSetter
-
get
Retrieve the variable's value from the given object.- Overrides:
get
in classVariableAccessor
- Parameters:
object
- the object from which to retrieve this variable- Returns:
- the variable's value
-
getOrNil
Retrieve the variable's value from the given object.- Overrides:
getOrNil
in classVariableAccessor
- Parameters:
object
- the object from which to retrieve this variable- Returns:
- the variable's value
-
set
Set this variable into the given object using Unsafe to ensure safe updating of the variable table.- Overrides:
set
in classVariableAccessor
- Parameters:
object
- the object into which to set this variablevalue
- the variable's value
-