| 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.js_emitter; | 5 part of dart2js.js_emitter; |
| 6 | 6 |
| 7 const USE_NEW_EMITTER = const bool.fromEnvironment("dart2js.use.new.emitter"); | 7 const USE_NEW_EMITTER = const bool.fromEnvironment("dart2js.use.new.emitter"); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Generates the code for all used classes in the program. Static fields (even | 10 * Generates the code for all used classes in the program. Static fields (even |
| 11 * in classes) are ignored, since they can be treated as non-class elements. | 11 * in classes) are ignored, since they can be treated as non-class elements. |
| 12 * | 12 * |
| 13 * The code for the containing (used) methods must exist in the [:universe:]. | 13 * The code for the containing (used) methods must exist in the `universe`. |
| 14 */ | 14 */ |
| 15 class CodeEmitterTask extends CompilerTask { | 15 class CodeEmitterTask extends CompilerTask { |
| 16 // TODO(floitsch): the code-emitter task should not need a namer. | 16 // TODO(floitsch): the code-emitter task should not need a namer. |
| 17 final Namer namer; | 17 final Namer namer; |
| 18 final TypeTestRegistry typeTestRegistry; | 18 final TypeTestRegistry typeTestRegistry; |
| 19 NativeEmitter nativeEmitter; | 19 NativeEmitter nativeEmitter; |
| 20 MetadataCollector metadataCollector; | 20 MetadataCollector metadataCollector; |
| 21 OldEmitter oldEmitter; | 21 OldEmitter oldEmitter; |
| 22 Emitter emitter; | 22 Emitter emitter; |
| 23 | 23 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 for (Element element in Elements.sortedByPosition(elements)) { | 356 for (Element element in Elements.sortedByPosition(elements)) { |
| 357 List<Element> list = outputStaticLists.putIfAbsent( | 357 List<Element> list = outputStaticLists.putIfAbsent( |
| 358 compiler.deferredLoadTask.outputUnitForElement(element), | 358 compiler.deferredLoadTask.outputUnitForElement(element), |
| 359 () => new List<Element>()); | 359 () => new List<Element>()); |
| 360 list.add(element); | 360 list.add(element); |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 | 363 |
| 364 void computeNeededStaticNonFinalFields() { | 364 void computeNeededStaticNonFinalFields() { |
| 365 JavaScriptConstantCompiler handler = backend.constants; | 365 JavaScriptConstantCompiler handler = backend.constants; |
| 366 Iterable<VariableElement> staticNonFinalFields = | 366 Iterable<VariableElement> staticNonFinalFields = handler |
| 367 handler.getStaticNonFinalFieldsForEmission(); | 367 .getStaticNonFinalFieldsForEmission() |
| 368 .where(compiler.codegenWorld.allReferencedStaticFields.contains); |
| 368 for (Element element in Elements.sortedByPosition(staticNonFinalFields)) { | 369 for (Element element in Elements.sortedByPosition(staticNonFinalFields)) { |
| 369 List<VariableElement> list = outputStaticNonFinalFieldLists.putIfAbsent( | 370 List<VariableElement> list = outputStaticNonFinalFieldLists.putIfAbsent( |
| 370 compiler.deferredLoadTask.outputUnitForElement(element), | 371 compiler.deferredLoadTask.outputUnitForElement(element), |
| 371 () => new List<VariableElement>()); | 372 () => new List<VariableElement>()); |
| 372 list.add(element); | 373 list.add(element); |
| 373 } | 374 } |
| 374 } | 375 } |
| 375 | 376 |
| 376 void computeNeededLibraries() { | 377 void computeNeededLibraries() { |
| 377 void addSurroundingLibraryToSet(Element element) { | 378 void addSurroundingLibraryToSet(Element element) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 453 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
| 453 | 454 |
| 454 /// Returns the JS code for accessing the given [constant]. | 455 /// Returns the JS code for accessing the given [constant]. |
| 455 jsAst.Expression constantReference(ConstantValue constant); | 456 jsAst.Expression constantReference(ConstantValue constant); |
| 456 | 457 |
| 457 /// Returns the JS template for the given [builtin]. | 458 /// Returns the JS template for the given [builtin]. |
| 458 jsAst.Template templateForBuiltin(JsBuiltin builtin); | 459 jsAst.Template templateForBuiltin(JsBuiltin builtin); |
| 459 | 460 |
| 460 void invalidateCaches(); | 461 void invalidateCaches(); |
| 461 } | 462 } |
| OLD | NEW |