Class dec.trek.LocalThe Local object allows you to manipulate the local variables of a Method. To scan a methods normal local variables, you must use firstLocal or lastLocal in the Method class or override at(Local) in the Trek class. This set of local variables is called the method's Local Variables Table (LVT). Compilers supply LVTs to facilitate debugging. If a compiler does not supply LVTs, as in an optimized classfile, JTrek builds LVTs by analyzing each method's code. When a compiler supplies a method's LVT, it omits local variables that it created during code generation (as opposed to those declared by the developer). When a compiler does not supply an LVT, this distinction is lost. So in a JTrek-built LVT, all of the method's local variables are in the LVT. The methods getLocal and getReferenceArg in the Instruction class can be used to get an instruction's local variable. If the instruction uses a normal local, the returned Local is an object in the LVT. Otherwise the returned Local is an object that was created by the called method itself. Method Summary
Fieldspublic Object userDefined Field that can be used by an application developer to store arbitrary data about this object during the trek. Methodspublic Statement getDefinition() Returns the Statement object in which this local variable is defined. If this local is a method argument or catch argument, null is returned instead. Returns the Method object of the method in which this local variable is defined. Returns true if this local variable is an argument of its method. Note that this is not considered an argument. Returns true if this field is an array. Returns true if this local variable is the this variable of its method. public Local(String name, Object type, Method meth) Creates a new local variable in the specified method. This local is not placed in the method's LVT. Normally this constructor is used when you need inserted code to store something, but do not want to clobber any of the real data used in the method. Parameters: name the name you want to give the local variable type the local's data type is derived from this. If it is a Field, FieldRef, Local, TypeRef, or ValueRef, the new local is given this thing's data type. If it is a Method or MethodRef, the new local is given this method's return type. If it is a String, the new local's data type is set from the String's value, which must encode a data type as described in The Java Virtual Machine Specification. meth the method in which to create the local variable
Returns the Local object for the next local variable in this locals method, or null if there are no more. public Field prev()Returns the Local object for the previous local variable in this locals method, or null if there are no more. Returns the name of this local variable. Returns a persistent value that identifies this local variable. A reference to this local can be acquired by calling getObject on a trek that this local is within. An object Id for a local variable becomes obsolete if its method's object Id becomes obsolete or if its definition point is no longer within the range of definition of any local variable with its name. (Recall that the same name can mean different local variables in different parts of a method in Java). Returns the source statement that defined this local variable. Returns the data type of this local variable, for example int or java.lang.Object.
|