Chromium Code Reviews| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 /// Compute all the classes and typedefs that must be emitted. | 171 /// Compute all the classes and typedefs that must be emitted. |
| 172 void computeNeededDeclarations() { | 172 void computeNeededDeclarations() { |
| 173 // Compute needed typedefs. | 173 // Compute needed typedefs. |
| 174 typedefsNeededForReflection = Elements.sortedByPosition(closedWorld | 174 typedefsNeededForReflection = Elements.sortedByPosition(closedWorld |
| 175 .allTypedefs | 175 .allTypedefs |
| 176 .where(backend.isAccessibleByReflection) | 176 .where(backend.isAccessibleByReflection) |
| 177 .toList()); | 177 .toList()); |
| 178 | 178 |
| 179 // Compute needed classes. | 179 // Compute needed classes. |
| 180 Set<ClassElement> instantiatedClasses = compiler | 180 Set<ClassElement> instantiatedClasses = compiler |
| 181 .codegenWorld.directlyInstantiatedClasses | 181 .codegenWorldBuilder.directlyInstantiatedClasses |
|
Siggi Cherem (dart-lang)
2017/01/11 23:54:56
similar to my other question about the namer - it
Johnni Winther
2017/01/12 12:20:12
Not yet. Added a TODO.
| |
| 182 .where(computeClassFilter()) | 182 .where(computeClassFilter()) |
| 183 .toSet(); | 183 .toSet(); |
| 184 | 184 |
| 185 void addClassWithSuperclasses(ClassElement cls) { | 185 void addClassWithSuperclasses(ClassElement cls) { |
| 186 neededClasses.add(cls); | 186 neededClasses.add(cls); |
| 187 for (ClassElement superclass = cls.superclass; | 187 for (ClassElement superclass = cls.superclass; |
| 188 superclass != null; | 188 superclass != null; |
| 189 superclass = superclass.superclass) { | 189 superclass = superclass.superclass) { |
| 190 neededClasses.add(superclass); | 190 neededClasses.add(superclass); |
| 191 } | 191 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 | 279 |
| 280 void computeNeededStaticNonFinalFields() { | 280 void computeNeededStaticNonFinalFields() { |
| 281 JavaScriptConstantCompiler handler = backend.constants; | 281 JavaScriptConstantCompiler handler = backend.constants; |
| 282 addToOutputUnit(Element element) { | 282 addToOutputUnit(Element element) { |
| 283 List<VariableElement> list = outputStaticNonFinalFieldLists.putIfAbsent( | 283 List<VariableElement> list = outputStaticNonFinalFieldLists.putIfAbsent( |
| 284 compiler.deferredLoadTask.outputUnitForElement(element), | 284 compiler.deferredLoadTask.outputUnitForElement(element), |
| 285 () => new List<VariableElement>()); | 285 () => new List<VariableElement>()); |
| 286 list.add(element); | 286 list.add(element); |
| 287 } | 287 } |
| 288 | 288 |
| 289 Iterable<Element> fields = compiler.codegenWorld.allReferencedStaticFields | 289 Iterable<Element> fields = compiler |
| 290 .codegenWorldBuilder.allReferencedStaticFields | |
| 290 .where((FieldElement field) { | 291 .where((FieldElement field) { |
| 291 if (!field.isConst) { | 292 if (!field.isConst) { |
| 292 return field.isField && | 293 return field.isField && |
| 293 !field.isInstanceMember && | 294 !field.isInstanceMember && |
| 294 !field.isFinal && | 295 !field.isFinal && |
| 295 field.constant != null; | 296 field.constant != null; |
| 296 } else { | 297 } else { |
| 297 // We also need to emit static const fields if they are available for | 298 // We also need to emit static const fields if they are available for |
| 298 // reflection. | 299 // reflection. |
| 299 return backend.isAccessibleByReflection(field); | 300 return backend.isAccessibleByReflection(field); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 317 } | 318 } |
| 318 | 319 |
| 319 void collect() { | 320 void collect() { |
| 320 computeNeededDeclarations(); | 321 computeNeededDeclarations(); |
| 321 computeNeededConstants(); | 322 computeNeededConstants(); |
| 322 computeNeededStatics(); | 323 computeNeededStatics(); |
| 323 computeNeededStaticNonFinalFields(); | 324 computeNeededStaticNonFinalFields(); |
| 324 computeNeededLibraries(); | 325 computeNeededLibraries(); |
| 325 } | 326 } |
| 326 } | 327 } |
| OLD | NEW |