OLD | NEW |
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 part of dart2js; | 5 part of dart2js; |
6 | 6 |
7 class EnqueueTask extends CompilerTask { | 7 class EnqueueTask extends CompilerTask { |
8 final Enqueuer codegen; | 8 final Enqueuer codegen; |
9 final Enqueuer resolution; | 9 final Enqueuer resolution; |
10 | 10 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 * Invariant: [element] must be a declaration element. | 131 * Invariant: [element] must be a declaration element. |
132 */ | 132 */ |
133 void eagerRecompile(Element element) { | 133 void eagerRecompile(Element element) { |
134 assert(invariant(element, element.isDeclaration)); | 134 assert(invariant(element, element.isDeclaration)); |
135 universe.generatedCode.remove(element); | 135 universe.generatedCode.remove(element); |
136 universe.generatedBailoutCode.remove(element); | 136 universe.generatedBailoutCode.remove(element); |
137 addToWorkList(element); | 137 addToWorkList(element); |
138 } | 138 } |
139 | 139 |
140 void registerInstantiatedClass(ClassElement cls) { | 140 void registerInstantiatedClass(ClassElement cls) { |
141 if (cls.isInterface()) { | |
142 compiler.internalErrorOnElement( | |
143 // Use the current element, as this is where cls is referenced from. | |
144 compiler.currentElement, | |
145 'Expected a class, but $cls is an interface.'); | |
146 } | |
147 universe.instantiatedClasses.add(cls); | 141 universe.instantiatedClasses.add(cls); |
148 onRegisterInstantiatedClass(cls); | 142 onRegisterInstantiatedClass(cls); |
149 compiler.backend.registerInstantiatedClass(cls, this); | 143 compiler.backend.registerInstantiatedClass(cls, this); |
150 } | 144 } |
151 | 145 |
152 bool checkNoEnqueuedInvokedInstanceMethods() { | 146 bool checkNoEnqueuedInvokedInstanceMethods() { |
153 task.measure(() { | 147 task.measure(() { |
154 // Run through the classes and see if we need to compile methods. | 148 // Run through the classes and see if we need to compile methods. |
155 for (ClassElement classElement in universe.instantiatedClasses) { | 149 for (ClassElement classElement in universe.instantiatedClasses) { |
156 for (ClassElement currentClass = classElement; | 150 for (ClassElement currentClass = classElement; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // The class must be resolved to compute the set of all | 226 // The class must be resolved to compute the set of all |
233 // supertypes. | 227 // supertypes. |
234 cls.ensureResolved(compiler); | 228 cls.ensureResolved(compiler); |
235 | 229 |
236 for (Link<DartType> supertypes = cls.allSupertypesAndSelf; | 230 for (Link<DartType> supertypes = cls.allSupertypesAndSelf; |
237 !supertypes.isEmpty; supertypes = supertypes.tail) { | 231 !supertypes.isEmpty; supertypes = supertypes.tail) { |
238 cls = supertypes.head.element; | 232 cls = supertypes.head.element; |
239 if (seenClasses.contains(cls)) continue; | 233 if (seenClasses.contains(cls)) continue; |
240 seenClasses.add(cls); | 234 seenClasses.add(cls); |
241 cls.ensureResolved(compiler); | 235 cls.ensureResolved(compiler); |
242 if (!cls.isInterface()) { | 236 cls.implementation.forEachMember(processInstantiatedClassMember); |
243 cls.implementation.forEachMember(processInstantiatedClassMember); | |
244 } | |
245 if (isResolutionQueue) { | 237 if (isResolutionQueue) { |
246 compiler.resolver.checkMembers(cls); | 238 compiler.resolver.checkMembers(cls); |
247 } | 239 } |
248 | 240 |
249 if (compiler.enableTypeAssertions) { | 241 if (compiler.enableTypeAssertions) { |
250 // We need to register is checks and helpers for checking | 242 // We need to register is checks and helpers for checking |
251 // assignments to fields. | 243 // assignments to fields. |
252 // TODO(ngeoffray): This should really move to the backend. | 244 // TODO(ngeoffray): This should really move to the backend. |
253 cls.localMembers.forEach((Element member) { | 245 cls.localMembers.forEach((Element member) { |
254 if (!member.isInstanceMember() || !member.isField()) return; | 246 if (!member.isInstanceMember() || !member.isField()) return; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 nativeEnqueuer.logSummary(log); | 404 nativeEnqueuer.logSummary(log); |
413 } | 405 } |
414 | 406 |
415 registerUsedSelector(Selector selector) { | 407 registerUsedSelector(Selector selector) { |
416 Element interceptor = compiler.backend.getInterceptor(selector); | 408 Element interceptor = compiler.backend.getInterceptor(selector); |
417 if (interceptor != null) { | 409 if (interceptor != null) { |
418 registerStaticUse(interceptor); | 410 registerStaticUse(interceptor); |
419 } | 411 } |
420 } | 412 } |
421 } | 413 } |
OLD | NEW |