Class IfNode

All Implemented Interfaces:
Terminal, Cloneable

public final class IfNode extends Statement
IR representation for an IF statement.
  • Constructor Details

    • IfNode

      public IfNode(int lineNumber, long token, int finish, Expression test, Block pass, Block fail)
      Constructor
      Parameters:
      lineNumber - line number
      token - token
      finish - finish
      test - test
      pass - block to execute when test passes
      fail - block to execute when test fails or null
  • 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(NodeVisitor<? extends LexicalContext> visitor)
      Description copied from class: Node
      Provides a means to navigate the IR.
      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 <R> R accept(TranslatorNodeVisitor<? extends LexicalContext,R> visitor)
      Description copied from class: Node
      Provides a means to navigate the IR.
      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
    • toString

      public void toString(StringBuilder sb, boolean printTypes)
      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
      printTypes - print type?
    • getFail

      public Block getFail()
      Get the else block of this IfNode
      Returns:
      the else block, or null if none exists
    • getPass

      public Block getPass()
      Get the then block for this IfNode
      Returns:
      the then block
    • getTest

      public Expression getTest()
      Get the test expression for this IfNode
      Returns:
      the test expression
    • setTest

      public IfNode setTest(Expression test)
      Reset the test expression for this IfNode
      Parameters:
      test - a new test expression
      Returns:
      new or same IfNode
    • isCompletionValueNeverEmpty

      public boolean isCompletionValueNeverEmpty()
      Overrides:
      isCompletionValueNeverEmpty in class Statement
      Returns:
      true if the completion value of this statement is never the value empty