Class WithNode

All Implemented Interfaces:
LexicalContextNode, Terminal, Cloneable

public final class WithNode extends Statement
IR representation for with statements.
  • Constructor Details

    • WithNode

      public WithNode(int lineNumber, long token, int finish, Expression expression, Block body)
      Constructor
      Parameters:
      lineNumber - Line number of the header
      token - First token
      finish - Character index of the last token
      expression - With expression
      body - Body of with node
  • Method Details

    • accept

      public Node accept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor)
      Assist in IR navigation.
      Parameters:
      lc - lexical context
      visitor - IR navigating visitor.
      Returns:
      new node or same node depending on state change
    • accept

      public <R> R accept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext, R> visitor)
    • 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
    • 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 this WithNode
      Returns:
      the body
    • setBody

      public WithNode setBody(LexicalContext lc, Block body)
      Reset the body of this with node
      Parameters:
      lc - lexical context
      body - new body
      Returns:
      new or same withnode
    • getExpression

      public Expression getExpression()
      Get the expression of this WithNode
      Returns:
      the expression
    • setExpression

      public WithNode setExpression(LexicalContext lc, Expression expression)
      Reset the expression of this with node
      Parameters:
      lc - lexical context
      expression - new expression
      Returns:
      new or same withnode
    • isCompletionValueNeverEmpty

      public boolean isCompletionValueNeverEmpty()
      Overrides:
      isCompletionValueNeverEmpty in class Statement
      Returns:
      true if the completion value of this statement is never the value empty
    • 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