Package org.apache.bcel.generic
Class LocalVariableGen
- java.lang.Object
-
- org.apache.bcel.generic.LocalVariableGen
-
- All Implemented Interfaces:
java.lang.Cloneable,InstructionTargeter,NamedAndTyped
public class LocalVariableGen extends java.lang.Object implements InstructionTargeter, NamedAndTyped, java.lang.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:
LocalVariable,MethodGen
-
-
Constructor Summary
Constructors Constructor Description LocalVariableGen(int index, java.lang.String name, Type type, InstructionHandle start, InstructionHandle end)Generate a local variable that with index 'index'.LocalVariableGen(int index, java.lang.String name, Type type, InstructionHandle start, InstructionHandle end, int origIndex)Generates a local variable that with index 'index'.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()booleancontainsTarget(InstructionHandle ih)Tests whether this targeter targets the specified instruction handle.booleanequals(java.lang.Object o)We consider to local variables to be equal, if the use the same index and are valid in the same range.InstructionHandlegetEnd()intgetIndex()booleangetLiveToEnd()LocalVariablegetLocalVariable(ConstantPoolGen cp)Gets LocalVariable object.java.lang.StringgetName()intgetOrigIndex()InstructionHandlegetStart()TypegetType()inthashCode()voidsetEnd(InstructionHandle end)voidsetIndex(int index)voidsetLiveToEnd(boolean liveToEnd)voidsetName(java.lang.String name)voidsetStart(InstructionHandle start)voidsetType(Type type)java.lang.StringtoString()voidupdateTarget(InstructionHandle oldIh, InstructionHandle newIh)Replaces the target of this targeter from this old handle to the new handle.
-
-
-
Constructor Detail
-
LocalVariableGen
public LocalVariableGen(int index, java.lang.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, java.lang.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 Detail
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
containsTarget
public boolean containsTarget(InstructionHandle ih)
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
public boolean equals(java.lang.Object o)
We consider to local variables to be equal, if the use the same index and are valid in the same range.- Overrides:
equalsin classjava.lang.Object
-
getEnd
public InstructionHandle getEnd()
-
getIndex
public int getIndex()
-
getLiveToEnd
public boolean getLiveToEnd()
-
getLocalVariable
public LocalVariable getLocalVariable(ConstantPoolGen cp)
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
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceNamedAndTyped
-
getOrigIndex
public int getOrigIndex()
-
getStart
public InstructionHandle getStart()
-
getType
public Type getType()
- Specified by:
getTypein interfaceNamedAndTyped
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
setEnd
public void setEnd(InstructionHandle end)
-
setIndex
public void setIndex(int index)
-
setLiveToEnd
public void setLiveToEnd(boolean liveToEnd)
-
setName
public void setName(java.lang.String name)
- Specified by:
setNamein interfaceNamedAndTyped
-
setStart
public void setStart(InstructionHandle start)
-
setType
public void setType(Type type)
- Specified by:
setTypein interfaceNamedAndTyped
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
updateTarget
public void updateTarget(InstructionHandle oldIh, InstructionHandle newIh)
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 endnewIh- new target
-
-