Class ForNode
java.lang.Object
com.oracle.js.parser.ir.Node
com.oracle.js.parser.ir.Statement
com.oracle.js.parser.ir.LoopNode
com.oracle.js.parser.ir.ForNode
- All Implemented Interfaces:
BreakableNode, LexicalContextNode, Terminal, Cloneable
IR representing a FOR statement.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIs this a for await of loop?static final intIs this a normal for each in loop?static final intIs this a normal for in loop?static final intIs this a for of loop?static final intDoes this loop need a per-iteration scope because its init contain a LET declaration?Fields inherited from class LoopNode
body, controlFlowEscapes, test -
Constructor Summary
ConstructorsConstructorDescriptionForNode(int lineNumber, long token, int finish, Block body, int flags, Expression init, JoinPredecessorExpression test, JoinPredecessorExpression modify) Constructor -
Method Summary
Modifier and TypeMethodDescriptionaccept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor) Accept function for the node given a lexical context.<R> Raccept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext, R> visitor) final 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.getBody()Get the body for this for nodegetInit()Get the initialization expression for this for loopIf this is a for in or for each construct, there is an iterator symbolGet the modification expression for this ForNodebooleanhasGoto()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.booleanIs this an ECMAScript 8 for-await-of construct.booleanIs this a (non-standard) for each construct, known from e.g.booleanisForIn()Is this a for in construct rather than a standard init;condition;modification onebooleanIs this a for-in, for-of, or for-await-of statement?booleanisForOf()Is this an ECMAScript 6 for of construct.booleanConservative check: does this loop have to be entered?setBody(LexicalContext lc, Block body) setControlFlowEscapes(LexicalContext lc, boolean controlFlowEscapes) Set the control flow escapes flag for this node.setInit(LexicalContext lc, Expression init) Reset the initialization expression for this for loopvoidsetIterator(Symbol iterator) Assign an iterator symbol to this ForNode.setModify(LexicalContext lc, JoinPredecessorExpression modify) Reset the modification expression for this ForNodesetTest(LexicalContext lc, JoinPredecessorExpression test) Set the test for this for nodevoidtoString(StringBuilder sb, boolean printTypes) 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 valueMethods inherited from class LoopNode
getTest, isCompletionValueNeverEmpty, isLoop, isTerminalMethods inherited from class Statement
getLineNumber, hasTerminalFlagsMethods inherited from class Node
clone, equals, getFinish, getSourceOrder, getStart, getToken, hashCode, isAssignment, isTokenType, tokenType, toString, toStringMethods inherited from interface LexicalContextNode
accept, accept
-
Field Details
-
IS_FOR_IN
public static final int IS_FOR_INIs this a normal for in loop?- See Also:
-
IS_FOR_EACH
public static final int IS_FOR_EACHIs this a normal for each in loop?- See Also:
-
PER_ITERATION_SCOPE
public static final int PER_ITERATION_SCOPEDoes this loop need a per-iteration scope because its init contain a LET declaration?- See Also:
-
IS_FOR_OF
public static final int IS_FOR_OFIs this a for of loop?- See Also:
-
IS_FOR_AWAIT_OF
public static final int IS_FOR_AWAIT_OFIs this a for await of loop?- See Also:
-
-
Constructor Details
-
ForNode
public ForNode(int lineNumber, long token, int finish, Block body, int flags, Expression init, JoinPredecessorExpression test, JoinPredecessorExpression modify) Constructor- Parameters:
lineNumber- The line number of headertoken- The for tokenfinish- The last character of the for nodebody- The body of the for nodeflags- The flagsinit- The initial expressiontest- The test expressionmodify- The modify expression
-
-
Method Details
-
accept
Description copied from interface:LexicalContextNodeAccept function for the node given a lexical context. It must be prepared to replace itself if present in the lexical context- Parameters:
lc- lexical contextvisitor- node visitor- Returns:
- new node or same node depending on state change
-
accept
-
toString
Description copied from class:NodePrint 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 -
hasGoto
-
mustEnter
-
getInit
Get the initialization expression for this for loop- Returns:
- the initialization expression
-
setInit
Reset the initialization expression for this for loop- Parameters:
lc- lexical contextinit- new initialization expression- Returns:
- new for node if changed or existing if not
-
isForIn
public boolean isForIn()Is this a for in construct rather than a standard init;condition;modification one- Returns:
- true if this is a for in construct
-
isForEach
public boolean isForEach()Is this a (non-standard) for each construct, known from e.g. Rhino.- Returns:
- true if this is a for each construct
-
isForOf
public boolean isForOf()Is this an ECMAScript 6 for of construct.- Returns:
- true if this is a for of construct
-
isForAwaitOf
public boolean isForAwaitOf()Is this an ECMAScript 8 for-await-of construct.- Returns:
- true if this is a for-await-of construct
-
isForInOrOf
public boolean isForInOrOf()Is this a for-in, for-of, or for-await-of statement?- Returns:
- true if this is a for-in, for-of, or for-await-of loop
-
getIterator
If this is a for in or for each construct, there is an iterator symbol- Returns:
- the symbol for the iterator to be used, or null if none exists
-
setIterator
Assign an iterator symbol to this ForNode. Used for for in and for each constructs- Parameters:
iterator- the iterator symbol
-
getModify
Get the modification expression for this ForNode- Returns:
- the modification expression
-
setModify
Reset the modification expression for this ForNode- Parameters:
lc- lexical contextmodify- new modification expression- Returns:
- new for node if changed or existing if not
-
setTest
Description copied from class:LoopNodeSet the test for this for node -
getBody
-
setBody
-
setControlFlowEscapes
Description copied from class:LoopNodeSet the control flow escapes flag for this node.- Specified by:
setControlFlowEscapesin classLoopNode- Parameters:
lc- lexical contextcontrolFlowEscapes- control flow escapes value- Returns:
- new loop node if changed otherwise the same
-
hasPerIterationScope
public boolean hasPerIterationScope()Description copied from class:LoopNodeDoes this loop have a LET declaration and hence require a per-iteration scope?- Specified by:
hasPerIterationScopein classLoopNode- 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:
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
-