Class CaseNode

java.lang.Object
com.oracle.js.parser.ir.Node
com.oracle.js.parser.ir.CaseNode
All Implemented Interfaces:
Terminal, Cloneable

public final class CaseNode extends Node implements Terminal
IR representation of case clause. Case nodes are not BreakableNodes, but the SwitchNode is.
  • Field Details

    • statements

      protected final List<Statement> statements
      Statements.
  • Constructor Details

    • CaseNode

      public CaseNode(long token, int finish, Expression test, List<Statement> statements)
      Constructors
      Parameters:
      token - token
      finish - finish
      test - case test node, can be any node in JavaScript
      statements - case body statements
  • Method Details

    • accept

      public Node accept(NodeVisitor<? extends LexicalContext> visitor)
      Assist in IR navigation.
      Specified by:
      accept in class Node
      Parameters:
      visitor - IR navigating 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?
    • isTerminal

      public boolean isTerminal()
      Description copied from interface: Terminal
      Returns true if this AST node is (or contains) a statement that terminates function control flow.
      Specified by:
      isTerminal in interface Terminal
    • getStatements

      public List<Statement> getStatements()
      Get the body for this case node
      Returns:
      the body
    • getTest

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

      public CaseNode setTest(Expression test)
      Reset the test expression for this case node
      Parameters:
      test - new test expression
      Returns:
      new or same CaseNode
    • setStatements

      public CaseNode setStatements(List<Statement> statements)