| Index: lib/compiler/implementation/resolver.dart
|
| diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
|
| index 338148d6de278863f03f569c4f2868a603ce58f1..82234e68d905e67a1e928bb5d4d4970a4baa668a 100644
|
| --- a/lib/compiler/implementation/resolver.dart
|
| +++ b/lib/compiler/implementation/resolver.dart
|
| @@ -1213,6 +1213,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| if (!target.statement.isValidContinueTarget()) {
|
| 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 +1241,10 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| }
|
| }
|
|
|
| + visitLabel(Label node) {
|
| + // Labels are handled by their containing statements/cases.
|
| + }
|
| +
|
| visitLabeledStatement(LabeledStatement node) {
|
| String labelName = node.label.slowToString();
|
| LabelElement existingElement = statementScope.lookupLabel(labelName);
|
| @@ -1283,8 +1291,9 @@ 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 (Node labelOrCase in switchCase.labelsAndCases) {
|
| + if (labelOrCase is! Label) continue;
|
| + Label label = labelOrCase;
|
| String labelName = label.slowToString();
|
|
|
| LabelElement existingElement = continueLabels[labelName];
|
| @@ -1315,19 +1324,21 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| continueLabels[labelName] = labelElement;
|
| }
|
| cases = cases.tail;
|
| + // Test that only the last case, if any, is a default case.
|
| if (switchCase.defaultKeyword !== null && !cases.isEmpty()) {
|
| error(switchCase, MessageKind.INVALID_CASE_DEFAULT);
|
| }
|
| }
|
| +
|
| statementScope.enterSwitch(breakElement, continueLabels);
|
| 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;
|
| if (!label.isContinueTarget) {
|
| + TargetElement targetElement = label.target;
|
| + SwitchCase switchCase = targetElement.statement;
|
| mapping.remove(switchCase);
|
| mapping.remove(label.label);
|
| }
|
| @@ -1335,11 +1346,14 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
|
| }
|
|
|
| visitSwitchCase(SwitchCase node) {
|
| - // The label was handled in [visitSwitchStatement(SwitchStatement)].
|
| - node.expressions.accept(this);
|
| + node.labelsAndCases.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) {
|
|
|