Class ReturnNode

All Implemented Interfaces:
Terminal, Cloneable

public class ReturnNode extends Statement
IR representation for return statements.
  • Constructor Details

    • ReturnNode

      public ReturnNode(int lineNumber, long token, int finish, Expression expression)
      Constructor
      Parameters:
      lineNumber - line number
      token - token
      finish - finish
      expression - expression to return
  • 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 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?
    • getExpression

      public Expression getExpression()
      Get the expression this node returns
      Returns:
      return expression, or null if void return
    • setExpression

      public ReturnNode setExpression(Expression expression)
      Reset the expression this node returns
      Parameters:
      expression - new expression, or null if void return
      Returns:
      new or same return node
    • isInTerminalPosition

      public boolean isInTerminalPosition()
    • setInTerminalPosition

      public void setInTerminalPosition(boolean inTerminalPosition)
    • isCompletionValueNeverEmpty

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