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

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 2682553002: Fix lingering switch statement test failures. (Closed)
Patch Set: associateNode Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.resolution.members; 5 library dart2js.resolution.members;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show Selectors; 8 import '../common/names.dart' show Selectors;
9 import '../common/resolution.dart' show Resolution; 9 import '../common/resolution.dart' show Resolution;
10 import '../compile_time_constants.dart'; 10 import '../compile_time_constants.dart';
(...skipping 4583 matching lines...) Expand 10 before | Expand all | Expand 10 after
4594 if (error != null) { 4594 if (error != null) {
4595 reporter.reportError(error, infos); 4595 reporter.reportError(error, infos);
4596 } 4596 }
4597 } 4597 }
4598 4598
4599 ResolutionResult visitSwitchStatement(SwitchStatement node) { 4599 ResolutionResult visitSwitchStatement(SwitchStatement node) {
4600 node.expression.accept(this); 4600 node.expression.accept(this);
4601 4601
4602 JumpTarget breakElement = getOrDefineTarget(node); 4602 JumpTarget breakElement = getOrDefineTarget(node);
4603 Map<String, LabelDefinition> continueLabels = <String, LabelDefinition>{}; 4603 Map<String, LabelDefinition> continueLabels = <String, LabelDefinition>{};
4604 Set<SwitchCase> switchCasesWithContinues = new Set<SwitchCase>();
4604 Link<Node> cases = node.cases.nodes; 4605 Link<Node> cases = node.cases.nodes;
4605 while (!cases.isEmpty) { 4606 while (!cases.isEmpty) {
4606 SwitchCase switchCase = cases.head; 4607 SwitchCase switchCase = cases.head;
4607 for (Node labelOrCase in switchCase.labelsAndCases) { 4608 for (Node labelOrCase in switchCase.labelsAndCases) {
4608 CaseMatch caseMatch = labelOrCase.asCaseMatch(); 4609 CaseMatch caseMatch = labelOrCase.asCaseMatch();
4609 if (caseMatch != null) { 4610 if (caseMatch != null) {
4610 analyzeConstantDeferred(caseMatch.expression); 4611 analyzeConstantDeferred(caseMatch.expression);
4611 continue; 4612 continue;
4612 } 4613 }
4613 Label label = labelOrCase; 4614 Label label = labelOrCase;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
4661 } 4662 }
4662 4663
4663 addDeferredAction(enclosingElement, () { 4664 addDeferredAction(enclosingElement, () {
4664 checkCaseExpressions(node); 4665 checkCaseExpressions(node);
4665 }); 4666 });
4666 4667
4667 statementScope.enterSwitch(breakElement, continueLabels); 4668 statementScope.enterSwitch(breakElement, continueLabels);
4668 node.cases.accept(this); 4669 node.cases.accept(this);
4669 statementScope.exitSwitch(); 4670 statementScope.exitSwitch();
4670 4671
4672 continueLabels.forEach((String key, LabelDefinition label) {
4673 if (label.isContinueTarget) {
4674 JumpTarget targetElement = label.target;
4675 SwitchCase switchCase = targetElement.statement;
4676 switchCasesWithContinues.add(switchCase);
4677 }
4678 });
4679
4671 // Clean-up unused labels. 4680 // Clean-up unused labels.
4672 continueLabels.forEach((String key, LabelDefinition label) { 4681 continueLabels.forEach((String key, LabelDefinition label) {
4673 if (!label.isContinueTarget) { 4682 if (!label.isContinueTarget) {
4674 JumpTarget targetElement = label.target; 4683 JumpTarget targetElement = label.target;
4675 SwitchCase switchCase = targetElement.statement; 4684 SwitchCase switchCase = targetElement.statement;
4676 registry.undefineTarget(switchCase); 4685 if (!switchCasesWithContinues.contains(switchCase)) {
4686 registry.undefineTarget(switchCase);
4687 }
4677 registry.undefineLabel(label.label); 4688 registry.undefineLabel(label.label);
4678 } 4689 }
4679 }); 4690 });
4680 // TODO(15575): We should warn if we can detect a fall through 4691 // TODO(15575): We should warn if we can detect a fall through
4681 // error. 4692 // error.
4682 return const NoneResult(); 4693 return const NoneResult();
4683 } 4694 }
4684 4695
4685 ResolutionResult visitSwitchCase(SwitchCase node) { 4696 ResolutionResult visitSwitchCase(SwitchCase node) {
4686 node.labelsAndCases.accept(this); 4697 node.labelsAndCases.accept(this);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
4791 } 4802 }
4792 return const NoneResult(); 4803 return const NoneResult();
4793 } 4804 }
4794 } 4805 }
4795 4806
4796 /// Looks up [name] in [scope] and unwraps the result. 4807 /// Looks up [name] in [scope] and unwraps the result.
4797 Element lookupInScope( 4808 Element lookupInScope(
4798 DiagnosticReporter reporter, Node node, Scope scope, String name) { 4809 DiagnosticReporter reporter, Node node, Scope scope, String name) {
4799 return Elements.unwrap(scope.lookup(name), reporter, node); 4810 return Elements.unwrap(scope.lookup(name), reporter, node);
4800 } 4811 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/kernel_visitor.dart ('k') | pkg/compiler/lib/src/ssa/builder_kernel.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698