| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 NewExpression, | 47 NewExpression, |
| 48 Import, | 48 Import, |
| 49 LibraryDependency, | 49 LibraryDependency, |
| 50 LiteralString, | 50 LiteralString, |
| 51 LiteralDartString; | 51 LiteralDartString; |
| 52 | 52 |
| 53 import 'tree/tree.dart' as ast; | 53 import 'tree/tree.dart' as ast; |
| 54 | 54 |
| 55 import 'resolution/resolution.dart' show | 55 import 'resolution/resolution.dart' show |
| 56 TreeElements, | 56 TreeElements, |
| 57 AnalyzableElement; | 57 AnalyzableElementX; |
| 58 | 58 |
| 59 /// A "hunk" of the program that will be loaded whenever one of its [imports] | 59 /// A "hunk" of the program that will be loaded whenever one of its [imports] |
| 60 /// are loaded. | 60 /// are loaded. |
| 61 /// | 61 /// |
| 62 /// Elements that are only used in one deferred import, is in an OutputUnit with | 62 /// Elements that are only used in one deferred import, is in an OutputUnit with |
| 63 /// the deferred import as single element in the [imports] set. | 63 /// the deferred import as single element in the [imports] set. |
| 64 /// | 64 /// |
| 65 /// Whenever a deferred Element is shared between several deferred imports it is | 65 /// Whenever a deferred Element is shared between several deferred imports it is |
| 66 /// in an output unit with those imports in the [imports] Set. | 66 /// in an output unit with those imports in the [imports] Set. |
| 67 /// | 67 /// |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 /// Adds extra dependencies coming from mirror usage. | 445 /// Adds extra dependencies coming from mirror usage. |
| 446 /// | 446 /// |
| 447 /// The elements are added with [_mapDependencies]. | 447 /// The elements are added with [_mapDependencies]. |
| 448 void _addMirrorElements() { | 448 void _addMirrorElements() { |
| 449 void mapDependenciesIfResolved(Element element, Import deferredImport) { | 449 void mapDependenciesIfResolved(Element element, Import deferredImport) { |
| 450 // If an element is the target of a MirrorsUsed annotation but never used | 450 // If an element is the target of a MirrorsUsed annotation but never used |
| 451 // It will not be resolved, and we should not call isNeededForReflection. | 451 // It will not be resolved, and we should not call isNeededForReflection. |
| 452 // TODO(sigurdm): Unresolved elements should just answer false when | 452 // TODO(sigurdm): Unresolved elements should just answer false when |
| 453 // asked isNeededForReflection. Instead an internal error is triggered. | 453 // asked isNeededForReflection. Instead an internal error is triggered. |
| 454 // So we have to filter them out here. | 454 // So we have to filter them out here. |
| 455 if (element is AnalyzableElement && !element.hasTreeElements) return; | 455 if (element is AnalyzableElementX && !element.hasTreeElements) return; |
| 456 if (compiler.backend.isNeededForReflection(element)) { | 456 if (compiler.backend.isNeededForReflection(element)) { |
| 457 _mapDependencies(element, deferredImport); | 457 _mapDependencies(element, deferredImport); |
| 458 } | 458 } |
| 459 } | 459 } |
| 460 | 460 |
| 461 // For each deferred import we analyze all elements reachable from the | 461 // For each deferred import we analyze all elements reachable from the |
| 462 // imported library through non-deferred imports. | 462 // imported library through non-deferred imports. |
| 463 handleLibrary(LibraryElement library, Import deferredImport) { | 463 handleLibrary(LibraryElement library, Import deferredImport) { |
| 464 library.implementation.forEachLocalMember((Element element) { | 464 library.implementation.forEachLocalMember((Element element) { |
| 465 mapDependenciesIfResolved(element, deferredImport); | 465 mapDependenciesIfResolved(element, deferredImport); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 Element maybePrefix = elements[identifier]; | 779 Element maybePrefix = elements[identifier]; |
| 780 if (maybePrefix != null && maybePrefix.isPrefix) { | 780 if (maybePrefix != null && maybePrefix.isPrefix) { |
| 781 PrefixElement prefixElement = maybePrefix; | 781 PrefixElement prefixElement = maybePrefix; |
| 782 if (prefixElement.isDeferred) { | 782 if (prefixElement.isDeferred) { |
| 783 return prefixElement; | 783 return prefixElement; |
| 784 } | 784 } |
| 785 } | 785 } |
| 786 return null; | 786 return null; |
| 787 } | 787 } |
| 788 } | 788 } |
| OLD | NEW |