KT-2986
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ package com.google.dart.compiler.backend.js.ast;
|
||||
* A <code>for</code> 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.
|
||||
* <p/>
|
||||
* <p/>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user