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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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<ClassEntity> computeInterceptorsReferencedFromConstants() { | 73 Set<ClassElement> computeInterceptorsReferencedFromConstants() { |
74 Set<ClassEntity> classes = new Set<ClassEntity>(); | 74 Set<ClassElement> classes = new Set<ClassElement>(); |
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 Loading... |
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((FieldEntity field) { | 324 _worldBuilder.allReferencedStaticFields.where((FieldElement field) { |
325 if (!field.isConst) { | 325 if (!field.isConst) { |
326 return field.isAssignable && | 326 return field.isField && |
327 _worldBuilder.hasConstantFieldInitializer(field); | 327 !field.isInstanceMember && |
| 328 !field.isFinal && |
| 329 field.constant != null; |
328 } else { | 330 } else { |
329 // We also need to emit static const fields if they are available for | 331 // We also need to emit static const fields if they are available for |
330 // reflection. | 332 // reflection. |
331 return _mirrorsData.isMemberAccessibleByReflection(field); | 333 return _mirrorsData.isMemberAccessibleByReflection(field); |
332 } | 334 } |
333 }); | 335 }); |
334 | 336 |
335 _sorter.sortMembers(fields).forEach((MemberEntity e) => addToOutputUnit(e)); | 337 _sorter.sortMembers(fields).forEach((MemberEntity e) => addToOutputUnit(e)); |
336 } | 338 } |
337 | 339 |
(...skipping 15 matching lines...) Expand all Loading... |
353 } | 355 } |
354 | 356 |
355 void collect() { | 357 void collect() { |
356 computeNeededDeclarations(); | 358 computeNeededDeclarations(); |
357 computeNeededConstants(); | 359 computeNeededConstants(); |
358 computeNeededStatics(); | 360 computeNeededStatics(); |
359 computeNeededStaticNonFinalFields(); | 361 computeNeededStaticNonFinalFields(); |
360 computeNeededLibraries(); | 362 computeNeededLibraries(); |
361 } | 363 } |
362 } | 364 } |
OLD | NEW |