Chromium Code Reviews| 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 interface TreeElements { | 5 interface TreeElements { |
| 6 Element operator[](Node node); | 6 Element operator[](Node node); |
| 7 Selector getSelector(Send send); | 7 Selector getSelector(Send send); |
| 8 } | 8 } |
| 9 | 9 |
| 10 class TreeElementMapping implements TreeElements { | 10 class TreeElementMapping implements TreeElements { |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 visitLabeledStatement(LabeledStatement node) { | 1084 visitLabeledStatement(LabeledStatement node) { |
| 1085 String labelName = node.label.source.slowToString(); | 1085 String labelName = node.label.source.slowToString(); |
| 1086 LabelElement existingElement = statementScope.lookupLabel(labelName); | 1086 LabelElement existingElement = statementScope.lookupLabel(labelName); |
| 1087 if (existingElement !== null) { | 1087 if (existingElement !== null) { |
| 1088 warning(node.label, MessageKind.DUPLICATE_LABEL, [labelName]); | 1088 warning(node.label, MessageKind.DUPLICATE_LABEL, [labelName]); |
| 1089 warning(existingElement.label, MessageKind.EXISTING_LABEL, [labelName]); | 1089 warning(existingElement.label, MessageKind.EXISTING_LABEL, [labelName]); |
| 1090 } | 1090 } |
| 1091 Node body = node.getBody(); | 1091 Node body = node.getBody(); |
| 1092 TargetElement TargetElement = getOrCreateTargetElement(body); | 1092 TargetElement targetElement = getOrCreateTargetElement(body); |
| 1093 | 1093 |
| 1094 LabelElement element = TargetElement.addLabel(node.label, labelName); | 1094 LabelElement element = targetElement.addLabel(node.label, labelName); |
| 1095 statementScope.enterLabelScope(element); | 1095 statementScope.enterLabelScope(element); |
| 1096 visit(node.statement); | 1096 visit(node.statement); |
| 1097 statementScope.exitLabelScope(); | 1097 statementScope.exitLabelScope(); |
| 1098 if (element.isTarget) { | 1098 if (element.isTarget) { |
| 1099 mapping[node.label] = element; | 1099 mapping[node.label] = element; |
| 1100 } else { | 1100 } else { |
| 1101 warning(node.label, MessageKind.UNUSED_LABEL, [labelName]); | 1101 warning(node.label, MessageKind.UNUSED_LABEL, [labelName]); |
| 1102 } | 1102 } |
| 1103 if (!TargetElement.isBreakTarget && mapping[body] === TargetElement) { | 1103 if (!targetElement.isTarget && mapping[body] === targetElement) { |
| 1104 // If the body is itself a break or continue for another target, it | 1104 // If the body is itself a break or continue for another target, it |
| 1105 // might have updated its mapping to the label it actaully does target. | 1105 // might have updated its mapping to the target it actaully does target. |
|
ngeoffray
2012/03/19 11:42:06
actaully -> actually
Lasse Reichstein Nielsen
2012/03/19 12:13:58
Done.
| |
| 1106 mapping.remove(body); | 1106 mapping.remove(body); |
| 1107 } | 1107 } |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 visitLiteralMap(LiteralMap node) { | 1110 visitLiteralMap(LiteralMap node) { |
| 1111 node.visitChildren(this); | 1111 node.visitChildren(this); |
| 1112 } | 1112 } |
| 1113 | 1113 |
| 1114 visitLiteralMapEntry(LiteralMapEntry node) { | 1114 visitLiteralMapEntry(LiteralMapEntry node) { |
| 1115 node.visitChildren(this); | 1115 node.visitChildren(this); |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1750 | 1750 |
| 1751 TopScope(LibraryElement library) : super(null, library); | 1751 TopScope(LibraryElement library) : super(null, library); |
| 1752 Element lookup(SourceString name) { | 1752 Element lookup(SourceString name) { |
| 1753 return library.find(name); | 1753 return library.find(name); |
| 1754 } | 1754 } |
| 1755 | 1755 |
| 1756 Element add(Element element) { | 1756 Element add(Element element) { |
| 1757 throw "Cannot add an element in the top scope"; | 1757 throw "Cannot add an element in the top scope"; |
| 1758 } | 1758 } |
| 1759 } | 1759 } |
| OLD | NEW |