org.biojava.utils.bytecode
Class LocalVariable

java.lang.Object
  extended by org.biojava.utils.bytecode.LocalVariable

public final class LocalVariable
extends java.lang.Object

A local variable.

Local variables are used as identifiers for things that can be stored and loaded from the local variable slots associated with each method. By using LocalVariable intances, you are removed from the taudry task of book-keeping these slots.

To use a local variable, create an intance and then use it in a code generator. The method will keep track of which local variables are in scope, and will handle all the nastiness for you. You can re-use the same local variable instance in different contexts, and it will be sanely allocated different or the same slots.

The JVM stores some things in single words, and others in pairs of words. To hide this detail from you, local variables take a class that indicates the type of thing they will store. Please populate this sensibly.

Author:
Thomas Down, Matthew Pocock

Constructor Summary
LocalVariable(CodeClass clazz)
          Create a new local variable that will store values of a given type.
LocalVariable(CodeClass clazz, java.lang.String name)
          Create a new local variable with a type and a name.
 
Method Summary
 java.lang.String getName()
           
 CodeClass getType()
           
 int needSlots()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocalVariable

public LocalVariable(CodeClass clazz)
Create a new local variable that will store values of a given type.

Parameters:
clazz - the type of the values stored in this variable

LocalVariable

public LocalVariable(CodeClass clazz,
                     java.lang.String name)
Create a new local variable with a type and a name.

The name may appear in debug output from the generator, and possibly in stack-traces.

Parameters:
clazz - the type of the values stored in this variable
name - the name of the variable
Method Detail

getName

public java.lang.String getName()

needSlots

public int needSlots()

getType

public CodeClass getType()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object