Class LocalVariable

java.lang.Object
EDU.purdue.cs.bloat.editor.LocalVariable

public class LocalVariable extends Object
LocalVariable represents a local variable index operand to various instructions.
  • Constructor Details

    • LocalVariable

      public LocalVariable(int index)
      Constructor.
      Parameters:
      index - The index of the local variable in the method's local variable array.
    • LocalVariable

      public LocalVariable(String name, Type type, int index)
      Constructor.
      Parameters:
      name - The name of the local variable.
      type - The descriptor (or index into the constant pool) representing the variable type.
      index - The index of the local variable in the method's local variable array.
  • Method Details

    • hashCode

      public int hashCode()
      Hash the local variable. A stricter hashing than using the index will break Hashtable lookups since a variable could have a name assigned to it after its first use.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code.
    • equals

      public boolean equals(Object obj)
      Check if an object is equal to this variable. A stricter comparison than comparing indices will break Hashtable lookups since a variable could have a name assigned to it after its first use.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare against.
      Returns:
      true if equal, false if not.
    • name

      public String name()
      Get the name of the local variable.
      Returns:
      The name of the local variable.
    • type

      public Type type()
      Get the type of the local variable.
      Returns:
      The type of the local variable.
    • index

      public int index()
      Get the index into the local variable array.
      Returns:
      The index into the local variable array.
    • toString

      public String toString()
      Convert the variable to a string.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the variable.