Class LoopNode

All Implemented Interfaces:
BreakableNode, LexicalContextNode, Terminal, Cloneable
Direct Known Subclasses:
ForNode, WhileNode

public abstract class LoopNode extends Statement
A loop node, for example a while node, do while node or for node
  • Field Details

    • test

      protected final JoinPredecessorExpression test
      Loop test node, null if infinite
    • body

      protected final Block body
      Loop body
    • controlFlowEscapes

      protected final boolean controlFlowEscapes
      Can control flow escape from loop, e.g. through breaks or continues to outer loops?
  • Constructor Details

    • LoopNode

      protected LoopNode(int lineNumber, long token, int finish, Block body, JoinPredecessorExpression test, boolean controlFlowEscapes)
      Constructor
      Parameters:
      lineNumber - lineNumber
      token - token
      finish - finish
      body - loop body
      test - test
      controlFlowEscapes - controlFlowEscapes
    • LoopNode

      protected LoopNode(LoopNode loopNode, JoinPredecessorExpression test, Block body, boolean controlFlowEscapes)
      Constructor
      Parameters:
      loopNode - loop node
      test - new test
      body - new body
      controlFlowEscapes - controlFlowEscapes
  • 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
    • mustEnter

      public abstract boolean mustEnter()
      Conservative check: does this loop have to be entered?
      Returns:
      true if body will execute at least once
    • isLoop

      public boolean isLoop()
      Description copied from class: Node
      Is this a loop node?
      Overrides:
      isLoop in class Node
      Returns:
      true if atom
    • getBody

      public abstract Block getBody()
      Get the body for this for node
      Returns:
      the body
    • setBody

      public abstract LoopNode setBody(LexicalContext lc, Block body)
      Parameters:
      lc - lexical context
      body - new body
      Returns:
      new for node if changed or existing if not
    • getTest

      public final JoinPredecessorExpression getTest()
      Get the test for this for node
      Returns:
      the test
    • setTest

      public abstract LoopNode setTest(LexicalContext lc, JoinPredecessorExpression test)
      Set the test for this for node
      Parameters:
      lc - lexical context
      test - new test
      Returns:
      same or new node depending on if test was changed
    • setControlFlowEscapes

      public abstract LoopNode setControlFlowEscapes(LexicalContext lc, boolean controlFlowEscapes)
      Set the control flow escapes flag for this node.
      Parameters:
      lc - lexical context
      controlFlowEscapes - control flow escapes value
      Returns:
      new loop node if changed otherwise the same
    • hasPerIterationScope

      public abstract boolean hasPerIterationScope()
      Does this loop have a LET declaration and hence require a per-iteration scope?
      Returns:
      true if a per-iteration scope is required.
    • isCompletionValueNeverEmpty

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

      public boolean isBreakableWithoutLabel()
      Check whether this can be broken out from without using a label, e.g. everything but Blocks, basically
      Specified by:
      isBreakableWithoutLabel in interface BreakableNode
      Returns:
      true if breakable without label
    • 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