Package serp.bytecode
Class FieldInstruction
- java.lang.Object
-
- serp.bytecode.CodeEntry
-
- serp.bytecode.Instruction
-
- serp.bytecode.FieldInstruction
-
- All Implemented Interfaces:
BCEntity
,VisitAcceptor
- Direct Known Subclasses:
GetFieldInstruction
,PutFieldInstruction
public abstract class FieldInstruction extends Instruction
Instruction that takes as an argument a field to operate on. Examples includegetfield, getstatic, setfield, setstatic
.
-
-
Constructor Summary
Constructors Constructor Description FieldInstruction(Code owner, int opcode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equalsInstruction(Instruction other)
FieldInstructions are equal if the field they reference is the same, or if the field of either is unset.BCField
getField()
Return the field this instruction operates on, or null if not set.BCClass
getFieldDeclarerBC()
Return the declaring class of the field this instruction operates on, or null if not set.java.lang.String
getFieldDeclarerName()
Return the declaring class of the field this instruction operates on, or null if not set.java.lang.Class
getFieldDeclarerType()
Return the declaring class of the field this instruction operates on, or null if not set.int
getFieldIndex()
Return the index in the classConstantPool
of theComplexEntry
describing the field to operate on.java.lang.String
getFieldName()
Return the name of the field this instruction operates on, or null if not set.java.lang.Class
getFieldType()
Return the type of the field this instruction operates on, or null if not set.BCClass
getFieldTypeBC()
Return the type of the field this instruction operates on, or null if not set.java.lang.String
getFieldTypeName()
Return the type of the field this instruction operates on, or null if not set.(package private) int
getLength()
Return the length in bytes of this opcode, including all arguments.(package private) void
read(java.io.DataInput in)
Read the arguments for this opcode from the given stream.(package private) void
read(Instruction orig)
Copy the given instruction data.FieldInstruction
setField(java.lang.Class dec, java.lang.String name, java.lang.Class type)
Set the field this instruction operates on.FieldInstruction
setField(java.lang.reflect.Field field)
Set the field this instruction operates on.FieldInstruction
setField(java.lang.String name, java.lang.Class type)
Set the field this instruction operates on, for fields that are declared by the current class.FieldInstruction
setField(java.lang.String name, java.lang.String type)
Set the field this instruction operates on, for fields that are declared by the current class.FieldInstruction
setField(java.lang.String dec, java.lang.String name, java.lang.String type)
Set the field this instruction operates on.FieldInstruction
setField(java.lang.String name, BCClass type)
Set the field this instruction operates on, for fields that are declared by the current class.FieldInstruction
setField(BCClass dec, java.lang.String name, BCClass type)
Set the field this instruction operates on.FieldInstruction
setField(BCField field)
Set the field this instruction operates on.FieldInstruction
setFieldDeclarer(java.lang.Class type)
Set the declaring class of the field this instruction operates on.FieldInstruction
setFieldDeclarer(java.lang.String type)
Set the declaring class of the field this instruction operates on.FieldInstruction
setFieldDeclarer(BCClass type)
Set the declaring class of the field this instruction operates on.FieldInstruction
setFieldIndex(int index)
Set the index in the classConstantPool
of theComplexEntry
describing the field to operate on.FieldInstruction
setFieldName(java.lang.String name)
Set the name of the field this instruction operates on.FieldInstruction
setFieldType(java.lang.Class type)
Set the type of the field this instruction operates on.FieldInstruction
setFieldType(java.lang.String type)
Set the type of the field this instruction operates on.FieldInstruction
setFieldType(BCClass type)
Set the type of the field this instruction operates on.(package private) void
write(java.io.DataOutput out)
Write the arguments for this opcode to the given stream.-
Methods inherited from class serp.bytecode.Instruction
acceptVisit, getByteIndex, getClassLoader, getCode, getLineNumber, getLogicalStackChange, getName, getOpcode, getPool, getProject, getStackChange, invalidate, invalidateByteIndexes, isValid, setOpcode
-
-
-
-
Constructor Detail
-
FieldInstruction
FieldInstruction(Code owner, int opcode)
-
-
Method Detail
-
getLength
int getLength()
Description copied from class:Instruction
Return the length in bytes of this opcode, including all arguments. For many opcodes this method relies on an up-to-date byte index.- Overrides:
getLength
in classInstruction
-
getFieldIndex
public int getFieldIndex()
Return the index in the classConstantPool
of theComplexEntry
describing the field to operate on.
-
setFieldIndex
public FieldInstruction setFieldIndex(int index)
Set the index in the classConstantPool
of theComplexEntry
describing the field to operate on.- Returns:
- this instruction, for method chaining
-
getField
public BCField getField()
Return the field this instruction operates on, or null if not set.
-
setField
public FieldInstruction setField(BCField field)
Set the field this instruction operates on.- Returns:
- this instruction, for method chaining
-
setField
public FieldInstruction setField(java.lang.reflect.Field field)
Set the field this instruction operates on.- Returns:
- this instruction, for method chaining
-
setField
public FieldInstruction setField(java.lang.String dec, java.lang.String name, java.lang.String type)
Set the field this instruction operates on.- Parameters:
dec
- the full class name of the field's declaring classname
- the field nametype
- the full class name of the field type- Returns:
- this instruction, for method chaining
-
setField
public FieldInstruction setField(java.lang.String name, java.lang.String type)
Set the field this instruction operates on, for fields that are declared by the current class.- Parameters:
name
- the field nametype
- the full class name of the field type- Returns:
- this instruction, for method chaining
-
setField
public FieldInstruction setField(java.lang.Class dec, java.lang.String name, java.lang.Class type)
Set the field this instruction operates on.- Parameters:
dec
- the field's declaring classname
- the field nametype
- the class of the field type- Returns:
- this instruction, for method chaining
-
setField
public FieldInstruction setField(java.lang.String name, java.lang.Class type)
Set the field this instruction operates on, for fields that are declared by the current class.- Parameters:
name
- the field nametype
- the class of the field type- Returns:
- this instruction, for method chaining
-
setField
public FieldInstruction setField(BCClass dec, java.lang.String name, BCClass type)
Set the field this instruction operates on.- Parameters:
dec
- the field's declaring classname
- the field nametype
- the class of the field type- Returns:
- this instruction, for method chaining
-
setField
public FieldInstruction setField(java.lang.String name, BCClass type)
Set the field this instruction operates on, for fields that are declared by the current class.- Parameters:
name
- the field nametype
- the class of the field type- Returns:
- this instruction, for method chaining
-
getFieldName
public java.lang.String getFieldName()
Return the name of the field this instruction operates on, or null if not set.
-
setFieldName
public FieldInstruction setFieldName(java.lang.String name)
Set the name of the field this instruction operates on.- Returns:
- this instruction, for method chaining
-
getFieldTypeName
public java.lang.String getFieldTypeName()
Return the type of the field this instruction operates on, or null if not set.
-
getFieldType
public java.lang.Class getFieldType()
Return the type of the field this instruction operates on, or null if not set.
-
getFieldTypeBC
public BCClass getFieldTypeBC()
Return the type of the field this instruction operates on, or null if not set.
-
setFieldType
public FieldInstruction setFieldType(java.lang.String type)
Set the type of the field this instruction operates on.- Returns:
- this instruction, for method chaining
-
setFieldType
public FieldInstruction setFieldType(java.lang.Class type)
Set the type of the field this instruction operates on.- Returns:
- this instruction, for method chaining
-
setFieldType
public FieldInstruction setFieldType(BCClass type)
Set the type of the field this instruction operates on.- Returns:
- this instruction, for method chaining
-
getFieldDeclarerName
public java.lang.String getFieldDeclarerName()
Return the declaring class of the field this instruction operates on, or null if not set.
-
getFieldDeclarerType
public java.lang.Class getFieldDeclarerType()
Return the declaring class of the field this instruction operates on, or null if not set.
-
getFieldDeclarerBC
public BCClass getFieldDeclarerBC()
Return the declaring class of the field this instruction operates on, or null if not set.
-
setFieldDeclarer
public FieldInstruction setFieldDeclarer(java.lang.String type)
Set the declaring class of the field this instruction operates on.- Returns:
- this instruction, for method chaining
-
setFieldDeclarer
public FieldInstruction setFieldDeclarer(java.lang.Class type)
Set the declaring class of the field this instruction operates on.- Returns:
- this instruction, for method chaining
-
setFieldDeclarer
public FieldInstruction setFieldDeclarer(BCClass type)
Set the declaring class of the field this instruction operates on.- Returns:
- this instruction, for method chaining
-
equalsInstruction
public boolean equalsInstruction(Instruction other)
FieldInstructions are equal if the field they reference is the same, or if the field of either is unset.- Overrides:
equalsInstruction
in classInstruction
-
read
void read(Instruction orig)
Description copied from class:Instruction
Copy the given instruction data.- Overrides:
read
in classInstruction
-
read
void read(java.io.DataInput in) throws java.io.IOException
Description copied from class:Instruction
Read the arguments for this opcode from the given stream. This method should be overridden by opcodes that take arguments.- Overrides:
read
in classInstruction
- Throws:
java.io.IOException
-
write
void write(java.io.DataOutput out) throws java.io.IOException
Description copied from class:Instruction
Write the arguments for this opcode to the given stream. This method should be overridden by opcodes that take arguments.- Overrides:
write
in classInstruction
- Throws:
java.io.IOException
-
-