Class WhileNode

All Implemented Interfaces:
BreakableNode, LexicalContextNode, Terminal, Cloneable

public final class WhileNode extends LoopNode
IR representation for a while statement. This is the superclass of all loop nodes
  • Constructor Details

    • WhileNode

      public WhileNode(int lineNumber, long token, int finish, boolean isDoWhile, JoinPredecessorExpression test, Block body)
      Constructor
      Parameters:
      lineNumber - line number
      token - token
      finish - finish
      isDoWhile - is this a do while loop?
      test - test expression
      body - body of the while loop
  • Method Details

    • hasGoto

      public boolean hasGoto()
      Description copied from class: Statement
      Check if this statement repositions control flow with goto like semantics, for example BreakNode or a ForNode with no test
      Overrides:
      hasGoto in class Statement
      Returns:
      true if statement has goto semantics
    • accept

      public Node accept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor)
      Description copied from interface: LexicalContextNode
      Accept function for the node given a lexical context. It must be prepared to replace itself if present in the lexical context
      Parameters:
      lc - lexical context
      visitor - node visitor
      Returns:
      new node or same node depending on state change
    • accept

      public <R> R accept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext, R> visitor)
    • setTest

      Description copied from class: LoopNode
      Set the test for this for node
      Specified by:
      setTest in class LoopNode
      Parameters:
      lc - lexical context
      test - new test
      Returns:
      same or new node depending on if test was changed
    • getBody

      public Block getBody()
      Description copied from class: LoopNode
      Get the body for this for node
      Specified by:
      getBody in class LoopNode
      Returns:
      the body
    • setBody

      public WhileNode setBody(LexicalContext lc, Block body)
      Specified by:
      setBody in class LoopNode
      Parameters:
      lc - lexical context
      body - new body
      Returns:
      new for node if changed or existing if not
    • setControlFlowEscapes

      public WhileNode setControlFlowEscapes(LexicalContext lc, boolean controlFlowEscapes)
      Description copied from class: LoopNode
      Set the control flow escapes flag for this node.
      Specified by:
      setControlFlowEscapes in class LoopNode
      Parameters:
      lc - lexical context
      controlFlowEscapes - control flow escapes value
      Returns:
      new loop node if changed otherwise the same
    • isDoWhile

      public boolean isDoWhile()
      Check if this is a do while loop or a normal while loop
      Returns:
      true if do while
    • 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?
    • mustEnter

      public boolean mustEnter()
      Description copied from class: LoopNode
      Conservative check: does this loop have to be entered?
      Specified by:
      mustEnter in class LoopNode
      Returns:
      true if body will execute at least once
    • hasPerIterationScope

      public boolean hasPerIterationScope()
      Description copied from class: LoopNode
      Does this loop have a LET declaration and hence require a per-iteration scope?
      Specified by:
      hasPerIterationScope in class LoopNode
      Returns:
      true if a per-iteration scope is required.
    • 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