Package serp.bytecode
Class LocalVariableInstruction
java.lang.Object
serp.bytecode.CodeEntry
serp.bytecode.Instruction
serp.bytecode.TypedInstruction
serp.bytecode.LocalVariableInstruction
- All Implemented Interfaces:
BCEntity
,VisitAcceptor
- Direct Known Subclasses:
IIncInstruction
,LoadInstruction
,RetInstruction
,StoreInstruction
,WideInstruction
An instruction that has an argument of an index into the
local variable table of the current frame. This includes most of the
load
and store
instructions.
The local variable table size is fixed by the maxLocals
property of the code block. Long and double types take up 2 local variable
indexes.
Parameter values to methods are loaded into the local variable table prior to the execution of the first instruction. The 0 index of the table is set to the instance of the class the method is being invoked on.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLocalVariableInstruction
(Code owner) LocalVariableInstruction
(Code owner, int opcode) -
Method Summary
Modifier and TypeMethodDescription(package private) void
Subclasses can use this method to calculate the locals index based on their opcode.(package private) void
Subclasses with variable opcodes can use this method to be notified that information possibly affecting the opcode has been changed.boolean
equalsInstruction
(Instruction other) Two local variable instructions are equal if the local index they reference is equal or if either index is 0/unset.int
getLocal()
Return the index of the local variable that this instruction operates on.Return the local variable object this instruction operates on, or null if none.int
getParam()
Return the parameter that this instruction operates on, or -1 if none.Return the type name for this instruction.(package private) void
read
(Instruction orig) Copy the given instruction data.setLocal
(int index) Set the index of the local variable that this instruction operates on.setLocalVariable
(LocalVariable local) Set the local variable object this instruction operates on.setParam
(int param) Set the method parameter that this instruction operates on.Set the type of this instruction.Methods inherited from class serp.bytecode.TypedInstruction
getType, getTypeBC, mapType, setType, setType
Methods inherited from class serp.bytecode.Instruction
acceptVisit, getByteIndex, getClassLoader, getCode, getLength, getLineNumber, getLogicalStackChange, getName, getOpcode, getPool, getProject, getStackChange, invalidate, invalidateByteIndexes, isValid, read, setOpcode, write
-
Field Details
-
_index
private int _index
-
-
Constructor Details
-
Method Details
-
getTypeName
Description copied from class:TypedInstruction
Return the type name for this instruction. If the type has not been set, this method will return null.- Specified by:
getTypeName
in classTypedInstruction
-
setType
Description copied from class:TypedInstruction
Set the type of this instruction. Types that have no direct support will be converted accordingly.- Specified by:
setType
in classTypedInstruction
- Returns:
- this instruction, for method chaining
-
getLocal
public int getLocal()Return the index of the local variable that this instruction operates on. -
setLocal
Set the index of the local variable that this instruction operates on.- Returns:
- this instruction, for method chaining
-
getParam
public int getParam()Return the parameter that this instruction operates on, or -1 if none. -
setParam
Set the method parameter that this instruction operates on. This will set both the local index and the type of the instruction based on the current method parameters. -
getLocalVariable
Return the local variable object this instruction operates on, or null if none.- See Also:
-
setLocalVariable
Set the local variable object this instruction operates on. This method will set both the type and local index of this instruction from the given local variable.- Returns:
- this instruction, for method chaining
-
equalsInstruction
Two local variable instructions are equal if the local index they reference is equal or if either index is 0/unset.- Overrides:
equalsInstruction
in classInstruction
-
read
Description copied from class:Instruction
Copy the given instruction data.- Overrides:
read
in classInstruction
-
calculateOpcode
void calculateOpcode()Subclasses with variable opcodes can use this method to be notified that information possibly affecting the opcode has been changed. -
calculateLocal
void calculateLocal()Subclasses can use this method to calculate the locals index based on their opcode.
-