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

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: 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 resolveType(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 type = new InterfaceType(cls.name, cls, arguments.toLink()); 1119 type = new InterfaceType(cls.name, cls, arguments.toLink());
1109 } else if (element.isTypedef()) { 1120 } else if (element.isTypedef()) {
1110 // TODO(karlklose): implement typedefs. We return a fake type that the 1121 // TODO(ngeoffray): This is a hack to help us get support for the
1111 // code generator can use to detect typedefs in is-checks. 1122 // DOM library.
1112 type = new InterfaceType(element.name, element); 1123 // TODO(ngeoffray): The list of types for the argument is wrong.
1124 type = new FunctionType(compiler.types.dynamicType,
1125 const EmptyLink<Type>(),
1126 element);
1113 } else { 1127 } else {
1114 type = element.computeType(compiler); 1128 type = element.computeType(compiler);
1115 } 1129 }
1116 } 1130 }
1117 return useType(node, type); 1131 return useType(node, type);
1118 } 1132 }
1119 1133
1120 visitModifiers(Modifiers node) { 1134 visitModifiers(Modifiers node) {
1121 // TODO(ngeoffray): Implement this. 1135 // TODO(ngeoffray): Implement this.
1122 unimplemented(node, 'modifiers'); 1136 unimplemented(node, 'modifiers');
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 1925
1912 TopScope(LibraryElement library) : super(null, library); 1926 TopScope(LibraryElement library) : super(null, library);
1913 Element lookup(SourceString name) { 1927 Element lookup(SourceString name) {
1914 return library.find(name); 1928 return library.find(name);
1915 } 1929 }
1916 1930
1917 Element add(Element newElement) { 1931 Element add(Element newElement) {
1918 throw "Cannot add an element in the top scope"; 1932 throw "Cannot add an element in the top scope";
1919 } 1933 }
1920 } 1934 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698