| 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 AnalyzableElementX; | 57 AnalyzableElement; |
| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 /// Adds extra dependencies coming from mirror usage. | 449 /// Adds extra dependencies coming from mirror usage. |
| 450 /// | 450 /// |
| 451 /// The elements are added with [_mapDependencies]. | 451 /// The elements are added with [_mapDependencies]. |
| 452 void _addMirrorElements() { | 452 void _addMirrorElements() { |
| 453 void mapDependenciesIfResolved(Element element, Import deferredImport) { | 453 void mapDependenciesIfResolved(Element element, Import deferredImport) { |
| 454 // If an element is the target of a MirrorsUsed annotation but never used | 454 // If an element is the target of a MirrorsUsed annotation but never used |
| 455 // It will not be resolved, and we should not call isNeededForReflection. | 455 // It will not be resolved, and we should not call isNeededForReflection. |
| 456 // TODO(sigurdm): Unresolved elements should just answer false when | 456 // TODO(sigurdm): Unresolved elements should just answer false when |
| 457 // asked isNeededForReflection. Instead an internal error is triggered. | 457 // asked isNeededForReflection. Instead an internal error is triggered. |
| 458 // So we have to filter them out here. | 458 // So we have to filter them out here. |
| 459 if (element is AnalyzableElementX && !element.hasTreeElements) return; | 459 if (element is AnalyzableElement && !element.hasTreeElements) return; |
| 460 if (compiler.backend.isNeededForReflection(element)) { | 460 if (compiler.backend.isNeededForReflection(element)) { |
| 461 _mapDependencies(element, deferredImport); | 461 _mapDependencies(element, deferredImport); |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 | 464 |
| 465 // For each deferred import we analyze all elements reachable from the | 465 // For each deferred import we analyze all elements reachable from the |
| 466 // imported library through non-deferred imports. | 466 // imported library through non-deferred imports. |
| 467 handleLibrary(LibraryElement library, Import deferredImport) { | 467 handleLibrary(LibraryElement library, Import deferredImport) { |
| 468 library.implementation.forEachLocalMember((Element element) { | 468 library.implementation.forEachLocalMember((Element element) { |
| 469 mapDependenciesIfResolved(element, deferredImport); | 469 mapDependenciesIfResolved(element, deferredImport); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 Element maybePrefix = elements[identifier]; | 783 Element maybePrefix = elements[identifier]; |
| 784 if (maybePrefix != null && maybePrefix.isPrefix) { | 784 if (maybePrefix != null && maybePrefix.isPrefix) { |
| 785 PrefixElement prefixElement = maybePrefix; | 785 PrefixElement prefixElement = maybePrefix; |
| 786 if (prefixElement.isDeferred) { | 786 if (prefixElement.isDeferred) { |
| 787 return prefixElement; | 787 return prefixElement; |
| 788 } | 788 } |
| 789 } | 789 } |
| 790 return null; | 790 return null; |
| 791 } | 791 } |
| 792 } | 792 } |
| OLD | NEW |