aboutsummaryrefslogtreecommitdiff
path: root/src/jdk/nashorn/internal/ir/WhileNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jdk/nashorn/internal/ir/WhileNode.java')
-rw-r--r--src/jdk/nashorn/internal/ir/WhileNode.java42
1 files changed, 25 insertions, 17 deletions
diff --git a/src/jdk/nashorn/internal/ir/WhileNode.java b/src/jdk/nashorn/internal/ir/WhileNode.java
index 97e7ca54..7e60fee0 100644
--- a/src/jdk/nashorn/internal/ir/WhileNode.java
+++ b/src/jdk/nashorn/internal/ir/WhileNode.java
@@ -34,6 +34,8 @@ import jdk.nashorn.internal.ir.visitor.NodeVisitor;
*/
@Immutable
public final class WhileNode extends LoopNode {
+ private static final long serialVersionUID = 1L;
+
/** is this a do while node ? */
private final boolean isDoWhile;
@@ -47,7 +49,7 @@ public final class WhileNode extends LoopNode {
* @param isDoWhile is this a do while loop?
*/
public WhileNode(final int lineNumber, final long token, final int finish, final boolean isDoWhile) {
- super(lineNumber, token, finish, null, null, false);
+ super(lineNumber, token, finish, null, false);
this.isDoWhile = isDoWhile;
}
@@ -58,15 +60,16 @@ public final class WhileNode extends LoopNode {
* @param test test
* @param body body
* @param controlFlowEscapes control flow escapes?
+ * @param conversion TODO
*/
- protected WhileNode(final WhileNode whileNode, final Expression test, final Block body, final boolean controlFlowEscapes) {
- super(whileNode, test, body, controlFlowEscapes);
+ private WhileNode(final WhileNode whileNode, final JoinPredecessorExpression test, final Block body, final boolean controlFlowEscapes, final LocalVariableConversion conversion) {
+ super(whileNode, test, body, controlFlowEscapes, conversion);
this.isDoWhile = whileNode.isDoWhile;
}
@Override
public Node ensureUniqueLabels(final LexicalContext lc) {
- return Node.replaceInLexicalContext(lc, this, new WhileNode(this, test, body, controlFlowEscapes));
+ return Node.replaceInLexicalContext(lc, this, new WhileNode(this, test, body, controlFlowEscapes, conversion));
}
@Override
@@ -80,26 +83,21 @@ public final class WhileNode extends LoopNode {
if (isDoWhile()) {
return visitor.leaveWhileNode(
setBody(lc, (Block)body.accept(visitor)).
- setTest(lc, (Expression)test.accept(visitor)));
+ setTest(lc, (JoinPredecessorExpression)test.accept(visitor)));
}
return visitor.leaveWhileNode(
- setTest(lc, (Expression)test.accept(visitor)).
+ setTest(lc, (JoinPredecessorExpression)test.accept(visitor)).
setBody(lc, (Block)body.accept(visitor)));
}
return this;
}
@Override
- public Expression getTest() {
- return test;
- }
-
- @Override
- public WhileNode setTest(final LexicalContext lc, final Expression test) {
+ public WhileNode setTest(final LexicalContext lc, final JoinPredecessorExpression test) {
if (this.test == test) {
return this;
}
- return Node.replaceInLexicalContext(lc, this, new WhileNode(this, test, body, controlFlowEscapes));
+ return Node.replaceInLexicalContext(lc, this, new WhileNode(this, test, body, controlFlowEscapes, conversion));
}
@Override
@@ -112,7 +110,7 @@ public final class WhileNode extends LoopNode {
if (this.body == body) {
return this;
}
- return Node.replaceInLexicalContext(lc, this, new WhileNode(this, test, body, controlFlowEscapes));
+ return Node.replaceInLexicalContext(lc, this, new WhileNode(this, test, body, controlFlowEscapes, conversion));
}
@Override
@@ -120,7 +118,12 @@ public final class WhileNode extends LoopNode {
if (this.controlFlowEscapes == controlFlowEscapes) {
return this;
}
- return Node.replaceInLexicalContext(lc, this, new WhileNode(this, test, body, controlFlowEscapes));
+ return Node.replaceInLexicalContext(lc, this, new WhileNode(this, test, body, controlFlowEscapes, conversion));
+ }
+
+ @Override
+ JoinPredecessor setLocalVariableConversionChanged(final LexicalContext lc, final LocalVariableConversion conversion) {
+ return Node.replaceInLexicalContext(lc, this, new WhileNode(this, test, body, controlFlowEscapes, conversion));
}
/**
@@ -132,9 +135,9 @@ public final class WhileNode extends LoopNode {
}
@Override
- public void toString(final StringBuilder sb) {
+ public void toString(final StringBuilder sb, final boolean printType) {
sb.append("while (");
- test.toString(sb);
+ test.toString(sb, printType);
sb.append(')');
}
@@ -145,4 +148,9 @@ public final class WhileNode extends LoopNode {
}
return test == null;
}
+
+ @Override
+ public boolean hasPerIterationScope() {
+ return false;
+ }
}