gnu.bytecode
Class Variable

java.lang.Object
  extended by gnu.bytecode.Location
      extended by gnu.bytecode.Variable
All Implemented Interfaces:
java.util.Enumeration

public class Variable
extends Location
implements java.util.Enumeration


Field Summary
 
Fields inherited from class gnu.bytecode.Location
name, type
 
Constructor Summary
Variable()
           
Variable(java.lang.String name)
           
Variable(java.lang.String name, Type type)
           
 
Method Summary
 void allocateLocal(CodeAttr code)
          Allocate slots for a local variable (or parameter).
 boolean dead()
           
 void freeLocal(CodeAttr code)
           
 boolean hasMoreElements()
           
 boolean isAssigned()
          Returns true iff assigned to a local variable slot.
 boolean isParameter()
           
 boolean isSimple()
          Returns true for a "simple" variable.
 java.lang.Object nextElement()
           
 Variable nextVar()
           
 boolean reserveLocal(int varIndex, CodeAttr code)
          Assign a local variable to a given local variable slot.
 void setParameter(boolean parameter)
           
 void setSimple(boolean simple)
           
 java.lang.String toString()
           
 
Methods inherited from class gnu.bytecode.Location
getName, getSignature, getType, setName, setName, setSignature, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Variable

public Variable()

Variable

public Variable(java.lang.String name)

Variable

public Variable(java.lang.String name,
                Type type)
Method Detail

nextVar

public final Variable nextVar()

hasMoreElements

public final boolean hasMoreElements()
Specified by:
hasMoreElements in interface java.util.Enumeration

nextElement

public java.lang.Object nextElement()
Specified by:
nextElement in interface java.util.Enumeration

isAssigned

public final boolean isAssigned()
Returns true iff assigned to a local variable slot. Only relevant if isSimple ().


dead

public final boolean dead()

isSimple

public final boolean isSimple()
Returns true for a "simple" variable. A "simple" Variable can be stack-allocated using standard local variable slots. It is allocated by the codegen package. A non-simple variable may need heap allocation, or more more complex access; it is basically ignored by the codegen package, and must be managed by higher layers.


setSimple

public final void setSimple(boolean simple)

isParameter

public final boolean isParameter()

setParameter

public final void setParameter(boolean parameter)

reserveLocal

public boolean reserveLocal(int varIndex,
                            CodeAttr code)
Assign a local variable to a given local variable slot.

Parameters:
varIndex - the index of the local variables.
Returns:
true iff we succeeded (i.e. the slot was unused)

allocateLocal

public void allocateLocal(CodeAttr code)
Allocate slots for a local variable (or parameter).


freeLocal

public void freeLocal(CodeAttr code)

toString

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