Interface StructuredSleigh.Label

All Known Implementing Classes:
StructuredSleigh.FreshLabel
Enclosing class:
StructuredSleigh

protected static interface StructuredSleigh.Label
A generated Sleigh label
  • Method Details

    • freshOrBorrow

      StructuredSleigh.Label freshOrBorrow()
      Borrow this label

      This should be used whenever a statement (or its children) may need to generate a goto using the "next" label passed into it. If "next" is the fall-through label, this will generate a fresh label. If this label is already fresh, this will "borrow" the label, meaning references will be generated, but it will not produce another anchor. This is to prevent generation of duplicate anchors.

      Returns:
      the resulting label
    • genAnchor

      StringTree genAnchor()
      Generate code for this label

      This must be the last method called on the label, because it relies on knowing whether or not the label is actually used. (The Sleigh compiler rejects code if it contains unused labels.)

      Returns:
      the Sleigh code
    • ref

      StringTree ref()
      Generate a reference to this label as it should appear in a Sleigh "goto" statement
      Returns:
      the label's expression
    • genGoto

      Generate a goto statement that targets this label
      Parameters:
      fall - the label following the goto
      Returns:
      the Sleigh code
    • genGoto

      Generate a conditional goto statement that targets this label
      Parameters:
      cond - the condition value
      fall - the label following the goto
      Returns:
      the Sleigh code