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
ConstructorsConstructorDescriptionLocalVariableGen(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()booleanTests whether this targeter targets the specified instruction handle.booleanWe consider to local variables to be equal, if the use the same index and are valid in the same range.getEnd()Gets the end instruction handle.intgetIndex()Gets the index.booleanGets whether the variable lives to the end.Gets LocalVariable object.getName()Gets the name.intGets the original index.getStart()Gets the start instruction handle.getType()Gets the type.inthashCode()voidsetEnd(InstructionHandle end) Sets the end instruction handle.voidsetIndex(int index) Sets the index.voidsetLiveToEnd(boolean liveToEnd) Sets whether the variable lives to the end.voidSets the name.voidsetStart(InstructionHandle start) Sets the start instruction handle.voidSets the type.toString()voidupdateTarget(InstructionHandle oldIh, InstructionHandle newIh) 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 variable.name- its name.type- its type.start- 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 variable.name- its name.type- its type.start- 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
-
clone
-
containsTarget
Description copied from interface:InstructionTargeterTests whether this targeter targets the specified instruction handle.- Specified by:
containsTargetin interfaceInstructionTargeter- Parameters:
ih- the instruction handle to test.- Returns:
- true, if ih is target of this variable.
-
equals
-
getEnd
Gets the end instruction handle.- Returns:
- the end instruction handle.
-
getIndex
-
getLiveToEnd
Gets whether the variable lives to the end.- Returns:
- true if the variable lives to the end.
-
getLocalVariable
Gets LocalVariable object. This relies on that the instruction list has already been dumped to byte code 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.- Returns:
- the local variable.
-
getName
Description copied from interface:NamedAndTypedGets the name.- Specified by:
getNamein interfaceNamedAndTyped- Returns:
- the name.
-
getOrigIndex
-
getStart
Gets the start instruction handle.- Returns:
- the start instruction handle.
-
getType
Description copied from interface:NamedAndTypedGets the type.- Specified by:
getTypein interfaceNamedAndTyped- Returns:
- the type.
-
hashCode
-
setEnd
Sets the end instruction handle.- Parameters:
end- the end instruction handle.
-
setIndex
-
setLiveToEnd
Sets whether the variable lives to the end.- Parameters:
liveToEnd- true if the variable lives to the end.
-
setName
Description copied from interface:NamedAndTypedSets the name.- Specified by:
setNamein interfaceNamedAndTyped- Parameters:
name- the name.
-
setStart
Sets the start instruction handle.- Parameters:
start- the start instruction handle.
-
setType
Description copied from interface:NamedAndTypedSets the type.- Specified by:
setTypein interfaceNamedAndTyped- Parameters:
type- the type.
-
toString
-
updateTarget
Description copied from interface:InstructionTargeterReplaces the target of this targeter from this old handle to the new handle.- Specified by:
updateTargetin interfaceInstructionTargeter- Parameters:
oldIh- old target, either start or end.newIh- new target.
-