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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 14969004: Implement continue for switch. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments + status updated. Created 7 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 unified diff | Download patch | Annotate | Revision Log
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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element get currentElement; 8 Element get currentElement;
9 Set<Node> get superUses; 9 Set<Node> get superUses;
10 10
(...skipping 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after
2739 String labelName = node.target.source.slowToString(); 2739 String labelName = node.target.source.slowToString();
2740 LabelElement label = statementScope.lookupLabel(labelName); 2740 LabelElement label = statementScope.lookupLabel(labelName);
2741 if (label == null) { 2741 if (label == null) {
2742 error(node.target, MessageKind.UNBOUND_LABEL, {'labelName': labelName}); 2742 error(node.target, MessageKind.UNBOUND_LABEL, {'labelName': labelName});
2743 return; 2743 return;
2744 } 2744 }
2745 target = label.target; 2745 target = label.target;
2746 if (!target.statement.isValidContinueTarget()) { 2746 if (!target.statement.isValidContinueTarget()) {
2747 error(node.target, MessageKind.INVALID_CONTINUE); 2747 error(node.target, MessageKind.INVALID_CONTINUE);
2748 } 2748 }
2749 // TODO(lrn): Handle continues to switch cases.
2750 if (target.statement is SwitchCase) {
2751 unimplemented(node, "continue to switch case");
2752 }
2753 label.setContinueTarget(); 2749 label.setContinueTarget();
2754 mapping[node.target] = label; 2750 mapping[node.target] = label;
2755 } 2751 }
2756 mapping[node] = target; 2752 mapping[node] = target;
2757 } 2753 }
2758 2754
2759 registerImplicitInvocation(SourceString name, int arity) { 2755 registerImplicitInvocation(SourceString name, int arity) {
2760 Selector selector = new Selector.call(name, null, arity); 2756 Selector selector = new Selector.call(name, null, arity);
2761 world.registerDynamicInvocation(name, selector); 2757 world.registerDynamicInvocation(name, selector);
2762 } 2758 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2922 // It's only a warning if it shadows another label. 2918 // It's only a warning if it shadows another label.
2923 existingElement = statementScope.lookupLabel(labelName); 2919 existingElement = statementScope.lookupLabel(labelName);
2924 if (existingElement != null) { 2920 if (existingElement != null) {
2925 warning(label, MessageKind.DUPLICATE_LABEL, 2921 warning(label, MessageKind.DUPLICATE_LABEL,
2926 {'labelName': labelName}); 2922 {'labelName': labelName});
2927 warning(existingElement.label, 2923 warning(existingElement.label,
2928 MessageKind.EXISTING_LABEL, {'labelName': labelName}); 2924 MessageKind.EXISTING_LABEL, {'labelName': labelName});
2929 } 2925 }
2930 } 2926 }
2931 2927
2932 TargetElement targetElement = 2928 TargetElement targetElement = getOrCreateTargetElement(switchCase);
2933 new TargetElementX(switchCase, 2929 LabelElement labelElement = targetElement.addLabel(label, labelName);
2934 statementScope.nestingLevel,
2935 enclosingElement);
2936 if (mapping[switchCase] != null) {
2937 // TODO(ahe): Talk to Lasse about this.
2938 mapping.remove(switchCase);
2939 }
2940 mapping[switchCase] = targetElement;
2941
2942 LabelElement labelElement =
2943 new LabelElementX(label, labelName,
2944 targetElement, enclosingElement);
2945 mapping[label] = labelElement; 2930 mapping[label] = labelElement;
2946 continueLabels[labelName] = labelElement; 2931 continueLabels[labelName] = labelElement;
2947 } 2932 }
2948 cases = cases.tail; 2933 cases = cases.tail;
2949 // Test that only the last case, if any, is a default case. 2934 // Test that only the last case, if any, is a default case.
2950 if (switchCase.defaultKeyword != null && !cases.isEmpty) { 2935 if (switchCase.defaultKeyword != null && !cases.isEmpty) {
2951 error(switchCase, MessageKind.INVALID_CASE_DEFAULT); 2936 error(switchCase, MessageKind.INVALID_CASE_DEFAULT);
2952 } 2937 }
2953 } 2938 }
2954 2939
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
3946 return e; 3931 return e;
3947 } 3932 }
3948 3933
3949 /// Assumed to be called by [resolveRedirectingFactory]. 3934 /// Assumed to be called by [resolveRedirectingFactory].
3950 Element visitReturn(Return node) { 3935 Element visitReturn(Return node) {
3951 Node expression = node.expression; 3936 Node expression = node.expression;
3952 return finishConstructorReference(visit(expression), 3937 return finishConstructorReference(visit(expression),
3953 expression, expression); 3938 expression, expression);
3954 } 3939 }
3955 } 3940 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698