Class Label

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

public class Label extends Object
Label 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 boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Label(int index)
    Constructor.
    Label(int index, boolean startsBlock)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check if an object is equal to this label.
    int
    Hash the label.
    int
    Get the index of the label.
    void
    setComment(String comment)
    Sets the comment associated with this Label.
    void
    setStartsBlock(boolean startsBlock)
    Set if the label starts a block.
    boolean
    Check if the label starts a block.
    Convert the label to a string.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • TRACE

      public static boolean TRACE
  • Constructor Details

    • 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 array
      startsBlock - True if the label is the first instruction in a basic block, false if not.
  • Method Details

    • setComment

      public void setComment(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:
      hashCode in class Object
      Returns:
      The hash code.
    • equals

      public boolean equals(Object obj)
      Check if an object is equal to this label.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare against.
      Returns:
      true if equal, false if not.
    • toString

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