Class LabelNode

All Implemented Interfaces:
LexicalContextNode, Terminal, Cloneable

public final class LabelNode extends Statement
IR representation for a labeled statement. It implements JoinPredecessor to hold conversions that need to be effected when the block exits normally, but is also targeted by a break statement that might bring different local variable types to the join at the break point.
  • Constructor Details

    • LabelNode

      public LabelNode(int lineNumber, long token, int finish, String labelName, Block body)
      Constructor
      Parameters:
      lineNumber - line number
      token - token
      finish - finish
      labelName - label name
      body - body of label node
  • Method Details

    • isTerminal

      public boolean isTerminal()
      Description copied from class: Statement
      Is this a terminal statement, i.e. does it end control flow like a throw or return?
      Specified by:
      isTerminal in interface Terminal
      Overrides:
      isTerminal in class Statement
      Returns:
      true if this node statement is terminal
    • accept

      public Node accept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor)
      Description copied from interface: LexicalContextNode
      Accept function for the node given a lexical context. It must be prepared to replace itself if present in the lexical context
      Parameters:
      lc - lexical context
      visitor - node visitor
      Returns:
      new node or same node depending on state change
    • accept

      public <R> R accept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext, R> visitor)
    • toString

      public void toString(StringBuilder sb, boolean printType)
      Description copied from class: Node
      Print logic that decides whether to show the optimistic type or not - for example it should not be printed after just parse, when it hasn't been computed, or has been set to a trivially provable value
      Specified by:
      toString in class Node
      Parameters:
      sb - string builder
      printType - print type?
    • getBody

      public Block getBody()
      Get the body of the node
      Returns:
      the body
    • setBody

      public LabelNode setBody(LexicalContext lc, Block body)
      Reset the body of the node
      Parameters:
      lc - lexical context
      body - new body
      Returns:
      new for node if changed or existing if not
    • getLabelName

      public String getLabelName()
      Get the label name
      Returns:
      the label
    • accept

      public final Node accept(NodeVisitor<? extends LexicalContext> visitor)
      Description copied from class: Node
      Provides a means to navigate the IR.
      Specified by:
      accept in interface LexicalContextNode
      Specified by:
      accept in class Node
      Parameters:
      visitor - Node visitor.
      Returns:
      node the node or its replacement after visitation, null if no further visitations are required
    • accept

      public final <R> R accept(TranslatorNodeVisitor<? extends LexicalContext, R> visitor)
      Description copied from class: Node
      Provides a means to navigate the IR.
      Specified by:
      accept in interface LexicalContextNode
      Specified by:
      accept in class Node
      Parameters:
      visitor - Node visitor.
      Returns:
      node the node or its replacement after visitation, null if no further visitations are required