Package EDU.purdue.cs.bloat.editor
Class LocalVariable
- java.lang.Object
-
- EDU.purdue.cs.bloat.editor.LocalVariable
-
public class LocalVariable extends java.lang.ObjectLocalVariable represents a local variable index operand to various instructions.
-
-
Constructor Summary
Constructors Constructor Description LocalVariable(int index)Constructor.LocalVariable(java.lang.String name, Type type, int index)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Check if an object is equal to this variable.inthashCode()Hash the local variable.intindex()Get the index into the local variable array.java.lang.Stringname()Get the name of the local variable.java.lang.StringtoString()Convert the variable to a string.Typetype()Get the type of the local variable.
-
-
-
Constructor Detail
-
LocalVariable
public LocalVariable(int index)
Constructor.- Parameters:
index- The index of the local variable in the method's local variable array.
-
LocalVariable
public LocalVariable(java.lang.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 Detail
-
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:
hashCodein classjava.lang.Object- Returns:
- The hash code.
-
equals
public boolean equals(java.lang.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:
equalsin classjava.lang.Object- Parameters:
obj- The object to compare against.- Returns:
- true if equal, false if not.
-
name
public java.lang.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 java.lang.String toString()
Convert the variable to a string.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the variable.
-
-