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
public abstract class LocalVariableInstruction extends TypedInstruction
An instruction that has an argument of an index into the local variable table of the current frame. This includes most of theload
andstore
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.LocalVariable
getLocalVariable()
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.java.lang.String
getTypeName()
Return the type name for this instruction.LocalVariableInstruction
setLocal(int index)
Set the index of the local variable that this instruction operates on.LocalVariableInstruction
setLocalVariable(LocalVariable local)
Set the local variable object this instruction operates on.LocalVariableInstruction
setParam(int param)
Set the method parameter that this instruction operates on.TypedInstruction
setType(java.lang.String type)
Set the type of this instruction.-
Methods inherited from class serp.bytecode.TypedInstruction
getType, getTypeBC, setType, setType
-
Methods inherited from class serp.bytecode.Instruction
acceptVisit, getByteIndex, getClassLoader, getCode, getLineNumber, getLogicalStackChange, getName, getOpcode, getPool, getProject, getStackChange, isValid
-
-
-
-
Method Detail
-
getTypeName
public java.lang.String 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
public TypedInstruction setType(java.lang.String type)
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
public LocalVariableInstruction setLocal(int index)
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
public LocalVariableInstruction setParam(int param)
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
public LocalVariable getLocalVariable()
Return the local variable object this instruction operates on, or null if none.- See Also:
LocalVariableTable.getLocalVariable(int)
-
setLocalVariable
public LocalVariableInstruction setLocalVariable(LocalVariable local)
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
public 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.- Overrides:
equalsInstruction
in classInstruction
-
-