Class TryNode

All Implemented Interfaces:
Terminal, Cloneable

public final class TryNode extends Statement
IR representation of a try statement.
  • Constructor Details

    • TryNode

      public TryNode(int lineNumber, long token, int finish, Block body, List<Block> catchBlocks, Block finallyBody)
      Constructor
      Parameters:
      lineNumber - lineNumber
      token - token
      finish - finish
      body - try node body
      catchBlocks - list of catch blocks in order
      finallyBody - body of finally block or null if none
  • 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)
      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 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 for this try block
      Returns:
      body
    • setBody

      public TryNode setBody(Block body)
      Reset the body of this try block
      Parameters:
      body - new body
      Returns:
      new TryNode or same if unchanged
    • getCatches

      public List<CatchNode> getCatches()
      Get the catches for this try block
      Returns:
      a list of catch nodes
    • getCatchBlocks

      public List<Block> getCatchBlocks()
      Get the catch blocks for this try block
      Returns:
      a list of blocks
    • setCatchBlocks

      public TryNode setCatchBlocks(List<Block> catchBlocks)
      Set the catch blocks of this try
      Parameters:
      catchBlocks - list of catch blocks
      Returns:
      new TryNode or same if unchanged
    • getException

      public Symbol getException()
      Get the exception symbol for this try block
      Returns:
      a symbol for the compiler to store the exception in
    • getFinallyBody

      public Block getFinallyBody()
      Get the body of the finally clause for this try
      Returns:
      finally body, or null if no finally
    • setFinallyBody

      public TryNode setFinallyBody(Block finallyBody)
      Set the finally body of this try
      Parameters:
      finallyBody - new finally body
      Returns:
      new TryNode or same if unchanged
    • isCompletionValueNeverEmpty

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