Package serp.bytecode
Class LocalVariableInstruction
java.lang.Object
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.
- Author:
- Abe White
-
Method Summary
Modifier and TypeMethodDescriptionbooleanequalsInstruction(Instruction other) Two local variable instructions are equal if the local index they reference is equal or if either index is 0/unset.intgetLocal()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.intgetParam()Return the parameter that this instruction operates on, or -1 if none.Return the type name for this instruction.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, setType, setTypeMethods inherited from class serp.bytecode.Instruction
acceptVisit, getByteIndex, getClassLoader, getCode, getLineNumber, getLogicalStackChange, getName, getOpcode, getPool, getProject, getStackChange, isValid
-
Method Details
-
getTypeName
Description copied from class:TypedInstructionReturn the type name for this instruction. If the type has not been set, this method will return null.- Specified by:
getTypeNamein classTypedInstruction
-
setType
Description copied from class:TypedInstructionSet the type of this instruction. Types that have no direct support will be converted accordingly.- Specified by:
setTypein 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:
equalsInstructionin classInstruction
-