Package org.apache.bcel.generic
Class LocalVariableGen
- java.lang.Object
-
- org.apache.bcel.generic.LocalVariableGen
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,InstructionTargeter,NamedAndTyped
public class LocalVariableGen extends java.lang.Object implements InstructionTargeter, NamedAndTyped, java.lang.Cloneable, java.io.Serializable
This class 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.- Version:
- $Id: LocalVariableGen.java 386056 2006-03-15 11:31:56Z tcurdt $
- Author:
- M. Dahm
- See Also:
LocalVariable,MethodGen, Serialized Form
-
-
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'.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()booleancontainsTarget(InstructionHandle ih)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()LocalVariablegetLocalVariable(ConstantPoolGen cp)Get LocalVariable object.java.lang.StringgetName()InstructionHandlegetStart()TypegetType()inthashCode()voidsetEnd(InstructionHandle end)voidsetIndex(int index)voidsetName(java.lang.String name)voidsetStart(InstructionHandle start)voidsetType(Type type)java.lang.StringtoString()voidupdateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
-
-
-
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)
-
-
Method Detail
-
getLocalVariable
public LocalVariable getLocalVariable(ConstantPoolGen cp)
Get 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 for local variables whose scope end at the last instruction of the method's code, the JVM specification is ambiguous: both a start_pc+length ending at the last instruction and start_pc+length ending at first index beyond the end of the code are valid.- Parameters:
cp- constant pool
-
setIndex
public void setIndex(int index)
-
getIndex
public int getIndex()
-
setName
public void setName(java.lang.String name)
- Specified by:
setNamein interfaceNamedAndTyped
-
getName
public java.lang.String getName()
- Specified by:
getNamein interfaceNamedAndTyped
-
setType
public void setType(Type type)
- Specified by:
setTypein interfaceNamedAndTyped
-
getType
public Type getType()
- Specified by:
getTypein interfaceNamedAndTyped
-
getStart
public InstructionHandle getStart()
-
getEnd
public InstructionHandle getEnd()
-
setStart
public void setStart(InstructionHandle start)
-
setEnd
public void setEnd(InstructionHandle end)
-
updateTarget
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
- Specified by:
updateTargetin interfaceInstructionTargeter- Parameters:
old_ih- old target, either start or endnew_ih- new target
-
containsTarget
public boolean containsTarget(InstructionHandle ih)
- Specified by:
containsTargetin interfaceInstructionTargeter- Returns:
- true, if ih is target of this variable
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- Returns:
- a hash code value for the object.
-
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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clone
public java.lang.Object clone()
- Overrides:
clonein classjava.lang.Object
-
-