Package org.apache.bcel.generic
Class LocalVariableGen
java.lang.Object
org.apache.bcel.generic.LocalVariableGen
- All Implemented Interfaces:
Cloneable
,InstructionTargeter
,NamedAndTyped
public class LocalVariableGen
extends Object
implements InstructionTargeter, NamedAndTyped, Cloneable
Represents a local variable within a method. It contains its
scope, name and type. The generated LocalVariable object can be obtained
with getLocalVariable which needs the instruction list and the constant
pool as parameters.
- See Also:
-
Constructor Summary
ConstructorDescriptionLocalVariableGen
(int index, String name, Type type, InstructionHandle start, InstructionHandle end) Generate a local variable that with index `index'.LocalVariableGen
(int index, String name, Type type, InstructionHandle start, InstructionHandle end, int origIndex) Generates a local variable that with index `index'. -
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
Checks whether this targeter targets the specified instruction handle.boolean
We consider to local variables to be equal, if the use the same index and are valid in the same range.getEnd()
int
getIndex()
boolean
Gets LocalVariable object.getName()
int
getStart()
getType()
int
hashCode()
void
setEnd
(InstructionHandle end) void
setIndex
(int index) void
setLiveToEnd
(boolean live_to_end) void
void
setStart
(InstructionHandle start) void
toString()
void
updateTarget
(InstructionHandle old_ih, InstructionHandle new_ih) Replaces the target of this targeter from this old handle to the new handle.
-
Constructor Details
-
LocalVariableGen
public LocalVariableGen(int index, String name, Type type, InstructionHandle start, InstructionHandle end) Generate a local variable that with index `index'. Note that double and long variables need two indexs. Index indices have to be provided by the user.- Parameters:
index
- index of local variablename
- its nametype
- its typestart
- from where the instruction is valid (null means from the start)end
- until where the instruction is valid (null means to the end)
-
LocalVariableGen
public LocalVariableGen(int index, String name, Type type, InstructionHandle start, InstructionHandle end, int origIndex) Generates a local variable that with index `index'. Note that double and long variables need two indexs. Index indices have to be provided by the user.- Parameters:
index
- index of local variablename
- its nametype
- its typestart
- from where the instruction is valid (null means from the start)end
- until where the instruction is valid (null means to the end)origIndex
- index of local variable prior to any changes to index
-
-
Method Details
-
getLocalVariable
Gets LocalVariable object. This relies on that the instruction list has already been dumped to byte code or or that the `setPositions' methods has been called for the instruction list. Note that due to the conversion from byte code offset to InstructionHandle, it is impossible to tell the difference between a live range that ends BEFORE the last insturction of the method or a live range that ends AFTER the last instruction of the method. Hence the liveToEnd flag to differentiate between these two cases.- Parameters:
cp
- constant pool
-
setIndex
public void setIndex(int index) -
getIndex
public int getIndex() -
getOrigIndex
public int getOrigIndex() -
setLiveToEnd
public void setLiveToEnd(boolean live_to_end) -
getLiveToEnd
public boolean getLiveToEnd() -
setName
- Specified by:
setName
in interfaceNamedAndTyped
-
getName
- Specified by:
getName
in interfaceNamedAndTyped
-
setType
- Specified by:
setType
in interfaceNamedAndTyped
-
getType
- Specified by:
getType
in interfaceNamedAndTyped
-
getStart
-
getEnd
-
setStart
-
setEnd
-
updateTarget
Description copied from interface:InstructionTargeter
Replaces the target of this targeter from this old handle to the new handle.- Specified by:
updateTarget
in interfaceInstructionTargeter
- Parameters:
old_ih
- old target, either start or endnew_ih
- new target
-
containsTarget
Description copied from interface:InstructionTargeter
Checks whether this targeter targets the specified instruction handle.- Specified by:
containsTarget
in interfaceInstructionTargeter
- Returns:
- true, if ih is target of this variable
-
hashCode
public int hashCode() -
equals
We consider to local variables to be equal, if the use the same index and are valid in the same range. -
toString
-
clone
-