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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 10387080: Accept more labels per switch case. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 338148d6de278863f03f569c4f2868a603ce58f1..bc2b393dcee39b02cf21dd4ddc459982c669bff4 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1211,8 +1211,13 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
target = label.target;
if (!target.statement.isValidContinueTarget()) {
+ print(target);
karlklose 2012/05/11 09:29:31 Remove debug code.
Lasse Reichstein Nielsen 2012/05/11 14:17:09 Done.
error(node.target, MessageKind.INVALID_CONTINUE, [labelName]);
}
+ // TODO(lrn): Handle continues to switch cases.
+ if (target.statement is SwitchCase) {
+ unimplemented(node, "continue to switch case");
+ }
label.setContinueTarget();
mapping[node.target] = label;
}
@@ -1237,6 +1242,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
}
+ visitLabel(Label node) {
+
karlklose 2012/05/11 09:29:31 Remove empty line.
Lasse Reichstein Nielsen 2012/05/11 14:17:09 Done.
+ }
+
visitLabeledStatement(LabeledStatement node) {
String labelName = node.label.slowToString();
LabelElement existingElement = statementScope.lookupLabel(labelName);
@@ -1283,8 +1292,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
Link<Node> cases = node.cases.nodes;
while (!cases.isEmpty()) {
SwitchCase switchCase = cases.head;
- if (switchCase.label !== null) {
- Label label = switchCase.label;
+ for (Label label in switchCase.labels) {
String labelName = label.slowToString();
LabelElement existingElement = continueLabels[labelName];
@@ -1323,7 +1331,7 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
node.cases.accept(this);
statementScope.exitSwitch();
- // Clean-up unused labels
+ // Clean-up unused labels.
continueLabels.forEach((String key, LabelElement label) {
TargetElement targetElement = label.target;
SwitchCase switchCase = targetElement.statement;
@@ -1335,11 +1343,15 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
}
visitSwitchCase(SwitchCase node) {
- // The label was handled in [visitSwitchStatement(SwitchStatement)].
- node.expressions.accept(this);
+ // The labels were handled in [visitSwitchStatement(SwitchStatement)].
+ node.cases.accept(this);
visitIn(node.statements, new BlockScope(context));
}
+ visitCaseMatch(CaseMatch node) {
+ visit(node.expression);
+ }
+
visitTryStatement(TryStatement node) {
visit(node.tryBlock);
if (node.catchBlocks.isEmpty() && node.finallyBlock == null) {

Powered by Google App Engine
This is Rietveld 408576698