OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 library dart2js.mirrors_handler; | 5 library dart2js.mirrors_handler; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/resolution.dart'; | 8 import '../common/resolution.dart'; |
9 import '../compiler.dart'; | 9 import '../compiler.dart'; |
10 import '../constants/values.dart'; | 10 import '../constants/values.dart'; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // necessary, but the backend relies on them being resolved. | 113 // necessary, but the backend relies on them being resolved. |
114 enqueuer.applyImpact( | 114 enqueuer.applyImpact( |
115 _computeImpactForReflectiveStaticFields(_findStaticFieldTargets())); | 115 _computeImpactForReflectiveStaticFields(_findStaticFieldTargets())); |
116 } | 116 } |
117 | 117 |
118 if (_mirrorsData.mustPreserveNames) _reporter.log('Preserving names.'); | 118 if (_mirrorsData.mustPreserveNames) _reporter.log('Preserving names.'); |
119 | 119 |
120 if (_mirrorsData.mustRetainMetadata) { | 120 if (_mirrorsData.mustRetainMetadata) { |
121 _reporter.log('Retaining metadata.'); | 121 _reporter.log('Retaining metadata.'); |
122 | 122 |
123 _compiler.libraryLoader.libraries.forEach(_mirrorsData.retainMetadataOf); | 123 (_compiler.libraryLoader.libraries as Iterable<LibraryElement>) |
| 124 .forEach(_mirrorsData.retainMetadataOf); |
124 | 125 |
125 if (!enqueuer.queueIsClosed) { | 126 if (!enqueuer.queueIsClosed) { |
126 /// Register the constant value of [metadata] as live in resolution. | 127 /// Register the constant value of [metadata] as live in resolution. |
127 void registerMetadataConstant(MetadataAnnotation metadata) { | 128 void registerMetadataConstant(MetadataAnnotation metadata) { |
128 ConstantValue constant = | 129 ConstantValue constant = |
129 _constants.getConstantValueForMetadata(metadata); | 130 _constants.getConstantValueForMetadata(metadata); |
130 Dependency dependency = | 131 Dependency dependency = |
131 new Dependency(constant, metadata.annotatedElement); | 132 new Dependency(constant, metadata.annotatedElement); |
132 _metadataConstants.add(dependency); | 133 _metadataConstants.add(dependency); |
133 _impactBuilder.registerConstantUse(new ConstantUse.mirrors(constant)); | 134 _impactBuilder.registerConstantUse(new ConstantUse.mirrors(constant)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (_mirrorsData.isTreeShakingDisabled) { | 237 if (_mirrorsData.isTreeShakingDisabled) { |
237 enqueuer.applyImpact(_computeImpactForReflectiveElements(recentClasses, | 238 enqueuer.applyImpact(_computeImpactForReflectiveElements(recentClasses, |
238 enqueuer.processedClasses, _compiler.libraryLoader.libraries)); | 239 enqueuer.processedClasses, _compiler.libraryLoader.libraries)); |
239 } | 240 } |
240 | 241 |
241 if (_mirrorsData.mustPreserveNames) _reporter.log('Preserving names.'); | 242 if (_mirrorsData.mustPreserveNames) _reporter.log('Preserving names.'); |
242 | 243 |
243 if (_mirrorsData.mustRetainMetadata) { | 244 if (_mirrorsData.mustRetainMetadata) { |
244 _reporter.log('Retaining metadata.'); | 245 _reporter.log('Retaining metadata.'); |
245 | 246 |
246 _compiler.libraryLoader.libraries.forEach(_mirrorsData.retainMetadataOf); | 247 (_compiler.libraryLoader.libraries as Iterable<LibraryElement>) |
| 248 .forEach(_mirrorsData.retainMetadataOf); |
247 | 249 |
248 for (Dependency dependency in _metadataConstants) { | 250 for (Dependency dependency in _metadataConstants) { |
249 _impactBuilder | 251 _impactBuilder |
250 .registerConstantUse(new ConstantUse.mirrors(dependency.constant)); | 252 .registerConstantUse(new ConstantUse.mirrors(dependency.constant)); |
251 } | 253 } |
252 _metadataConstants.clear(); | 254 _metadataConstants.clear(); |
253 enqueuer.applyImpact(_impactBuilder.flush()); | 255 enqueuer.applyImpact(_impactBuilder.flush()); |
254 } | 256 } |
255 } | 257 } |
256 } | 258 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 470 |
469 /// Records that [constant] is used by the element behind [registry]. | 471 /// Records that [constant] is used by the element behind [registry]. |
470 class Dependency { | 472 class Dependency { |
471 final ConstantValue constant; | 473 final ConstantValue constant; |
472 final Element annotatedElement; | 474 final Element annotatedElement; |
473 | 475 |
474 const Dependency(this.constant, this.annotatedElement); | 476 const Dependency(this.constant, this.annotatedElement); |
475 | 477 |
476 String toString() => '$annotatedElement:${constant.toStructuredText()}'; | 478 String toString() => '$annotatedElement:${constant.toStructuredText()}'; |
477 } | 479 } |
OLD | NEW |