Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: pkg/compiler/lib/src/js_emitter/program_builder/collector.dart

Issue 2894893002: Add ElementCodegenWorldBuilder (Closed)
Patch Set: Updated cf. comments. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = Elements.sortedByPosition(_closedWorld
201 .allTypedefs 201 .allTypedefs
202 .where(_mirrorsData.isTypedefAccessibleByReflection) 202 .where(_mirrorsData.isTypedefAccessibleByReflection)
203 .toList()); 203 .toList());
204 204
205 // Compute needed classes. 205 // Compute needed classes.
206 Set<ClassElement> instantiatedClasses = 206 Set<ClassEntity> instantiatedClasses =
207 // TODO(johnniwinther): This should be accessed from a codegen closed 207 // TODO(johnniwinther): This should be accessed from a codegen closed
208 // world. 208 // world.
209 _worldBuilder.directlyInstantiatedClasses 209 _worldBuilder.directlyInstantiatedClasses
210 .where(computeClassFilter()) 210 .where(computeClassFilter())
211 .toSet(); 211 .toSet();
212 212
213 void addClassWithSuperclasses(ClassElement cls) { 213 void addClassWithSuperclasses(ClassElement cls) {
214 neededClasses.add(cls); 214 neededClasses.add(cls);
215 for (ClassElement superclass = cls.superclass; 215 for (ClassElement superclass = cls.superclass;
216 superclass != null; 216 superclass != null;
217 superclass = superclass.superclass) { 217 superclass = superclass.superclass) {
218 neededClasses.add(superclass); 218 neededClasses.add(superclass);
219 } 219 }
220 } 220 }
221 221
222 void addClassesWithSuperclasses(Iterable<ClassElement> classes) { 222 void addClassesWithSuperclasses(Iterable<ClassEntity> classes) {
223 for (ClassElement cls in classes) { 223 for (ClassElement cls in classes) {
224 addClassWithSuperclasses(cls); 224 addClassWithSuperclasses(cls);
225 } 225 }
226 } 226 }
227 227
228 // 1. We need to generate all classes that are instantiated. 228 // 1. We need to generate all classes that are instantiated.
229 addClassesWithSuperclasses(instantiatedClasses); 229 addClassesWithSuperclasses(instantiatedClasses);
230 230
231 // 2. Add all classes used as mixins. 231 // 2. Add all classes used as mixins.
232 Set<ClassElement> mixinClasses = neededClasses 232 Set<ClassElement> mixinClasses = neededClasses
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } 355 }
356 356
357 void collect() { 357 void collect() {
358 computeNeededDeclarations(); 358 computeNeededDeclarations();
359 computeNeededConstants(); 359 computeNeededConstants();
360 computeNeededStatics(); 360 computeNeededStatics();
361 computeNeededStaticNonFinalFields(); 361 computeNeededStaticNonFinalFields();
362 computeNeededLibraries(); 362 computeNeededLibraries();
363 } 363 }
364 } 364 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/resolution_listener.dart ('k') | pkg/compiler/lib/src/js_emitter/type_test_registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698