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

Side by Side Diff: lib/compiler/implementation/resolver.dart

Issue 10001008: Many type fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 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 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 useElement(node.send, constructor); 987 useElement(node.send, constructor);
988 return null; 988 return null;
989 } 989 }
990 990
991 FunctionElement resolveConstructor(NewExpression node) { 991 FunctionElement resolveConstructor(NewExpression node) {
992 FunctionElement constructor = 992 FunctionElement constructor =
993 node.accept(new ConstructorResolver(compiler, this)); 993 node.accept(new ConstructorResolver(compiler, this));
994 if (constructor === null) { 994 if (constructor === null) {
995 Element resolved = resolveTypeRequired(node.send.selector); 995 Element resolved = resolveTypeRequired(node.send.selector);
996 if (resolved !== null && resolved.kind === ElementKind.TYPE_VARIABLE) { 996 if (resolved !== null && resolved.kind === ElementKind.TYPE_VARIABLE) {
997 error(node, WarningKind.TYPE_VARIABLE_AS_CONSTRUCTOR); 997 error(node, MessageKind.TYPE_VARIABLE_AS_CONSTRUCTOR);
998 return null; 998 return null;
999 } else { 999 } else {
1000 error(node.send, MessageKind.CANNOT_FIND_CONSTRUCTOR, [node.send]); 1000 error(node.send, MessageKind.CANNOT_FIND_CONSTRUCTOR, [node.send]);
1001 } 1001 }
1002 } 1002 }
1003 return constructor; 1003 return constructor;
1004 } 1004 }
1005 1005
1006 Element resolveTypeRequired(Node node) { 1006 Element resolveTypeRequired(Node node) {
1007 bool old = typeRequired; 1007 bool old = typeRequired;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 } else { 1161 } else {
1162 // It's only a warning if it shadows another label. 1162 // It's only a warning if it shadows another label.
1163 existingElement = statementScope.lookupLabel(labelName); 1163 existingElement = statementScope.lookupLabel(labelName);
1164 if (existingElement !== null) { 1164 if (existingElement !== null) {
1165 warning(labelIdentifier, MessageKind.DUPLICATE_LABEL, [labelName]); 1165 warning(labelIdentifier, MessageKind.DUPLICATE_LABEL, [labelName]);
1166 warning(existingElement.label, 1166 warning(existingElement.label,
1167 MessageKind.EXISTING_LABEL, [labelName]); 1167 MessageKind.EXISTING_LABEL, [labelName]);
1168 } 1168 }
1169 } 1169 }
1170 1170
1171 TargetElement TargetElement = 1171 TargetElement targetElement =
1172 new TargetElement(switchCase, 1172 new TargetElement(switchCase,
1173 statementScope.nestingLevel, 1173 statementScope.nestingLevel,
1174 enclosingElement); 1174 enclosingElement);
1175 mapping[switchCase] = TargetElement; 1175 mapping[switchCase] = targetElement;
1176 1176
1177 LabelElement label = 1177 LabelElement label =
1178 new LabelElement(labelIdentifier, labelName, 1178 new LabelElement(labelIdentifier, labelName,
1179 TargetElement, enclosingElement); 1179 targetElement, enclosingElement);
1180 mapping[labelIdentifier] = label; 1180 mapping[labelIdentifier] = label;
1181 continueLabels[labelName] = label; 1181 continueLabels[labelName] = label;
1182 } 1182 }
1183 cases = cases.tail; 1183 cases = cases.tail;
1184 if (switchCase.defaultKeyword !== null && !cases.isEmpty()) { 1184 if (switchCase.defaultKeyword !== null && !cases.isEmpty()) {
1185 error(switchCase, MessageKind.INVALID_CASE_DEFAULT); 1185 error(switchCase, MessageKind.INVALID_CASE_DEFAULT);
1186 } 1186 }
1187 } 1187 }
1188 statementScope.enterSwitch(breakElement, continueLabels); 1188 statementScope.enterSwitch(breakElement, continueLabels);
1189 node.cases.accept(this); 1189 node.cases.accept(this);
1190 statementScope.exitSwitch(); 1190 statementScope.exitSwitch();
1191 1191
1192 // Clean-up unused labels 1192 // Clean-up unused labels
1193 continueLabels.forEach((String key, LabelElement label) { 1193 continueLabels.forEach((String key, LabelElement label) {
1194 TargetElement TargetElement = label.target; 1194 TargetElement targetElement = label.target;
1195 SwitchCase switchCase = TargetElement.statement; 1195 SwitchCase switchCase = targetElement.statement;
1196 if (!label.isContinueTarget) { 1196 if (!label.isContinueTarget) {
1197 mapping.remove(switchCase); 1197 mapping.remove(switchCase);
1198 mapping.remove(label.label); 1198 mapping.remove(label.label);
1199 } 1199 }
1200 }); 1200 });
1201 } 1201 }
1202 1202
1203 visitSwitchCase(SwitchCase node) { 1203 visitSwitchCase(SwitchCase node) {
1204 // The label was handled in [visitSwitchStatement(SwitchStatement)]. 1204 // The label was handled in [visitSwitchStatement(SwitchStatement)].
1205 node.expressions.accept(this); 1205 node.expressions.accept(this);
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 1794
1795 TopScope(LibraryElement library) : super(null, library); 1795 TopScope(LibraryElement library) : super(null, library);
1796 Element lookup(SourceString name) { 1796 Element lookup(SourceString name) {
1797 return library.find(name); 1797 return library.find(name);
1798 } 1798 }
1799 1799
1800 Element add(Element element) { 1800 Element add(Element element) {
1801 throw "Cannot add an element in the top scope"; 1801 throw "Cannot add an element in the top scope";
1802 } 1802 }
1803 } 1803 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698