| OLD | NEW |
| 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 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2708 String labelName = node.target.source.slowToString(); | 2708 String labelName = node.target.source.slowToString(); |
| 2709 LabelElement label = statementScope.lookupLabel(labelName); | 2709 LabelElement label = statementScope.lookupLabel(labelName); |
| 2710 if (label == null) { | 2710 if (label == null) { |
| 2711 error(node.target, MessageKind.UNBOUND_LABEL, {'labelName': labelName}); | 2711 error(node.target, MessageKind.UNBOUND_LABEL, {'labelName': labelName}); |
| 2712 return; | 2712 return; |
| 2713 } | 2713 } |
| 2714 target = label.target; | 2714 target = label.target; |
| 2715 if (!target.statement.isValidContinueTarget()) { | 2715 if (!target.statement.isValidContinueTarget()) { |
| 2716 error(node.target, MessageKind.INVALID_CONTINUE); | 2716 error(node.target, MessageKind.INVALID_CONTINUE); |
| 2717 } | 2717 } |
| 2718 // TODO(lrn): Handle continues to switch cases. | |
| 2719 if (target.statement is SwitchCase) { | |
| 2720 unimplemented(node, "continue to switch case"); | |
| 2721 } | |
| 2722 label.setContinueTarget(); | 2718 label.setContinueTarget(); |
| 2723 mapping[node.target] = label; | 2719 mapping[node.target] = label; |
| 2724 } | 2720 } |
| 2725 mapping[node] = target; | 2721 mapping[node] = target; |
| 2726 } | 2722 } |
| 2727 | 2723 |
| 2728 registerImplicitInvocation(SourceString name, int arity) { | 2724 registerImplicitInvocation(SourceString name, int arity) { |
| 2729 Selector selector = new Selector.call(name, null, arity); | 2725 Selector selector = new Selector.call(name, null, arity); |
| 2730 world.registerDynamicInvocation(name, selector); | 2726 world.registerDynamicInvocation(name, selector); |
| 2731 } | 2727 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 // It's only a warning if it shadows another label. | 2887 // It's only a warning if it shadows another label. |
| 2892 existingElement = statementScope.lookupLabel(labelName); | 2888 existingElement = statementScope.lookupLabel(labelName); |
| 2893 if (existingElement != null) { | 2889 if (existingElement != null) { |
| 2894 warning(label, MessageKind.DUPLICATE_LABEL, | 2890 warning(label, MessageKind.DUPLICATE_LABEL, |
| 2895 {'labelName': labelName}); | 2891 {'labelName': labelName}); |
| 2896 warning(existingElement.label, | 2892 warning(existingElement.label, |
| 2897 MessageKind.EXISTING_LABEL, {'labelName': labelName}); | 2893 MessageKind.EXISTING_LABEL, {'labelName': labelName}); |
| 2898 } | 2894 } |
| 2899 } | 2895 } |
| 2900 | 2896 |
| 2901 TargetElement targetElement = | 2897 TargetElement targetElement = getOrCreateTargetElement(switchCase); |
| 2902 new TargetElementX(switchCase, | 2898 LabelElement labelElement = targetElement.addLabel(label, labelName); |
| 2903 statementScope.nestingLevel, | |
| 2904 enclosingElement); | |
| 2905 if (mapping[switchCase] != null) { | |
| 2906 // TODO(ahe): Talk to Lasse about this. | |
| 2907 mapping.remove(switchCase); | |
| 2908 } | |
| 2909 mapping[switchCase] = targetElement; | |
| 2910 | |
| 2911 LabelElement labelElement = | |
| 2912 new LabelElementX(label, labelName, | |
| 2913 targetElement, enclosingElement); | |
| 2914 mapping[label] = labelElement; | 2899 mapping[label] = labelElement; |
| 2915 continueLabels[labelName] = labelElement; | 2900 continueLabels[labelName] = labelElement; |
| 2916 } | 2901 } |
| 2917 cases = cases.tail; | 2902 cases = cases.tail; |
| 2918 // Test that only the last case, if any, is a default case. | 2903 // Test that only the last case, if any, is a default case. |
| 2919 if (switchCase.defaultKeyword != null && !cases.isEmpty) { | 2904 if (switchCase.defaultKeyword != null && !cases.isEmpty) { |
| 2920 error(switchCase, MessageKind.INVALID_CASE_DEFAULT); | 2905 error(switchCase, MessageKind.INVALID_CASE_DEFAULT); |
| 2921 } | 2906 } |
| 2922 } | 2907 } |
| 2923 | 2908 |
| (...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3915 return e; | 3900 return e; |
| 3916 } | 3901 } |
| 3917 | 3902 |
| 3918 /// Assumed to be called by [resolveRedirectingFactory]. | 3903 /// Assumed to be called by [resolveRedirectingFactory]. |
| 3919 Element visitReturn(Return node) { | 3904 Element visitReturn(Return node) { |
| 3920 Node expression = node.expression; | 3905 Node expression = node.expression; |
| 3921 return finishConstructorReference(visit(expression), | 3906 return finishConstructorReference(visit(expression), |
| 3922 expression, expression); | 3907 expression, expression); |
| 3923 } | 3908 } |
| 3924 } | 3909 } |
| OLD | NEW |