diff --git a/src/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.java b/src/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.java index 229dedc5417..b2205d3160b 100644 --- a/src/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.java +++ b/src/com/google/dart/compiler/backend/js/JsRequiresSemiVisitor.java @@ -100,7 +100,7 @@ public class JsRequiresSemiVisitor extends JsVisitor { @Override public boolean visit(JsLabel x, JsContext ctx) { - if (x.getStmt() instanceof JsEmpty) { + if (x.getStatement() instanceof JsEmpty) { needsSemicolon = true; } return false; diff --git a/src/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.java b/src/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.java index 85b1ae6f09c..6476775a129 100644 --- a/src/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.java +++ b/src/com/google/dart/compiler/backend/js/JsToStringGenerationVisitor.java @@ -312,10 +312,10 @@ public class JsToStringGenerationVisitor extends JsVisitor { } private void continueOrBreakLabel(JsContinue x) { - JsNameRef label = x.getLabel(); + String label = x.getLabel(); if (label != null) { space(); - _nameRef(label); + p.print(label); } } @@ -475,8 +475,8 @@ public class JsToStringGenerationVisitor extends JsVisitor { // The init expressions or var decl. // - if (x.getInitExpr() != null) { - accept(x.getInitExpr()); + if (x.getInitExpression() != null) { + accept(x.getInitExpression()); } else if (x.getInitVars() != null) { accept(x.getInitVars()); @@ -495,9 +495,9 @@ public class JsToStringGenerationVisitor extends JsVisitor { // The incr expression. // - if (x.getIncrExpr() != null) { + if (x.getIncrementExpression() != null) { spaceOpt(); - accept(x.getIncrExpr()); + accept(x.getIncrementExpression()); } rightParen(); @@ -619,7 +619,7 @@ public class JsToStringGenerationVisitor extends JsVisitor { nameOf(x); _colon(); spaceOpt(); - accept(x.getStmt()); + accept(x.getStatement()); return false; } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsBreak.java b/src/com/google/dart/compiler/backend/js/ast/JsBreak.java index 3360bcb7b2f..50a23c051e2 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsBreak.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsBreak.java @@ -12,7 +12,7 @@ public final class JsBreak extends JsContinue { super(null); } - public JsBreak(JsNameRef label) { + public JsBreak(String label) { super(label); } @@ -23,11 +23,7 @@ public final class JsBreak extends JsContinue { @Override public void traverse(JsVisitor v, JsContext context) { - if (v.visit(this, context)) { - if (label != null) { - v.accept(label); - } - } + v.visit(this, context); v.endVisit(this, context); } } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsContinue.java b/src/com/google/dart/compiler/backend/js/ast/JsContinue.java index 65e88f25932..dcec38018f7 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsContinue.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsContinue.java @@ -10,28 +10,24 @@ import org.jetbrains.annotations.Nullable; * Represents the JavaScript continue statement. */ public class JsContinue extends JsNodeImpl implements JsStatement { - protected final JsNameRef label; + protected final String label; public JsContinue() { this(null); } - public JsContinue(@Nullable JsNameRef label) { + public JsContinue(@Nullable String label) { super(); this.label = label; } - public JsNameRef getLabel() { + public String getLabel() { return label; } @Override public void traverse(JsVisitor v, JsContext context) { - if (v.visit(this, context)) { - if (label != null) { - v.accept(label); - } - } + v.visit(this, context); v.endVisit(this, context); } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsFor.java b/src/com/google/dart/compiler/backend/js/ast/JsFor.java index 4efb65d93c8..fe6b4ad3ca5 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsFor.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsFor.java @@ -8,7 +8,7 @@ package com.google.dart.compiler.backend.js.ast; * A for statement. If specified at all, the initializer part is * either a declaration of one or more variables, in which case * {@link #getInitVars()} is used, or an expression, in which case - * {@link #getInitExpr()} is used. In the latter case, the comma operator is + * {@link #getInitExpression()} is used. In the latter case, the comma operator is * often used to create a compound expression. *

*

@@ -18,20 +18,20 @@ package com.google.dart.compiler.backend.js.ast; public class JsFor extends JsNodeImpl implements JsStatement { private JsStatement body; private JsExpression condition; - private JsExpression incrExpr; - private JsExpression initExpr; + private JsExpression incrementExpression; + private JsExpression initExpression; private JsVars initVars; - public JsFor(JsVars initVars, JsExpression condition, JsExpression incrementExpr) { + public JsFor(JsVars initVars, JsExpression condition, JsExpression incrementExpression) { this.initVars = initVars; - this.incrExpr = incrementExpr; + this.incrementExpression = incrementExpression; this.condition = condition; - initExpr = null; + initExpression = null; } - public JsFor(JsExpression initExpr, JsExpression condition, JsExpression incrementExpr) { - this.initExpr = initExpr; - this.incrExpr = incrementExpr; + public JsFor(JsExpression initExpression, JsExpression condition, JsExpression incrementExpression) { + this.initExpression = initExpression; + this.incrementExpression = incrementExpression; this.condition = condition; initVars = null; } @@ -44,12 +44,12 @@ public class JsFor extends JsNodeImpl implements JsStatement { return condition; } - public JsExpression getIncrExpr() { - return incrExpr; + public JsExpression getIncrementExpression() { + return incrementExpression; } - public JsExpression getInitExpr() { - return initExpr; + public JsExpression getInitExpression() { + return initExpression; } public JsVars getInitVars() { @@ -63,10 +63,10 @@ public class JsFor extends JsNodeImpl implements JsStatement { @Override public void traverse(JsVisitor v, JsContext context) { if (v.visit(this, context)) { - assert (!(initExpr != null && initVars != null)); + assert (!(initExpression != null && initVars != null)); - if (initExpr != null) { - initExpr = v.accept(initExpr); + if (initExpression != null) { + initExpression = v.accept(initExpression); } else if (initVars != null) { initVars = v.accept(initVars); @@ -76,8 +76,8 @@ public class JsFor extends JsNodeImpl implements JsStatement { condition = v.accept(condition); } - if (incrExpr != null) { - incrExpr = v.accept(incrExpr); + if (incrementExpression != null) { + incrementExpression = v.accept(incrementExpression); } body = v.accept(body); } diff --git a/src/com/google/dart/compiler/backend/js/ast/JsLabel.java b/src/com/google/dart/compiler/backend/js/ast/JsLabel.java index 040434b95b6..3dbe28bc361 100644 --- a/src/com/google/dart/compiler/backend/js/ast/JsLabel.java +++ b/src/com/google/dart/compiler/backend/js/ast/JsLabel.java @@ -10,43 +10,47 @@ import com.google.dart.compiler.common.Symbol; * Represents a JavaScript label statement. */ public class JsLabel extends JsNodeImpl implements JsStatement, HasName { + private final JsName label; - private final JsName label; + private JsStatement statement; - private JsStatement stmt; - - public JsLabel(JsName label) { - this.label = label; - } - - @Override - public JsName getName() { - return label; - } - - @Override - public Symbol getSymbol() { - return label; - } - - public JsStatement getStmt() { - return stmt; - } - - public void setStmt(JsStatement stmt) { - this.stmt = stmt; - } - - @Override - public void traverse(JsVisitor v, JsContext context) { - if (v.visit(this, context)) { - stmt = v.accept(stmt); + public JsLabel(JsName label) { + this.label = label; } - v.endVisit(this, context); - } - @Override - public NodeKind getKind() { - return NodeKind.LABEL; - } + public JsLabel(JsName label, JsStatement statement) { + this.label = label; + this.statement = statement; + } + + @Override + public JsName getName() { + return label; + } + + @Override + public Symbol getSymbol() { + return label; + } + + public JsStatement getStatement() { + return statement; + } + + public void setStatement(JsStatement statement) { + this.statement = statement; + } + + @Override + public void traverse(JsVisitor v, JsContext context) { + if (v.visit(this, context)) { + statement = v.accept(statement); + } + v.endVisit(this, context); + } + + @Override + public NodeKind getKind() { + return NodeKind.LABEL; + } }