| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 | 74 |
| 75 Set<ClassElement> unneededClasses = new Set<ClassElement>(); | 75 Set<ClassElement> unneededClasses = new Set<ClassElement>(); |
| 76 // The [Bool] class is not marked as abstract, but has a factory | 76 // The [Bool] class is not marked as abstract, but has a factory |
| 77 // constructor that always throws. We never need to emit it. | 77 // constructor that always throws. We never need to emit it. |
| 78 unneededClasses.add(commonElements.boolClass); | 78 unneededClasses.add(commonElements.boolClass); |
| 79 | 79 |
| 80 // Go over specialized interceptors and then constants to know which | 80 // Go over specialized interceptors and then constants to know which |
| 81 // interceptors are needed. | 81 // interceptors are needed. |
| 82 Set<ClassElement> needed = new Set<ClassElement>(); | 82 Set<ClassElement> needed = new Set<ClassElement>(); |
| 83 backend.interceptorData.specializedGetInterceptors | 83 for (js.Name name |
| 84 .forEach((_, Iterable<ClassElement> elements) { | 84 in backend.oneShotInterceptorData.specializedGetInterceptorNames) { |
| 85 needed.addAll(elements); | 85 needed.addAll(backend.oneShotInterceptorData |
| 86 }); | 86 .getSpecializedGetInterceptorsFor(name)); |
| 87 } |
| 87 | 88 |
| 88 // Add interceptors referenced by constants. | 89 // Add interceptors referenced by constants. |
| 89 needed.addAll(computeInterceptorsReferencedFromConstants()); | 90 needed.addAll(computeInterceptorsReferencedFromConstants()); |
| 90 | 91 |
| 91 // Add unneeded interceptors to the [unneededClasses] set. | 92 // Add unneeded interceptors to the [unneededClasses] set. |
| 92 for (ClassElement interceptor | 93 for (ClassElement interceptor |
| 93 in backend.interceptorData.interceptedClasses) { | 94 in backend.interceptorData.interceptedClasses) { |
| 94 if (!needed.contains(interceptor) && | 95 if (!needed.contains(interceptor) && |
| 95 interceptor != commonElements.objectClass) { | 96 interceptor != commonElements.objectClass) { |
| 96 unneededClasses.add(interceptor); | 97 unneededClasses.add(interceptor); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 } | 327 } |
| 327 | 328 |
| 328 void collect() { | 329 void collect() { |
| 329 computeNeededDeclarations(); | 330 computeNeededDeclarations(); |
| 330 computeNeededConstants(); | 331 computeNeededConstants(); |
| 331 computeNeededStatics(); | 332 computeNeededStatics(); |
| 332 computeNeededStaticNonFinalFields(); | 333 computeNeededStaticNonFinalFields(); |
| 333 computeNeededLibraries(); | 334 computeNeededLibraries(); |
| 334 } | 335 } |
| 335 } | 336 } |
| OLD | NEW |