| 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 as Iterable<LibraryElement>) | 123 _compiler.libraryLoader.libraries.forEach(_mirrorsData.retainMetadataOf); |
| 124 .forEach(_mirrorsData.retainMetadataOf); | |
| 125 | 124 |
| 126 if (!enqueuer.queueIsClosed) { | 125 if (!enqueuer.queueIsClosed) { |
| 127 /// Register the constant value of [metadata] as live in resolution. | 126 /// Register the constant value of [metadata] as live in resolution. |
| 128 void registerMetadataConstant(MetadataAnnotation metadata) { | 127 void registerMetadataConstant(MetadataAnnotation metadata) { |
| 129 ConstantValue constant = | 128 ConstantValue constant = |
| 130 _constants.getConstantValueForMetadata(metadata); | 129 _constants.getConstantValueForMetadata(metadata); |
| 131 Dependency dependency = | 130 Dependency dependency = |
| 132 new Dependency(constant, metadata.annotatedElement); | 131 new Dependency(constant, metadata.annotatedElement); |
| 133 _metadataConstants.add(dependency); | 132 _metadataConstants.add(dependency); |
| 134 _impactBuilder.registerConstantUse(new ConstantUse.mirrors(constant)); | 133 _impactBuilder.registerConstantUse(new ConstantUse.mirrors(constant)); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 if (_mirrorsData.isTreeShakingDisabled) { | 236 if (_mirrorsData.isTreeShakingDisabled) { |
| 238 enqueuer.applyImpact(_computeImpactForReflectiveElements(recentClasses, | 237 enqueuer.applyImpact(_computeImpactForReflectiveElements(recentClasses, |
| 239 enqueuer.processedClasses, _compiler.libraryLoader.libraries)); | 238 enqueuer.processedClasses, _compiler.libraryLoader.libraries)); |
| 240 } | 239 } |
| 241 | 240 |
| 242 if (_mirrorsData.mustPreserveNames) _reporter.log('Preserving names.'); | 241 if (_mirrorsData.mustPreserveNames) _reporter.log('Preserving names.'); |
| 243 | 242 |
| 244 if (_mirrorsData.mustRetainMetadata) { | 243 if (_mirrorsData.mustRetainMetadata) { |
| 245 _reporter.log('Retaining metadata.'); | 244 _reporter.log('Retaining metadata.'); |
| 246 | 245 |
| 247 (_compiler.libraryLoader.libraries as Iterable<LibraryElement>) | 246 _compiler.libraryLoader.libraries.forEach(_mirrorsData.retainMetadataOf); |
| 248 .forEach(_mirrorsData.retainMetadataOf); | |
| 249 | 247 |
| 250 for (Dependency dependency in _metadataConstants) { | 248 for (Dependency dependency in _metadataConstants) { |
| 251 _impactBuilder | 249 _impactBuilder |
| 252 .registerConstantUse(new ConstantUse.mirrors(dependency.constant)); | 250 .registerConstantUse(new ConstantUse.mirrors(dependency.constant)); |
| 253 } | 251 } |
| 254 _metadataConstants.clear(); | 252 _metadataConstants.clear(); |
| 255 enqueuer.applyImpact(_impactBuilder.flush()); | 253 enqueuer.applyImpact(_impactBuilder.flush()); |
| 256 } | 254 } |
| 257 } | 255 } |
| 258 } | 256 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 468 |
| 471 /// Records that [constant] is used by the element behind [registry]. | 469 /// Records that [constant] is used by the element behind [registry]. |
| 472 class Dependency { | 470 class Dependency { |
| 473 final ConstantValue constant; | 471 final ConstantValue constant; |
| 474 final Element annotatedElement; | 472 final Element annotatedElement; |
| 475 | 473 |
| 476 const Dependency(this.constant, this.annotatedElement); | 474 const Dependency(this.constant, this.annotatedElement); |
| 477 | 475 |
| 478 String toString() => '$annotatedElement:${constant.toStructuredText()}'; | 476 String toString() => '$annotatedElement:${constant.toStructuredText()}'; |
| 479 } | 477 } |
| OLD | NEW |