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

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

Issue 10115026: Address the remaining review comments on http://chromiumcodereview.appspot.com/9431029. (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 Type getType(TypeAnnotation annotation); 8 Type getType(TypeAnnotation annotation);
9 } 9 }
10 10
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 typeArguments = typeArguments.tail) { 1098 typeArguments = typeArguments.tail) {
1099 if (++index > cls.typeParameters.length) { 1099 if (++index > cls.typeParameters.length) {
1100 report(typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); 1100 report(typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
1101 } 1101 }
1102 arguments.addLast(resolveTypeAnnotation(typeArguments.head)); 1102 arguments.addLast(resolveTypeAnnotation(typeArguments.head));
1103 } 1103 }
1104 if (index < cls.typeParameters.length) { 1104 if (index < cls.typeParameters.length) {
1105 report(node.typeArguments, MessageKind.MISSING_TYPE_ARGUMENT); 1105 report(node.typeArguments, MessageKind.MISSING_TYPE_ARGUMENT);
1106 } 1106 }
1107 } 1107 }
1108 type = new InterfaceType(cls.name, cls, arguments.toLink()); 1108 if (cls.typeParameters.length == 0) {
ahe 2012/05/01 17:26:24 && element.something == 0
karlklose 2012/05/02 08:26:50 Not necessary, as discussed.
1109 } else if (element.isTypedef()) { 1109 // Return the canonical type if it has no type parameters.
1110 // TODO(karlklose): implement typedefs. We return a fake type that the 1110 type = element.computeType(compiler);
1111 // code generator can use to detect typedefs in is-checks. 1111 } else {
1112 type = new InterfaceType(element.name, element); 1112 type = new InterfaceType(cls.name, cls, arguments.toLink());
1113 }
1114 } else if (element.isTypedef() || element.isTypeVariable()) {
1115 type = element.computeType(compiler);
1113 } else { 1116 } else {
1114 type = element.computeType(compiler); 1117 compiler.internalErrorOnElement(element, "unexpected element kind");
ahe 2012/05/01 17:26:24 I think you should use the node here.
karlklose 2012/05/02 08:26:50 Done.
1115 } 1118 }
1116 } 1119 }
1117 return useType(node, type); 1120 return useType(node, type);
1118 } 1121 }
1119 1122
1120 visitModifiers(Modifiers node) { 1123 visitModifiers(Modifiers node) {
1121 // TODO(ngeoffray): Implement this. 1124 // TODO(ngeoffray): Implement this.
1122 unimplemented(node, 'modifiers'); 1125 unimplemented(node, 'modifiers');
1123 } 1126 }
1124 1127
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 1735
1733 // TODO(ahe): This is temporary. 1736 // TODO(ahe): This is temporary.
1734 void resolveExpression(Node node) { 1737 void resolveExpression(Node node) {
1735 if (node == null) return; 1738 if (node == null) return;
1736 node.accept(new ResolverVisitor(compiler, enclosingElement)); 1739 node.accept(new ResolverVisitor(compiler, enclosingElement));
1737 } 1740 }
1738 1741
1739 // TODO(ahe): This is temporary. 1742 // TODO(ahe): This is temporary.
1740 void resolveType(Node node) { 1743 void resolveType(Node node) {
1741 if (node == null) return; 1744 if (node == null) return;
1742 // Find the correct member context to perform the lookup in. 1745 node.accept(new ResolverVisitor(compiler, enclosingElement));
1743 Element outer = enclosingElement;
1744 Element context = outer;
1745 while (outer !== null) {
1746 if (outer.isMember()) {
1747 context = outer;
1748 break;
1749 }
1750 outer = outer.enclosingElement;
1751 }
1752 node.accept(new ResolverVisitor(compiler, context));
1753 } 1746 }
1754 1747
1755 // TODO(ahe): This is temporary. 1748 // TODO(ahe): This is temporary.
1756 ClassElement get currentClass() { 1749 ClassElement get currentClass() {
1757 return enclosingElement.isMember() 1750 return enclosingElement.isMember()
1758 ? enclosingElement.enclosingElement : null; 1751 ? enclosingElement.enclosingElement : null;
1759 } 1752 }
1760 } 1753 }
1761 1754
1762 class ConstructorResolver extends CommonResolverVisitor<Element> { 1755 class ConstructorResolver extends CommonResolverVisitor<Element> {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 1904
1912 TopScope(LibraryElement library) : super(null, library); 1905 TopScope(LibraryElement library) : super(null, library);
1913 Element lookup(SourceString name) { 1906 Element lookup(SourceString name) {
1914 return library.find(name); 1907 return library.find(name);
1915 } 1908 }
1916 1909
1917 Element add(Element newElement) { 1910 Element add(Element newElement) {
1918 throw "Cannot add an element in the top scope"; 1911 throw "Cannot add an element in the top scope";
1919 } 1912 }
1920 } 1913 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698