OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.program_builder; | 5 part of dart2js.js_emitter.program_builder; |
6 | 6 |
7 /** | 7 /** |
8 * Generates the code for all used classes in the program. Static fields (even | 8 * Generates the code for all used classes in the program. Static fields (even |
9 * in classes) are ignored, since they can be treated as non-class elements. | 9 * in classes) are ignored, since they can be treated as non-class elements. |
10 * | 10 * |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 final Map<OutputUnit, Set<LibraryEntity>> outputLibraryLists = | 43 final Map<OutputUnit, Set<LibraryEntity>> outputLibraryLists = |
44 new Map<OutputUnit, Set<LibraryEntity>>(); | 44 new Map<OutputUnit, Set<LibraryEntity>>(); |
45 | 45 |
46 /// True, if the output contains a constant list. | 46 /// True, if the output contains a constant list. |
47 /// | 47 /// |
48 /// This flag is updated in [computeNeededConstants]. | 48 /// This flag is updated in [computeNeededConstants]. |
49 bool outputContainsConstantList = false; | 49 bool outputContainsConstantList = false; |
50 | 50 |
51 final List<ClassElement> nativeClassesAndSubclasses = <ClassElement>[]; | 51 final List<ClassElement> nativeClassesAndSubclasses = <ClassElement>[]; |
52 | 52 |
53 List<TypedefElement> typedefsNeededForReflection; | 53 List<TypedefEntity> typedefsNeededForReflection; |
54 | 54 |
55 Collector( | 55 Collector( |
56 this._options, | 56 this._options, |
57 this._commonElements, | 57 this._commonElements, |
58 this._elementEnvironment, | 58 this._elementEnvironment, |
59 this._deferredLoadTask, | 59 this._deferredLoadTask, |
60 this._worldBuilder, | 60 this._worldBuilder, |
61 this._namer, | 61 this._namer, |
62 this._emitter, | 62 this._emitter, |
63 this._constantHandler, | 63 this._constantHandler, |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 190 } |
191 outputConstantLists | 191 outputConstantLists |
192 .putIfAbsent(constantUnit, () => new List<ConstantValue>()) | 192 .putIfAbsent(constantUnit, () => new List<ConstantValue>()) |
193 .add(constant); | 193 .add(constant); |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 /// Compute all the classes and typedefs that must be emitted. | 197 /// Compute all the classes and typedefs that must be emitted. |
198 void computeNeededDeclarations() { | 198 void computeNeededDeclarations() { |
199 // Compute needed typedefs. | 199 // Compute needed typedefs. |
200 typedefsNeededForReflection = Elements.sortedByPosition(_closedWorld | 200 typedefsNeededForReflection = _sorter.sortTypedefs(_closedWorld.allTypedefs |
201 .allTypedefs | |
202 .where(_mirrorsData.isTypedefAccessibleByReflection) | 201 .where(_mirrorsData.isTypedefAccessibleByReflection) |
203 .toList()); | 202 .toList()); |
204 | 203 |
205 // Compute needed classes. | 204 // Compute needed classes. |
206 Set<ClassEntity> instantiatedClasses = | 205 Set<ClassEntity> instantiatedClasses = |
207 // TODO(johnniwinther): This should be accessed from a codegen closed | 206 // TODO(johnniwinther): This should be accessed from a codegen closed |
208 // world. | 207 // world. |
209 _worldBuilder.directlyInstantiatedClasses | 208 _worldBuilder.directlyInstantiatedClasses |
210 .where(computeClassFilter()) | 209 .where(computeClassFilter()) |
211 .toSet(); | 210 .toSet(); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 352 } |
354 | 353 |
355 void collect() { | 354 void collect() { |
356 computeNeededDeclarations(); | 355 computeNeededDeclarations(); |
357 computeNeededConstants(); | 356 computeNeededConstants(); |
358 computeNeededStatics(); | 357 computeNeededStatics(); |
359 computeNeededStaticNonFinalFields(); | 358 computeNeededStaticNonFinalFields(); |
360 computeNeededLibraries(); | 359 computeNeededLibraries(); |
361 } | 360 } |
362 } | 361 } |
OLD | NEW |