| 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 ResolutionEnqueuer resolution; | 8 final ResolutionEnqueuer resolution; |
| 9 final CodegenEnqueuer codegen; | 9 final CodegenEnqueuer codegen; |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 cls, this, compiler.globalDependencies); | 145 cls, this, compiler.globalDependencies); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void registerInstantiatedClass(ClassElement cls, TreeElements elements) { | 148 void registerInstantiatedClass(ClassElement cls, TreeElements elements) { |
| 149 cls.ensureResolved(compiler); | 149 cls.ensureResolved(compiler); |
| 150 registerInstantiatedType(cls.rawType, elements); | 150 registerInstantiatedType(cls.rawType, elements); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void registerTypeLiteral(Element element, TreeElements elements) { | 153 void registerTypeLiteral(Element element, TreeElements elements) { |
| 154 registerInstantiatedClass(compiler.typeClass, elements); | 154 registerInstantiatedClass(compiler.typeClass, elements); |
| 155 compiler.backend.registerTypeLiteral(elements); | 155 compiler.backend.registerTypeLiteral(element, elements); |
| 156 if (compiler.mirrorsEnabled) { | |
| 157 // In order to use reflectClass, we need to find the constructor. | |
| 158 registerInstantiatedClass(element, elements); | |
| 159 } | |
| 160 } | 156 } |
| 161 | 157 |
| 162 bool checkNoEnqueuedInvokedInstanceMethods() { | 158 bool checkNoEnqueuedInvokedInstanceMethods() { |
| 163 task.measure(() { | 159 task.measure(() { |
| 164 // Run through the classes and see if we need to compile methods. | 160 // Run through the classes and see if we need to compile methods. |
| 165 for (ClassElement classElement in universe.instantiatedClasses) { | 161 for (ClassElement classElement in universe.instantiatedClasses) { |
| 166 for (ClassElement currentClass = classElement; | 162 for (ClassElement currentClass = classElement; |
| 167 currentClass != null; | 163 currentClass != null; |
| 168 currentClass = currentClass.superclass) { | 164 currentClass = currentClass.superclass) { |
| 169 processInstantiatedClass(currentClass); | 165 processInstantiatedClass(currentClass); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 322 } |
| 327 | 323 |
| 328 void registerInvokedSetter(SourceString setterName, Selector selector) { | 324 void registerInvokedSetter(SourceString setterName, Selector selector) { |
| 329 task.measure(() { | 325 task.measure(() { |
| 330 registerNewSelector(setterName, selector, universe.invokedSetters); | 326 registerNewSelector(setterName, selector, universe.invokedSetters); |
| 331 }); | 327 }); |
| 332 } | 328 } |
| 333 | 329 |
| 334 /// Called when [:const Symbol(name):] is seen. | 330 /// Called when [:const Symbol(name):] is seen. |
| 335 void registerConstSymbol(String name, TreeElements elements) { | 331 void registerConstSymbol(String name, TreeElements elements) { |
| 336 // If dart:mirrors is loaded, a const symbol may be used to call a | 332 compiler.backend.registerConstSymbol(name, elements); |
| 337 // static/top-level method or accessor, instantiate a class, call | |
| 338 // an instance method or accessor with the given name. | |
| 339 if (!compiler.mirrorsEnabled) return; | |
| 340 | |
| 341 task.ensureAllElementsByName(); | |
| 342 | |
| 343 for (var link = task.allElementsByName[name]; | |
| 344 link != null && !link.isEmpty; | |
| 345 link = link.tail) { | |
| 346 pretendElementWasUsed(link.head, elements); | |
| 347 } | |
| 348 } | 333 } |
| 349 | 334 |
| 350 void pretendElementWasUsed(Element element, TreeElements elements) { | 335 void pretendElementWasUsed(Element element, TreeElements elements) { |
| 351 if (Elements.isUnresolved(element)) { | 336 if (Elements.isUnresolved(element)) { |
| 352 // Ignore. | 337 // Ignore. |
| 353 } else if (element.isSynthesized | 338 } else if (element.isSynthesized |
| 354 && element.getLibrary().isPlatformLibrary) { | 339 && element.getLibrary().isPlatformLibrary) { |
| 355 // TODO(ahe): Work-around for http://dartbug.com/11205. | 340 // TODO(ahe): Work-around for http://dartbug.com/11205. |
| 356 } else if (element.isConstructor()) { | 341 } else if (element.isConstructor()) { |
| 357 ClassElement cls = element.declaration.getEnclosingClass(); | 342 ClassElement cls = element.declaration.getEnclosingClass(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 381 new Selector.setter(element.name, element.getLibrary()); | 366 new Selector.setter(element.name, element.getLibrary()); |
| 382 registerInvokedSetter(element.name, selector); | 367 registerInvokedSetter(element.name, selector); |
| 383 selector = new Selector.getter(element.name, element.getLibrary()); | 368 selector = new Selector.getter(element.name, element.getLibrary()); |
| 384 registerInvokedGetter(element.name, selector); | 369 registerInvokedGetter(element.name, selector); |
| 385 } | 370 } |
| 386 } | 371 } |
| 387 } | 372 } |
| 388 | 373 |
| 389 /// Called when [:new Symbol(...):] is seen. | 374 /// Called when [:new Symbol(...):] is seen. |
| 390 void registerNewSymbol(TreeElements elements) { | 375 void registerNewSymbol(TreeElements elements) { |
| 376 compiler.backend.registerNewSymbol(elements); |
| 391 } | 377 } |
| 392 | 378 |
| 393 void enqueueEverything() { | 379 void enqueueEverything() { |
| 394 if (hasEnqueuedEverything) return; | 380 if (hasEnqueuedEverything) return; |
| 395 compiler.log('Enqueuing everything'); | 381 compiler.log('Enqueuing everything'); |
| 396 task.ensureAllElementsByName(); | 382 task.ensureAllElementsByName(); |
| 397 for (Link link in task.allElementsByName.values) { | 383 for (Link link in task.allElementsByName.values) { |
| 398 for (Element element in link) { | 384 for (Element element in link) { |
| 399 pretendElementWasUsed(element, compiler.globalDependencies); | 385 pretendElementWasUsed(element, compiler.globalDependencies); |
| 400 } | 386 } |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 while(!queue.isEmpty) { | 745 while(!queue.isEmpty) { |
| 760 // TODO(johnniwinther): Find an optimal process order for codegen. | 746 // TODO(johnniwinther): Find an optimal process order for codegen. |
| 761 f(queue.removeLast()); | 747 f(queue.removeLast()); |
| 762 } | 748 } |
| 763 } | 749 } |
| 764 | 750 |
| 765 void _logSpecificSummary(log(message)) { | 751 void _logSpecificSummary(log(message)) { |
| 766 log('Compiled ${generatedCode.length} methods.'); | 752 log('Compiled ${generatedCode.length} methods.'); |
| 767 } | 753 } |
| 768 } | 754 } |
| OLD | NEW |