| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_used; | 5 library dart2js.mirrors_used; |
| 6 | 6 |
| 7 import 'dart2jslib.dart' show | 7 import 'dart2jslib.dart' show |
| 8 Compiler, | 8 Compiler, |
| 9 CompilerTask, | 9 CompilerTask, |
| 10 Constant, | 10 Constant, |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 symbols == null ? null : new Set<String>.from(symbols), | 113 symbols == null ? null : new Set<String>.from(symbols), |
| 114 targets == null ? null : new Set<Element>.from(targets), | 114 targets == null ? null : new Set<Element>.from(targets), |
| 115 metaTargets == null ? null : new Set<Element>.from(metaTargets)); | 115 metaTargets == null ? null : new Set<Element>.from(metaTargets)); |
| 116 librariesWithUsage = analyzer.librariesWithUsage; | 116 librariesWithUsage = analyzer.librariesWithUsage; |
| 117 } | 117 } |
| 118 | 118 |
| 119 /// Is there a @MirrorsUsed annotation in the library of [element]? Used by | 119 /// Is there a @MirrorsUsed annotation in the library of [element]? Used by |
| 120 /// the resolver to suppress hints about using new Symbol or | 120 /// the resolver to suppress hints about using new Symbol or |
| 121 /// MirrorSystem.getName. | 121 /// MirrorSystem.getName. |
| 122 bool hasMirrorUsage(Element element) { | 122 bool hasMirrorUsage(Element element) { |
| 123 return librariesWithUsage != null | 123 LibraryElement library = element.getLibrary(); |
| 124 && librariesWithUsage.contains(element.getLibrary()); | 124 // Internal libraries always have implicit mirror usage. |
| 125 return library.isInternalLibrary |
| 126 || (librariesWithUsage != null |
| 127 && librariesWithUsage.contains(library)); |
| 125 } | 128 } |
| 126 | 129 |
| 127 /// Call-back from the resolver to analyze MirorsUsed annotations. The result | 130 /// Call-back from the resolver to analyze MirorsUsed annotations. The result |
| 128 /// is stored in [analyzer] and later used to compute | 131 /// is stored in [analyzer] and later used to compute |
| 129 /// [:analyzer.mergedMirrorUsage:]. | 132 /// [:analyzer.mergedMirrorUsage:]. |
| 130 void validate(NewExpression node, TreeElements mapping) { | 133 void validate(NewExpression node, TreeElements mapping) { |
| 131 for (Node argument in node.send.arguments) { | 134 for (Node argument in node.send.arguments) { |
| 132 NamedArgument named = argument.asNamedArgument(); | 135 NamedArgument named = argument.asNamedArgument(); |
| 133 if (named == null) continue; | 136 if (named == null) continue; |
| 134 Constant value = compiler.metadataHandler.compileNodeWithDefinitions( | 137 Constant value = compiler.metadataHandler.compileNodeWithDefinitions( |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 // @MirrorsUsed(targets: fisk) | 586 // @MirrorsUsed(targets: fisk) |
| 584 // ^^^^ | 587 // ^^^^ |
| 585 // | 588 // |
| 586 // Instead of saying 'fisk' should pretty print the problematic constant | 589 // Instead of saying 'fisk' should pretty print the problematic constant |
| 587 // value. | 590 // value. |
| 588 return spannable; | 591 return spannable; |
| 589 } | 592 } |
| 590 return node; | 593 return node; |
| 591 } | 594 } |
| 592 } | 595 } |
| OLD | NEW |