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

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

Issue 10270010: Remove getType; use the resolver instead. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 7 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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 204 }
205 205
206 TreeElements resolveParameter(Element element) { 206 TreeElements resolveParameter(Element element) {
207 Node tree = element.parseNode(compiler); 207 Node tree = element.parseNode(compiler);
208 ResolverVisitor visitor = 208 ResolverVisitor visitor =
209 new ResolverVisitor(compiler, element.enclosingElement); 209 new ResolverVisitor(compiler, element.enclosingElement);
210 initializerDo(tree, visitor.visit); 210 initializerDo(tree, visitor.visit);
211 return visitor.mapping; 211 return visitor.mapping;
212 } 212 }
213 213
214 Type resolveTypeAnnotation(Element element, TypeAnnotation annotation) {
215 if (annotation === null) return compiler.types.dynamicType;
216 ResolverVisitor visitor = new ResolverVisitor(compiler, element);
217 Type result = visitor.resolveTypeAnnotation(annotation);
218 if (result === null) {
219 // TODO(karklose): warning.
220 return compiler.types.dynamicType;
221 }
222 return result;
223 }
224
214 void resolveClass(ClassElement element) { 225 void resolveClass(ClassElement element) {
215 if (element.isResolved) return; 226 if (element.isResolved) return;
216 measure(() { 227 measure(() {
217 ClassNode tree = element.parseNode(compiler); 228 ClassNode tree = element.parseNode(compiler);
218 ClassResolverVisitor visitor = 229 ClassResolverVisitor visitor =
219 new ClassResolverVisitor(compiler, element.getLibrary(), element); 230 new ClassResolverVisitor(compiler, element.getLibrary(), element);
220 visitor.visit(tree); 231 visitor.visit(tree);
221 element.isResolved = true; 232 element.isResolved = true;
222 }); 233 });
223 } 234 }
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 report(typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); 1111 report(typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT);
1101 } 1112 }
1102 arguments.addLast(resolveTypeAnnotation(typeArguments.head)); 1113 arguments.addLast(resolveTypeAnnotation(typeArguments.head));
1103 } 1114 }
1104 if (index < cls.typeParameters.length) { 1115 if (index < cls.typeParameters.length) {
1105 report(node.typeArguments, MessageKind.MISSING_TYPE_ARGUMENT); 1116 report(node.typeArguments, MessageKind.MISSING_TYPE_ARGUMENT);
1106 } 1117 }
1107 } 1118 }
1108 if (cls.typeParameters.length == 0) { 1119 if (cls.typeParameters.length == 0) {
1109 // Return the canonical type if it has no type parameters. 1120 // Return the canonical type if it has no type parameters.
1110 type = element.computeType(compiler); 1121 type = cls.computeType(compiler);
1111 } else { 1122 } else {
1112 type = new InterfaceType(cls, arguments.toLink()); 1123 type = new InterfaceType(cls, arguments.toLink());
1113 } 1124 }
1114 } else if (element.isTypedef() || element.isTypeVariable()) { 1125 } else if (element.isTypedef()) {
1126 // TODO(ngeoffray): This is a hack to help us get support for the
1127 // DOM library.
1128 // TODO(ngeoffray): The list of types for the argument is wrong.
1129 type = new FunctionType(compiler.types.dynamicType,
1130 const EmptyLink<Type>(),
1131 element);
1132 } else if (element.isTypeVariable()) {
1115 type = element.computeType(compiler); 1133 type = element.computeType(compiler);
1116 } else { 1134 } else {
1117 compiler.cancel("unexpected element kind ${element.kind}", 1135 compiler.cancel("unexpected element kind ${element.kind}",
1118 node: node); 1136 node: node);
1119 } 1137 }
1120 } 1138 }
1121 return useType(node, type); 1139 return useType(node, type);
1122 } 1140 }
1123 1141
1124 visitModifiers(Modifiers node) { 1142 visitModifiers(Modifiers node) {
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 1923
1906 TopScope(LibraryElement library) : super(null, library); 1924 TopScope(LibraryElement library) : super(null, library);
1907 Element lookup(SourceString name) { 1925 Element lookup(SourceString name) {
1908 return library.find(name); 1926 return library.find(name);
1909 } 1927 }
1910 1928
1911 Element add(Element newElement) { 1929 Element add(Element newElement) {
1912 throw "Cannot add an element in the top scope"; 1930 throw "Cannot add an element in the top scope";
1913 } 1931 }
1914 } 1932 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/elements/elements.dart ('k') | lib/compiler/implementation/typechecker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698