Package gnu.bytecode

Class Variable

All Implemented Interfaces:
Enumeration

public class Variable extends Location implements Enumeration
Information about a local variable in a method's code.
  • Field Details

    • offset

      public int offset
      The local variable slot number used by this variable. Not used (by the codegen layer) if !isSimple().
  • Constructor Details

    • Variable

      public Variable()
    • Variable

      public Variable(String name)
    • Variable

      public Variable(String name, Type type)
  • Method Details

    • nextVar

      public final Variable nextVar()
    • hasMoreElements

      public final boolean hasMoreElements()
      Specified by:
      hasMoreElements in interface Enumeration
    • nextElement

      public Object nextElement()
      Specified by:
      nextElement in interface Enumeration
    • isAssigned

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

      public Scope getScope()
    • 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 String toString()
      Overrides:
      toString in class Object