Class LoopNode
java.lang.Object
com.oracle.js.parser.ir.Node
com.oracle.js.parser.ir.Statement
com.oracle.js.parser.ir.LoopNode
- All Implemented Interfaces:
BreakableNode,LexicalContextNode,Terminal,Cloneable
A loop node, for example a while node, do while node or for node
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BlockLoop bodyprotected final booleanCan control flow escape from loop, e.g.protected final JoinPredecessorExpressionLoop test node, null if infinite -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLoopNode(int lineNumber, long token, int finish, Block body, JoinPredecessorExpression test, boolean controlFlowEscapes) ConstructorprotectedLoopNode(LoopNode loopNode, JoinPredecessorExpression test, Block body, boolean controlFlowEscapes) Constructor -
Method Summary
Modifier and TypeMethodDescriptionfinal Nodeaccept(NodeVisitor<? extends LexicalContext> visitor) Provides a means to navigate the IR.final <R> Raccept(TranslatorNodeVisitor<? extends LexicalContext, R> visitor) Provides a means to navigate the IR.abstract BlockgetBody()Get the body for this for nodegetTest()Get the test for this for nodeabstract booleanDoes this loop have a LET declaration and hence require a per-iteration scope?booleanCheck whether this can be broken out from without using a label, e.g.booleanbooleanisLoop()Is this a loop node?booleanIs this a terminal statement, i.e.abstract booleanConservative check: does this loop have to be entered?abstract LoopNodesetBody(LexicalContext lc, Block body) abstract LoopNodesetControlFlowEscapes(LexicalContext lc, boolean controlFlowEscapes) Set the control flow escapes flag for this node.abstract LoopNodesetTest(LexicalContext lc, JoinPredecessorExpression test) Set the test for this for nodeMethods inherited from class com.oracle.js.parser.ir.Statement
getLineNumber, hasGoto, hasTerminalFlagsMethods inherited from class com.oracle.js.parser.ir.Node
clone, equals, getFinish, getSourceOrder, getStart, getToken, hashCode, isAssignment, isTokenType, tokenType, toString, toString, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.oracle.js.parser.ir.LexicalContextNode
accept, accept, accept, accept
-
Field Details
-
test
Loop test node, null if infinite -
body
Loop body -
controlFlowEscapes
protected final boolean controlFlowEscapesCan 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- lineNumbertoken- tokenfinish- finishbody- loop bodytest- testcontrolFlowEscapes- controlFlowEscapes
-
LoopNode
protected LoopNode(LoopNode loopNode, JoinPredecessorExpression test, Block body, boolean controlFlowEscapes) Constructor- Parameters:
loopNode- loop nodetest- new testbody- new bodycontrolFlowEscapes- controlFlowEscapes
-
-
Method Details
-
isTerminal
public boolean isTerminal()Description copied from class:StatementIs this a terminal statement, i.e. does it end control flow like a throw or return?- Specified by:
isTerminalin interfaceTerminal- Overrides:
isTerminalin classStatement- 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
-
getBody
-
setBody
- Parameters:
lc- lexical contextbody- new body- Returns:
- new for node if changed or existing if not
-
getTest
-
setTest
Set the test for this for node- Parameters:
lc- lexical contexttest- new test- Returns:
- same or new node depending on if test was changed
-
setControlFlowEscapes
Set the control flow escapes flag for this node.- Parameters:
lc- lexical contextcontrolFlowEscapes- 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:
isCompletionValueNeverEmptyin classStatement- 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:
isBreakableWithoutLabelin interfaceBreakableNode- Returns:
- true if breakable without label
-
accept
Description copied from class:NodeProvides a means to navigate the IR.- Specified by:
acceptin interfaceLexicalContextNode- Specified by:
acceptin classNode- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-
accept
Description copied from class:NodeProvides a means to navigate the IR.- Specified by:
acceptin interfaceLexicalContextNode- Specified by:
acceptin classNode- Parameters:
visitor- Node visitor.- Returns:
- node the node or its replacement after visitation, null if no further visitations are required
-