Chromium Code Reviews| Index: lib/compiler/implementation/tree/nodes.dart |
| diff --git a/lib/compiler/implementation/tree/nodes.dart b/lib/compiler/implementation/tree/nodes.dart |
| index 83280ae94b478c564d090dced20f07ce02ff5351..e3e295d2d7ef0541c057abbcd4205cfadda6db3e 100644 |
| --- a/lib/compiler/implementation/tree/nodes.dart |
| +++ b/lib/compiler/implementation/tree/nodes.dart |
| @@ -20,6 +20,7 @@ interface Visitor<R> { |
| R visitFunctionExpression(FunctionExpression node); |
| R visitIdentifier(Identifier node); |
| R visitIf(If node); |
| + R visitLabel(Label node); |
| R visitLabeledStatement(LabeledStatement node); |
| R visitLiteralBool(LiteralBool node); |
| R visitLiteralDouble(LiteralDouble node); |
| @@ -126,6 +127,7 @@ class Node implements Hashable { |
| FunctionExpression asFunctionExpression() => null; |
| Identifier asIdentifier() => null; |
| If asIf() => null; |
| + Label asLabel() => null; |
| LabeledStatement asLabeledStatement() => null; |
| LiteralBool asLiteralBool() => null; |
| LiteralDouble asLiteralDouble() => null; |
| @@ -1326,7 +1328,7 @@ class SwitchCase extends Node { |
| // The 'case' keywords can be obtained using [caseKeywords()]. |
| // Any actual switch case must have at least one 'case' or 'default' |
| // clause. |
| - final Identifier label; |
| + final Label label; |
| final NodeList expressions; |
| final Token defaultKeyword; |
| final NodeList statements; |
| @@ -1449,12 +1451,31 @@ class ForIn extends Loop { |
| Token getEndToken() => body.getEndToken(); |
| } |
| -class LabeledStatement extends Statement { |
| - final Identifier label; |
| +class Label extends Node { |
| + final Identifier identifier; |
| final Token colonToken; |
| + |
| + Label(this.identifier, this.colonToken); |
| + |
| + String get name() => identifier.source.slowToString(); |
|
ahe
2012/05/10 11:52:30
I don't like that you hide that you call slowToStr
Lasse Reichstein Nielsen
2012/05/10 12:14:20
Let's rename it to slowToString too.
|
| + |
| + Label asLabel() => this; |
| + |
| + accept(Visitor visitor) => visitor.visitLabel(this); |
| + |
| + void visitChildren(Visitor visitor) { |
| + identifier.accept(visitor); |
| + } |
| + |
| + Token getBeginToken() => identifier.token; |
| + Token getEndToken() => colonToken; |
| +} |
| + |
| +class LabeledStatement extends Statement { |
| + final Label label; |
| final Statement statement; |
| - LabeledStatement(this.label, this.colonToken, this.statement); |
| + LabeledStatement(this.label, this.statement); |
| LabeledStatement asLabeledStatement() => this; |