| 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 * Compute all the constants that must be emitted. | 131 * Compute all the constants that must be emitted. |
| 132 */ | 132 */ |
| 133 void computeNeededConstants() { | 133 void computeNeededConstants() { |
| 134 // Make sure we retain all metadata of all elements. This could add new | 134 // Make sure we retain all metadata of all elements. This could add new |
| 135 // constants to the handler. | 135 // constants to the handler. |
| 136 if (_mirrorsData.mustRetainMetadata) { | 136 if (_mirrorsData.mustRetainMetadata) { |
| 137 // TODO(floitsch): verify that we don't run through the same elements | 137 // TODO(floitsch): verify that we don't run through the same elements |
| 138 // multiple times. | 138 // multiple times. |
| 139 for (MemberElement element in _generatedCode.keys) { | 139 for (MemberElement element in _generatedCode.keys) { |
| 140 if (_mirrorsData.isMemberAccessibleByReflection(element)) { | 140 if (_mirrorsData.isMemberAccessibleByReflection(element)) { |
| 141 bool shouldRetainMetadata = | 141 _mirrorsData.retainMetadataOfMember(element); |
| 142 _mirrorsData.retainMetadataOfMember(element); | |
| 143 if (shouldRetainMetadata && | |
| 144 (element.isFunction || | |
| 145 element.isConstructor || | |
| 146 element.isSetter)) { | |
| 147 MethodElement function = element; | |
| 148 function.functionSignature.forEachParameter((parameter) => | |
| 149 _mirrorsData.retainMetadataOfParameter(parameter)); | |
| 150 } | |
| 151 } | 142 } |
| 152 } | 143 } |
| 153 for (ClassElement cls in neededClasses) { | 144 for (ClassElement cls in neededClasses) { |
| 154 final onlyForRti = classesOnlyNeededForRti.contains(cls); | 145 final onlyForRti = classesOnlyNeededForRti.contains(cls); |
| 155 if (!onlyForRti) { | 146 if (!onlyForRti) { |
| 156 _mirrorsData.retainMetadataOfClass(cls); | 147 _mirrorsData.retainMetadataOfClass(cls); |
| 157 new FieldVisitor(_options, _elementEnvironment, _worldBuilder, | 148 new FieldVisitor(_options, _elementEnvironment, _worldBuilder, |
| 158 _nativeData, _mirrorsData, _namer, _closedWorld) | 149 _nativeData, _mirrorsData, _namer, _closedWorld) |
| 159 .visitFields((FieldEntity member, | 150 .visitFields((FieldEntity member, |
| 160 js.Name name, | 151 js.Name name, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 343 } |
| 353 | 344 |
| 354 void collect() { | 345 void collect() { |
| 355 computeNeededDeclarations(); | 346 computeNeededDeclarations(); |
| 356 computeNeededConstants(); | 347 computeNeededConstants(); |
| 357 computeNeededStatics(); | 348 computeNeededStatics(); |
| 358 computeNeededStaticNonFinalFields(); | 349 computeNeededStaticNonFinalFields(); |
| 359 computeNeededLibraries(); | 350 computeNeededLibraries(); |
| 360 } | 351 } |
| 361 } | 352 } |
| OLD | NEW |