| 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 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 final Map<OutputUnit, List<VariableElement>> outputStaticNonFinalFieldLists = | 30 final Map<OutputUnit, List<VariableElement>> outputStaticNonFinalFieldLists = |
| 31 new Map<OutputUnit, List<VariableElement>>(); | 31 new Map<OutputUnit, List<VariableElement>>(); |
| 32 final Map<OutputUnit, Set<LibraryElement>> outputLibraryLists = | 32 final Map<OutputUnit, Set<LibraryElement>> outputLibraryLists = |
| 33 new Map<OutputUnit, Set<LibraryElement>>(); | 33 new Map<OutputUnit, Set<LibraryElement>>(); |
| 34 | 34 |
| 35 /// True, if the output contains a constant list. | 35 /// True, if the output contains a constant list. |
| 36 /// | 36 /// |
| 37 /// This flag is updated in [computeNeededConstants]. | 37 /// This flag is updated in [computeNeededConstants]. |
| 38 bool outputContainsConstantList = false; | 38 bool outputContainsConstantList = false; |
| 39 | 39 |
| 40 final List<ClassElement> nativeClasses = <ClassElement>[]; | 40 final List<ClassElement> nativeClassesAndSubclasses = <ClassElement>[]; |
| 41 | 41 |
| 42 /// Records if a type variable is read dynamically for type tests. | 42 /// Records if a type variable is read dynamically for type tests. |
| 43 final Set<TypeVariableElement> readTypeVariables = | 43 final Set<TypeVariableElement> readTypeVariables = |
| 44 new Set<TypeVariableElement>(); | 44 new Set<TypeVariableElement>(); |
| 45 | 45 |
| 46 List<TypedefElement> typedefsNeededForReflection; | 46 List<TypedefElement> typedefsNeededForReflection; |
| 47 | 47 |
| 48 JavaScriptBackend get backend => compiler.backend; | 48 JavaScriptBackend get backend => compiler.backend; |
| 49 | 49 |
| 50 CodeEmitterTask(Compiler compiler, Namer namer, bool generateSourceMap) | 50 CodeEmitterTask(Compiler compiler, Namer namer, bool generateSourceMap) |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 neededClasses.add(compiler.listClass); | 331 neededClasses.add(compiler.listClass); |
| 332 } | 332 } |
| 333 | 333 |
| 334 // 5. Finally, sort the classes. | 334 // 5. Finally, sort the classes. |
| 335 List<ClassElement> sortedClasses = Elements.sortedByPosition(neededClasses); | 335 List<ClassElement> sortedClasses = Elements.sortedByPosition(neededClasses); |
| 336 | 336 |
| 337 for (ClassElement element in sortedClasses) { | 337 for (ClassElement element in sortedClasses) { |
| 338 if (Elements.isNativeOrExtendsNative(element) && | 338 if (Elements.isNativeOrExtendsNative(element) && |
| 339 !typeTestRegistry.rtiNeededClasses.contains(element)) { | 339 !typeTestRegistry.rtiNeededClasses.contains(element)) { |
| 340 // For now, native classes and related classes cannot be deferred. | 340 // For now, native classes and related classes cannot be deferred. |
| 341 nativeClasses.add(element); | 341 nativeClassesAndSubclasses.add(element); |
| 342 if (!element.isNative) { | 342 assert(invariant(element, |
| 343 assert(invariant(element, | 343 !compiler.deferredLoadTask.isDeferred(element))); |
| 344 !compiler.deferredLoadTask.isDeferred(element))); | 344 outputClassLists.putIfAbsent(compiler.deferredLoadTask.mainOutputUnit, |
| 345 outputClassLists.putIfAbsent(compiler.deferredLoadTask.mainOutputUnit, | 345 () => new List<ClassElement>()).add(element); |
| 346 () => new List<ClassElement>()).add(element); | |
| 347 } | |
| 348 } else { | 346 } else { |
| 349 outputClassLists.putIfAbsent( | 347 outputClassLists.putIfAbsent( |
| 350 compiler.deferredLoadTask.outputUnitForElement(element), | 348 compiler.deferredLoadTask.outputUnitForElement(element), |
| 351 () => new List<ClassElement>()) | 349 () => new List<ClassElement>()) |
| 352 .add(element); | 350 .add(element); |
| 353 } | 351 } |
| 354 } | 352 } |
| 355 } | 353 } |
| 356 | 354 |
| 357 void computeNeededStatics() { | 355 void computeNeededStatics() { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 jsAst.Expression typeAccess(Element e); | 455 jsAst.Expression typeAccess(Element e); |
| 458 | 456 |
| 459 /// Returns the JS expression representing a function that returns 'null' | 457 /// Returns the JS expression representing a function that returns 'null' |
| 460 jsAst.Expression generateFunctionThatReturnsNull(); | 458 jsAst.Expression generateFunctionThatReturnsNull(); |
| 461 | 459 |
| 462 int compareConstants(ConstantValue a, ConstantValue b); | 460 int compareConstants(ConstantValue a, ConstantValue b); |
| 463 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); | 461 bool isConstantInlinedOrAlreadyEmitted(ConstantValue constant); |
| 464 | 462 |
| 465 void invalidateCaches(); | 463 void invalidateCaches(); |
| 466 } | 464 } |
| OLD | NEW |