aboutsummaryrefslogtreecommitdiff
path: root/src/jdk/nashorn/internal/ir/ContinueNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jdk/nashorn/internal/ir/ContinueNode.java')
-rw-r--r--src/jdk/nashorn/internal/ir/ContinueNode.java47
1 files changed, 21 insertions, 26 deletions
diff --git a/src/jdk/nashorn/internal/ir/ContinueNode.java b/src/jdk/nashorn/internal/ir/ContinueNode.java
index cbc7bff2..c8cc309d 100644
--- a/src/jdk/nashorn/internal/ir/ContinueNode.java
+++ b/src/jdk/nashorn/internal/ir/ContinueNode.java
@@ -25,43 +25,39 @@
package jdk.nashorn.internal.ir;
-import jdk.nashorn.internal.codegen.Label;
+import jdk.nashorn.internal.ir.annotations.Immutable;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
import jdk.nashorn.internal.runtime.Source;
/**
* IR representation for CONTINUE statements.
- *
*/
-public class ContinueNode extends LabeledNode {
+@Immutable
+public class ContinueNode extends Node {
+
+ private IdentNode label;
/**
* Constructor
*
- * @param source the source
- * @param token token
- * @param finish finish
- * @param labelNode the continue label
- * @param targetNode node to continue to
- * @param tryChain surrounding try chain
+ * @param source source code
+ * @param token token
+ * @param finish finish
+ * @param label label for break or null if none
*/
- public ContinueNode(final Source source, final long token, final int finish, final LabelNode labelNode, final Node targetNode, final TryNode tryChain) {
- super(source, token, finish, labelNode, targetNode, tryChain);
- setHasGoto();
- }
-
- private ContinueNode(final ContinueNode continueNode, final CopyState cs) {
- super(continueNode, cs);
+ public ContinueNode(final Source source, final long token, final int finish, final IdentNode label) {
+ super(source, token, finish);
+ this.label = label;
}
@Override
- protected Node copy(final CopyState cs) {
- return new ContinueNode(this, cs);
+ public boolean hasGoto() {
+ return true;
}
@Override
public Node accept(final NodeVisitor visitor) {
- if (visitor.enterContinueNode(this) != null) {
+ if (visitor.enterContinueNode(this)) {
return visitor.leaveContinueNode(this);
}
@@ -69,21 +65,20 @@ public class ContinueNode extends LabeledNode {
}
/**
- * Return the target label of this continue node.
- * @return the target label.
+ * Get the label for this break node
+ * @return label, or null if none
*/
- public Label getTargetLabel() {
- assert targetNode instanceof WhileNode : "continue target must be a while node";
- return ((WhileNode)targetNode).getContinueLabel();
+ public IdentNode getLabel() {
+ return label;
}
@Override
public void toString(final StringBuilder sb) {
sb.append("continue");
- if (labelNode != null) {
+ if (label != null) {
sb.append(' ');
- labelNode.getLabel().toString(sb);
+ label.toString(sb);
}
}
}