OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 deferred_load; | 5 library deferred_load; |
6 | 6 |
7 import 'common/tasks.dart' show CompilerTask; | 7 import 'common/tasks.dart' show CompilerTask; |
8 import 'common.dart'; | 8 import 'common.dart'; |
9 import 'compiler.dart' show Compiler; | 9 import 'compiler.dart' show Compiler; |
10 import 'constants/expressions.dart' show ConstantExpression; | 10 import 'constants/expressions.dart' show ConstantExpression; |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 /// The elements are added with [_mapDependencies]. | 585 /// The elements are added with [_mapDependencies]. |
586 void _addMirrorElements() { | 586 void _addMirrorElements() { |
587 void mapDependenciesIfResolved( | 587 void mapDependenciesIfResolved( |
588 Element element, _DeferredImport deferredImport) { | 588 Element element, _DeferredImport deferredImport) { |
589 // If an element is the target of a MirrorsUsed annotation but never used | 589 // If an element is the target of a MirrorsUsed annotation but never used |
590 // It will not be resolved, and we should not call isNeededForReflection. | 590 // It will not be resolved, and we should not call isNeededForReflection. |
591 // TODO(sigurdm): Unresolved elements should just answer false when | 591 // TODO(sigurdm): Unresolved elements should just answer false when |
592 // asked isNeededForReflection. Instead an internal error is triggered. | 592 // asked isNeededForReflection. Instead an internal error is triggered. |
593 // So we have to filter them out here. | 593 // So we have to filter them out here. |
594 if (element is AnalyzableElementX && !element.hasTreeElements) return; | 594 if (element is AnalyzableElementX && !element.hasTreeElements) return; |
595 if (compiler.backend.mirrorsData.isAccessibleByReflection(element)) { | 595 |
| 596 bool isAccessibleByReflection(Element element) { |
| 597 if (element.isLibrary) { |
| 598 return false; |
| 599 } else if (element.isClass) { |
| 600 ClassElement cls = element; |
| 601 return compiler.backend.mirrorsData |
| 602 .isClassAccessibleByReflection(cls); |
| 603 } else if (element.isTypedef) { |
| 604 TypedefElement typedef = element; |
| 605 return compiler.backend.mirrorsData |
| 606 .isTypedefAccessibleByReflection(typedef); |
| 607 } else { |
| 608 MemberElement member = element; |
| 609 return compiler.backend.mirrorsData |
| 610 .isMemberAccessibleByReflection(member); |
| 611 } |
| 612 } |
| 613 |
| 614 if (isAccessibleByReflection(element)) { |
596 _mapDependencies( | 615 _mapDependencies( |
597 element: element, import: deferredImport, isMirrorUsage: true); | 616 element: element, import: deferredImport, isMirrorUsage: true); |
598 } | 617 } |
599 } | 618 } |
600 | 619 |
601 // For each deferred import we analyze all elements reachable from the | 620 // For each deferred import we analyze all elements reachable from the |
602 // imported library through non-deferred imports. | 621 // imported library through non-deferred imports. |
603 void handleLibrary(LibraryElement library, _DeferredImport deferredImport) { | 622 void handleLibrary(LibraryElement library, _DeferredImport deferredImport) { |
604 library.implementation.forEachLocalMember((Element element) { | 623 library.implementation.forEachLocalMember((Element element) { |
605 mapDependenciesIfResolved(element, deferredImport); | 624 mapDependenciesIfResolved(element, deferredImport); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 | 1122 |
1104 bool operator ==(other) { | 1123 bool operator ==(other) { |
1105 if (other is! _DeclaredDeferredImport) return false; | 1124 if (other is! _DeclaredDeferredImport) return false; |
1106 return declaration == other.declaration; | 1125 return declaration == other.declaration; |
1107 } | 1126 } |
1108 | 1127 |
1109 int get hashCode => declaration.hashCode * 17; | 1128 int get hashCode => declaration.hashCode * 17; |
1110 | 1129 |
1111 String toString() => '$declaration'; | 1130 String toString() => '$declaration'; |
1112 } | 1131 } |
OLD | NEW |