Package EDU.purdue.cs.bloat.editor
Class Label
- java.lang.Object
-
- EDU.purdue.cs.bloat.editor.Label
-
public class Label extends java.lang.ObjectLabel is used to label an instruction. Labels are used to preserve the location of branch targets. A Label consists of an index into the code array and a boolean that determines whether or not it starts a basic block.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanTRACE
-
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 label.inthashCode()Hash the label.intindex()Get the index of the label.voidsetComment(java.lang.String comment)Sets the comment associated with this Label.voidsetStartsBlock(boolean startsBlock)Set if the label starts a block.booleanstartsBlock()Check if the label starts a block.java.lang.StringtoString()Convert the label to a string.
-
-
-
Constructor Detail
-
Label
public Label(int index)
Constructor.- Parameters:
index- A unique index for the label. For instance, its offset in the instruction array.
-
Label
public Label(int index, boolean startsBlock)Constructor.- Parameters:
index- The index of this label into the instruction arraystartsBlock- True if the label is the first instruction in a basic block, false if not.
-
-
Method Detail
-
setComment
public void setComment(java.lang.String comment)
Sets the comment associated with this Label.
-
setStartsBlock
public void setStartsBlock(boolean startsBlock)
Set if the label starts a block.- Parameters:
startsBlock- True if the label starts a block, false if not.
-
startsBlock
public boolean startsBlock()
Check if the label starts a block.- Returns:
- True if the label starts a block, false if not.
-
index
public int index()
Get the index of the label.- Returns:
- The index of the label.
-
hashCode
public int hashCode()
Hash the label.- 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 label.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- The object to compare against.- Returns:
- true if equal, false if not.
-
toString
public java.lang.String toString()
Convert the label to a string.- Overrides:
toStringin classjava.lang.Object- Returns:
- A string representation of the label.
-
-