Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Unified Diff: lib/compiler/implementation/tree/nodes.dart

Issue 10392024: Add a "Label" Node around an Identifier that is being used as a label. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressede review comments. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | lib/compiler/implementation/tree/unparser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..73986015e6c8156ccfaaec9cfe26830e75c01f1d 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 slowToString() => identifier.source.slowToString();
+
+ 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;
« no previous file with comments | « lib/compiler/implementation/ssa/builder.dart ('k') | lib/compiler/implementation/tree/unparser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698