aboutsummaryrefslogtreecommitdiff
path: root/src/jdk/nashorn/internal/ir/LoopNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jdk/nashorn/internal/ir/LoopNode.java')
-rw-r--r--src/jdk/nashorn/internal/ir/LoopNode.java29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/jdk/nashorn/internal/ir/LoopNode.java b/src/jdk/nashorn/internal/ir/LoopNode.java
index 107030a2..5991a32a 100644
--- a/src/jdk/nashorn/internal/ir/LoopNode.java
+++ b/src/jdk/nashorn/internal/ir/LoopNode.java
@@ -26,6 +26,7 @@
package jdk.nashorn.internal.ir;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import jdk.nashorn.internal.codegen.Label;
@@ -33,11 +34,13 @@ import jdk.nashorn.internal.codegen.Label;
* A loop node, for example a while node, do while node or for node
*/
public abstract class LoopNode extends BreakableStatement {
+ private static final long serialVersionUID = 1L;
+
/** loop continue label. */
protected final Label continueLabel;
/** Loop test node, null if infinite */
- protected final Expression test;
+ protected final JoinPredecessorExpression test;
/** Loop body */
protected final Block body;
@@ -51,14 +54,13 @@ public abstract class LoopNode extends BreakableStatement {
* @param lineNumber lineNumber
* @param token token
* @param finish finish
- * @param test test, or null if infinite loop
* @param body loop body
* @param controlFlowEscapes controlFlowEscapes
*/
- protected LoopNode(final int lineNumber, final long token, final int finish, final Expression test, final Block body, final boolean controlFlowEscapes) {
+ protected LoopNode(final int lineNumber, final long token, final int finish, final Block body, final boolean controlFlowEscapes) {
super(lineNumber, token, finish, new Label("while_break"));
this.continueLabel = new Label("while_continue");
- this.test = test;
+ this.test = null;
this.body = body;
this.controlFlowEscapes = controlFlowEscapes;
}
@@ -70,9 +72,11 @@ public abstract class LoopNode extends BreakableStatement {
* @param test new test
* @param body new body
* @param controlFlowEscapes controlFlowEscapes
+ * @param conversion the local variable conversion carried by this loop node.
*/
- protected LoopNode(final LoopNode loopNode, final Expression test, final Block body, final boolean controlFlowEscapes) {
- super(loopNode);
+ protected LoopNode(final LoopNode loopNode, final JoinPredecessorExpression test, final Block body,
+ final boolean controlFlowEscapes, final LocalVariableConversion conversion) {
+ super(loopNode, conversion);
this.continueLabel = new Label(loopNode.continueLabel);
this.test = test;
this.body = body;
@@ -125,7 +129,7 @@ public abstract class LoopNode extends BreakableStatement {
@Override
public List<Label> getLabels() {
- return Arrays.asList(breakLabel, continueLabel);
+ return Collections.unmodifiableList(Arrays.asList(breakLabel, continueLabel));
}
@Override
@@ -150,7 +154,9 @@ public abstract class LoopNode extends BreakableStatement {
* Get the test for this for node
* @return the test
*/
- public abstract Expression getTest();
+ public final JoinPredecessorExpression getTest() {
+ return test;
+ }
/**
* Set the test for this for node
@@ -159,7 +165,7 @@ public abstract class LoopNode extends BreakableStatement {
* @param test new test
* @return same or new node depending on if test was changed
*/
- public abstract LoopNode setTest(final LexicalContext lc, final Expression test);
+ public abstract LoopNode setTest(final LexicalContext lc, final JoinPredecessorExpression test);
/**
* Set the control flow escapes flag for this node.
@@ -171,4 +177,9 @@ public abstract class LoopNode extends BreakableStatement {
*/
public abstract LoopNode setControlFlowEscapes(final LexicalContext lc, final boolean controlFlowEscapes);
+ /**
+ * Does this loop have a LET declaration and hence require a per-iteration scope?
+ * @return true if a per-iteration scope is required.
+ */
+ public abstract boolean hasPerIterationScope();
}