Class ExpressionStatement

All Implemented Interfaces:
Terminal, Cloneable

public final class ExpressionStatement extends Statement
IR representation for executing bare expressions. Basically, an expression node means "this code will be executed" and evaluating it results in statements being added to the IR
  • Constructor Details

    • ExpressionStatement

      public ExpressionStatement(int lineNumber, long token, int finish, Expression expression)
      Constructor
      Parameters:
      lineNumber - line number
      token - token
      finish - finish
      expression - the expression to execute
  • Method Details

    • 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?
    • getExpression

      public Expression getExpression()
      Return the expression to be executed
      Returns:
      the expression
    • setExpression

      public ExpressionStatement setExpression(Expression expression)
      Reset the expression to be executed
      Parameters:
      expression - the expression
      Returns:
      new or same execute node
    • isCompletionValueNeverEmpty

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