public abstract class VariableAccessor
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
classId
the symbol of the class associated with this variable
|
static VariableAccessor |
DUMMY_ACCESSOR
a dummy accessor that will always return null
|
protected int |
index
the index allocated for it in the variable table
|
protected java.lang.String |
name
the name of the variable
|
protected RubyClass |
realClass
the "real" class associated with this variable
|
Constructor and Description |
---|
VariableAccessor(RubyClass realClass,
java.lang.String name,
int index,
int classId)
Construct a new VariableAccessor for the given "real" class, name,
variable index, and class symbol.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
get(java.lang.Object object)
Retrieve the variable's value from the given object.
|
int |
getClassId()
Get the symbol of the class associated with this variable.
|
int |
getIndex()
Get the index allocated for this variable.
|
java.lang.String |
getName()
Get the name of this variable.
|
static java.lang.Object |
getVariable(RubyBasicObject object,
int index)
Retrieve the variable's value from the given object.
|
void |
set(java.lang.Object object,
java.lang.Object value)
Set the value for this variable in the given object.
|
java.lang.String |
toString()
Produce a string representation of this VariableAccessor.
|
boolean |
verify(java.lang.Object object)
Verify if this is the correct accessor for the given object.
|
protected final java.lang.String name
protected final int index
protected final int classId
protected final RubyClass realClass
public static final VariableAccessor DUMMY_ACCESSOR
public VariableAccessor(RubyClass realClass, java.lang.String name, int index, int classId)
realClass
- the "real" classname
- the variable's nameindex
- the variable's indexclassId
- the class's symbolpublic int getClassId()
public int getIndex()
public java.lang.String getName()
public java.lang.Object get(java.lang.Object object)
object
- the object from which to retrieve this variablepublic static java.lang.Object getVariable(RubyBasicObject object, int index)
object
- the object from which to retrieve the variableindex
- the index of the variablepublic void set(java.lang.Object object, java.lang.Object value)
object
- the object into which to set this variablevalue
- the value of the variablepublic boolean verify(java.lang.Object object)
object
- the object for which to test this accessorpublic java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2001-2018 JRuby. All Rights Reserved.