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

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

Issue 2939033002: Towards compiling Hello World! (Closed)
Patch Set: Fix parameter ordering Created 3 years, 6 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 this._constantHandler, 63 this._constantHandler,
64 this._nativeData, 64 this._nativeData,
65 this._interceptorData, 65 this._interceptorData,
66 this._oneShotInterceptorData, 66 this._oneShotInterceptorData,
67 this._mirrorsData, 67 this._mirrorsData,
68 this._closedWorld, 68 this._closedWorld,
69 this._rtiNeededClasses, 69 this._rtiNeededClasses,
70 this._generatedCode, 70 this._generatedCode,
71 this._sorter); 71 this._sorter);
72 72
73 Set<ClassElement> computeInterceptorsReferencedFromConstants() { 73 Set<ClassEntity> computeInterceptorsReferencedFromConstants() {
74 Set<ClassElement> classes = new Set<ClassElement>(); 74 Set<ClassEntity> classes = new Set<ClassEntity>();
75 List<ConstantValue> constants = _worldBuilder.getConstantsForEmission(); 75 List<ConstantValue> constants = _worldBuilder.getConstantsForEmission();
76 for (ConstantValue constant in constants) { 76 for (ConstantValue constant in constants) {
77 if (constant is InterceptorConstantValue) { 77 if (constant is InterceptorConstantValue) {
78 InterceptorConstantValue interceptorConstant = constant; 78 InterceptorConstantValue interceptorConstant = constant;
79 classes.add(interceptorConstant.cls); 79 classes.add(interceptorConstant.cls);
80 } 80 }
81 } 81 }
82 return classes; 82 return classes;
83 } 83 }
84 84
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 List<FieldEntity> list = outputStaticNonFinalFieldLists.putIfAbsent( 314 List<FieldEntity> list = outputStaticNonFinalFieldLists.putIfAbsent(
315 // ignore: UNNECESSARY_CAST 315 // ignore: UNNECESSARY_CAST
316 _deferredLoadTask.outputUnitForMember(element as MemberEntity), 316 _deferredLoadTask.outputUnitForMember(element as MemberEntity),
317 () => new List<FieldEntity>()); 317 () => new List<FieldEntity>());
318 list.add(element); 318 list.add(element);
319 } 319 }
320 320
321 Iterable<FieldEntity> fields = 321 Iterable<FieldEntity> fields =
322 // TODO(johnniwinther): This should be accessed from a codegen closed 322 // TODO(johnniwinther): This should be accessed from a codegen closed
323 // world. 323 // world.
324 _worldBuilder.allReferencedStaticFields.where((FieldElement field) { 324 _worldBuilder.allReferencedStaticFields.where((FieldEntity field) {
325 if (!field.isConst) { 325 if (!field.isConst) {
326 return field.isField && 326 return field.isAssignable &&
327 !field.isInstanceMember && 327 _worldBuilder.hasConstantFieldInitializer(field);
328 !field.isFinal &&
329 field.constant != null;
330 } else { 328 } else {
331 // We also need to emit static const fields if they are available for 329 // We also need to emit static const fields if they are available for
332 // reflection. 330 // reflection.
333 return _mirrorsData.isMemberAccessibleByReflection(field); 331 return _mirrorsData.isMemberAccessibleByReflection(field);
334 } 332 }
335 }); 333 });
336 334
337 _sorter.sortMembers(fields).forEach((MemberEntity e) => addToOutputUnit(e)); 335 _sorter.sortMembers(fields).forEach((MemberEntity e) => addToOutputUnit(e));
338 } 336 }
339 337
(...skipping 15 matching lines...) Expand all
355 } 353 }
356 354
357 void collect() { 355 void collect() {
358 computeNeededDeclarations(); 356 computeNeededDeclarations();
359 computeNeededConstants(); 357 computeNeededConstants();
360 computeNeededStatics(); 358 computeNeededStatics();
361 computeNeededStaticNonFinalFields(); 359 computeNeededStaticNonFinalFields();
362 computeNeededLibraries(); 360 computeNeededLibraries();
363 } 361 }
364 } 362 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698