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 'dart2jslib.dart' show | 7 import 'dart2jslib.dart' show |
8 Backend, | 8 Backend, |
9 Compiler, | 9 Compiler, |
10 CompilerTask, | 10 CompilerTask, |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 /// | 464 /// |
465 /// The elements are added with [_mapDependencies]. | 465 /// The elements are added with [_mapDependencies]. |
466 void _addMirrorElements() { | 466 void _addMirrorElements() { |
467 void mapDependenciesIfResolved(Element element, Import deferredImport) { | 467 void mapDependenciesIfResolved(Element element, Import deferredImport) { |
468 // If an element is the target of a MirrorsUsed annotation but never used | 468 // If an element is the target of a MirrorsUsed annotation but never used |
469 // It will not be resolved, and we should not call isNeededForReflection. | 469 // It will not be resolved, and we should not call isNeededForReflection. |
470 // TODO(sigurdm): Unresolved elements should just answer false when | 470 // TODO(sigurdm): Unresolved elements should just answer false when |
471 // asked isNeededForReflection. Instead an internal error is triggered. | 471 // asked isNeededForReflection. Instead an internal error is triggered. |
472 // So we have to filter them out here. | 472 // So we have to filter them out here. |
473 if (element is AnalyzableElementX && !element.hasTreeElements) return; | 473 if (element is AnalyzableElementX && !element.hasTreeElements) return; |
474 if (compiler.backend.isNeededForReflection(element)) { | 474 if (compiler.backend.isAccessibleByReflection(element)) { |
475 _mapDependencies(element, deferredImport, isMirrorUsage: true); | 475 _mapDependencies(element, deferredImport, isMirrorUsage: true); |
476 } | 476 } |
477 } | 477 } |
478 | 478 |
479 // For each deferred import we analyze all elements reachable from the | 479 // For each deferred import we analyze all elements reachable from the |
480 // imported library through non-deferred imports. | 480 // imported library through non-deferred imports. |
481 handleLibrary(LibraryElement library, Import deferredImport) { | 481 handleLibrary(LibraryElement library, Import deferredImport) { |
482 library.implementation.forEachLocalMember((Element element) { | 482 library.implementation.forEachLocalMember((Element element) { |
483 mapDependenciesIfResolved(element, deferredImport); | 483 mapDependenciesIfResolved(element, deferredImport); |
484 }); | 484 }); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 Element maybePrefix = elements[identifier]; | 797 Element maybePrefix = elements[identifier]; |
798 if (maybePrefix != null && maybePrefix.isPrefix) { | 798 if (maybePrefix != null && maybePrefix.isPrefix) { |
799 PrefixElement prefixElement = maybePrefix; | 799 PrefixElement prefixElement = maybePrefix; |
800 if (prefixElement.isDeferred) { | 800 if (prefixElement.isDeferred) { |
801 return prefixElement; | 801 return prefixElement; |
802 } | 802 } |
803 } | 803 } |
804 return null; | 804 return null; |
805 } | 805 } |
806 } | 806 } |
OLD | NEW |