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

Side by Side Diff: dart/frog/leg/resolver.dart

Issue 9663047: Repeated prefixes and parser fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 Identifier prefix = node.receiver.asIdentifier(); 1156 Identifier prefix = node.receiver.asIdentifier();
1157 if (prefix === null) { 1157 if (prefix === null) {
1158 error(node.receiver, MessageKind.NOT_A_PREFIX, [node.receiver]); 1158 error(node.receiver, MessageKind.NOT_A_PREFIX, [node.receiver]);
1159 return null; 1159 return null;
1160 } 1160 }
1161 Element element = context.lookup(prefix.source); 1161 Element element = context.lookup(prefix.source);
1162 if (element === null || element.kind !== ElementKind.PREFIX) { 1162 if (element === null || element.kind !== ElementKind.PREFIX) {
1163 error(node.receiver, MessageKind.NOT_A_PREFIX, [node.receiver]); 1163 error(node.receiver, MessageKind.NOT_A_PREFIX, [node.receiver]);
1164 return null; 1164 return null;
1165 } 1165 }
1166 var e = element.library.lookupLocalMember(node.selector.source); 1166 var e = element.lookupLocalMember(node.selector.source);
1167 if (e === null || !e.impliesType()) { 1167 if (e === null || !e.impliesType()) {
1168 error(node.selector, MessageKind.CANNOT_RESOLVE_TYPE, [node.selector]); 1168 error(node.selector, MessageKind.CANNOT_RESOLVE_TYPE, [node.selector]);
1169 return null; 1169 return null;
1170 } 1170 }
1171 return e.computeType(compiler); 1171 return e.computeType(compiler);
1172 } 1172 }
1173 1173
1174 Link<Type> getOrCalculateAllSupertypes(ClassElement classElement, 1174 Link<Type> getOrCalculateAllSupertypes(ClassElement classElement,
1175 [Set<ClassElement> seen]) { 1175 [Set<ClassElement> seen]) {
1176 Link<Type> allSupertypes = classElement.allSupertypes; 1176 Link<Type> allSupertypes = classElement.allSupertypes;
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 } 1470 }
1471 SourceString constructorName = 1471 SourceString constructorName =
1472 Elements.constructConstructorName(cls.name, name.source); 1472 Elements.constructConstructorName(cls.name, name.source);
1473 FunctionElement constructor = cls.lookupConstructor(constructorName); 1473 FunctionElement constructor = cls.lookupConstructor(constructorName);
1474 if (constructor === null) { 1474 if (constructor === null) {
1475 error(name, MessageKind.CANNOT_FIND_CONSTRUCTOR, [name]); 1475 error(name, MessageKind.CANNOT_FIND_CONSTRUCTOR, [name]);
1476 } 1476 }
1477 e = constructor; 1477 e = constructor;
1478 } else if (e.kind === ElementKind.PREFIX) { 1478 } else if (e.kind === ElementKind.PREFIX) {
1479 PrefixElement prefix = e; 1479 PrefixElement prefix = e;
1480 e = prefix.library.lookupLocalMember(name.source); 1480 e = prefix.lookupLocalMember(name.source);
1481 if (e === null) { 1481 if (e === null) {
1482 error(name, MessageKind.CANNOT_RESOLVE, [name]); 1482 error(name, MessageKind.CANNOT_RESOLVE, [name]);
1483 // TODO(ahe): Return erroneous element. 1483 // TODO(ahe): Return erroneous element.
1484 } else if (e.kind !== ElementKind.CLASS) { 1484 } else if (e.kind !== ElementKind.CLASS) {
1485 error(node, MessageKind.NOT_A_TYPE, [name]); 1485 error(node, MessageKind.NOT_A_TYPE, [name]);
1486 } 1486 }
1487 } else { 1487 } else {
1488 internalError(node.receiver, 'unexpected element $e'); 1488 internalError(node.receiver, 'unexpected element $e');
1489 } 1489 }
1490 return e; 1490 return e;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 class TopScope extends Scope { 1558 class TopScope extends Scope {
1559 LibraryElement get library() => element; 1559 LibraryElement get library() => element;
1560 1560
1561 TopScope(LibraryElement library) : super(null, library); 1561 TopScope(LibraryElement library) : super(null, library);
1562 Element lookup(SourceString name) => library.find(name); 1562 Element lookup(SourceString name) => library.find(name);
1563 1563
1564 Element add(Element element) { 1564 Element add(Element element) {
1565 throw "Cannot add an element in the top scope"; 1565 throw "Cannot add an element in the top scope";
1566 } 1566 }
1567 } 1567 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698