Top Description Fields Constructors Methods
org.aspectj.apache.bcel.generic

public Class LocalVariableGen

extends Object
implements InstructionTargeter, Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable, org.aspectj.apache.bcel.generic.InstructionTargeter
Imports
org.aspectj.apache.bcel.Constants, org.aspectj.apache.bcel.classfile.ConstantPool, .LocalVariable

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.
Author
M. Dahm
Version
$Id: LocalVariableGen.java,v 1.7 2008/08/28 00:04:23 aclement Exp $
See Also
LocalVariable, MethodGen

Field Summary

Modifier and TypeField and Description
private InstructionHandle
private int
private String
private InstructionHandle
private Type

Constructor Summary

AccessConstructor and Description
public
LocalVariableGen(int
index of local variable
index
,
String
its name
name
,
Type
its type
type
,
InstructionHandle
from where the instruction is valid (null means from the start)
start
,
InstructionHandle
until where the instruction is valid (null means to the end)
end
)

Generate a local variable that with index `index'.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.
public boolean

Returns:

true, if ih is target of this variable
containsTarget
(InstructionHandle ih)

Implements org.aspectj.apache.bcel.generic.InstructionTargeter.containsTarget.

public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

We consider to local variables to be equal, if the use the same index and are valid in the same range.
public InstructionHandle
public int
public LocalVariable
getLocalVariable(ConstantPool
constant pool
cp
)

Get LocalVariable object.

public String
public InstructionHandle
public Type
public void
public void
setIndex(int index)

public void
public void
public void
setType(Type type)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
Inherited from java.lang.Object:
finalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

endback to summary
private InstructionHandle end
indexback to summary
private int index
nameback to summary
private String name
startback to summary
private InstructionHandle start
typeback to summary
private Type type

Constructor Detail

LocalVariableGenback to summary
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:int

index of local variable

name:String

its name

type:Type

its type

start:InstructionHandle

from where the instruction is valid (null means from the start)

end:InstructionHandle

until where the instruction is valid (null means to the end)

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

Returns:Object

a clone of this instance.

containsTargetback to summary
public boolean containsTarget(InstructionHandle ih)

Implements org.aspectj.apache.bcel.generic.InstructionTargeter.containsTarget.

Returns:boolean

true, if ih is target of this variable

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

We consider to local variables to be equal, if the use the same index and are valid in the same range.

Parameters
o:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

getEndback to summary
public InstructionHandle getEnd()
getIndexback to summary
public int getIndex()
getLocalVariableback to summary
public LocalVariable getLocalVariable(ConstantPool 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:ConstantPool

constant pool

getNameback to summary
public String getName()
getStartback to summary
public InstructionHandle getStart()
getTypeback to summary
public Type getType()
setEndback to summary
public void setEnd(InstructionHandle end)
setIndexback to summary
public void setIndex(int index)
setNameback to summary
public void setName(String name)
setStartback to summary
public void setStart(InstructionHandle start)
setTypeback to summary
public void setType(Type type)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

updateTargetback to summary
public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)

Implements org.aspectj.apache.bcel.generic.InstructionTargeter.updateTarget.

Parameters
old_ih:InstructionHandle

old target, either start or end

new_ih:InstructionHandle

new target