| 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 13 matching lines...) Expand all Loading... |
| 24 Elements, | 24 Elements, |
| 25 ExportElement, | 25 ExportElement, |
| 26 FunctionElement, | 26 FunctionElement, |
| 27 ImportElement, | 27 ImportElement, |
| 28 LibraryElement, | 28 LibraryElement, |
| 29 MetadataAnnotation, | 29 MetadataAnnotation, |
| 30 PrefixElement, | 30 PrefixElement, |
| 31 ResolvedAstKind, | 31 ResolvedAstKind, |
| 32 TypedefElement; | 32 TypedefElement; |
| 33 import 'js_backend/js_backend.dart' show JavaScriptBackend; | 33 import 'js_backend/js_backend.dart' show JavaScriptBackend; |
| 34 import 'js_backend/backend_usage.dart' show BackendUsage; |
| 34 import 'resolution/resolution.dart' show AnalyzableElementX; | 35 import 'resolution/resolution.dart' show AnalyzableElementX; |
| 35 import 'resolution/tree_elements.dart' show TreeElements; | 36 import 'resolution/tree_elements.dart' show TreeElements; |
| 36 import 'tree/tree.dart' as ast; | 37 import 'tree/tree.dart' as ast; |
| 37 import 'universe/use.dart' show StaticUse, StaticUseKind, TypeUse, TypeUseKind; | 38 import 'universe/use.dart' show StaticUse, StaticUseKind, TypeUse, TypeUseKind; |
| 38 import 'universe/world_impact.dart' | 39 import 'universe/world_impact.dart' |
| 39 show ImpactUseCase, WorldImpact, WorldImpactVisitorImpl; | 40 show ImpactUseCase, WorldImpact, WorldImpactVisitorImpl; |
| 40 import 'util/setlet.dart' show Setlet; | 41 import 'util/setlet.dart' show Setlet; |
| 41 import 'util/uri_extras.dart' as uri_extras; | 42 import 'util/uri_extras.dart' as uri_extras; |
| 42 import 'util/util.dart' show makeUnique; | 43 import 'util/util.dart' show makeUnique; |
| 43 | 44 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 152 |
| 152 final Compiler compiler; | 153 final Compiler compiler; |
| 153 DeferredLoadTask(Compiler compiler) | 154 DeferredLoadTask(Compiler compiler) |
| 154 : compiler = compiler, | 155 : compiler = compiler, |
| 155 super(compiler.measurer) { | 156 super(compiler.measurer) { |
| 156 mainOutputUnit.imports.add(_fakeMainImport); | 157 mainOutputUnit.imports.add(_fakeMainImport); |
| 157 } | 158 } |
| 158 | 159 |
| 159 JavaScriptBackend get backend => compiler.backend; | 160 JavaScriptBackend get backend => compiler.backend; |
| 160 DiagnosticReporter get reporter => compiler.reporter; | 161 DiagnosticReporter get reporter => compiler.reporter; |
| 162 BackendUsage get _backendUsage => backend.backendUsage; |
| 161 | 163 |
| 162 /// Returns the [OutputUnit] where [element] belongs. | 164 /// Returns the [OutputUnit] where [element] belongs. |
| 163 OutputUnit outputUnitForElement(Element element) { | 165 OutputUnit outputUnitForElement(Element element) { |
| 164 if (!isProgramSplit) return mainOutputUnit; | 166 if (!isProgramSplit) return mainOutputUnit; |
| 165 | 167 |
| 166 element = element.implementation; | 168 element = element.implementation; |
| 167 while (!_elementToOutputUnit.containsKey(element)) { | 169 while (!_elementToOutputUnit.containsKey(element)) { |
| 168 // TODO(21051): workaround: it looks like we output annotation constants | 170 // TODO(21051): workaround: it looks like we output annotation constants |
| 169 // for classes that we don't include in the output. This seems to happen | 171 // for classes that we don't include in the output. This seems to happen |
| 170 // when we have reflection but can see that some classes are not needed. | 172 // when we have reflection but can see that some classes are not needed. |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 () => measure(() { | 675 () => measure(() { |
| 674 // Starting from main, traverse the program and find all | 676 // Starting from main, traverse the program and find all |
| 675 // dependencies. | 677 // dependencies. |
| 676 _mapDependencies( | 678 _mapDependencies( |
| 677 element: compiler.mainFunction, import: _fakeMainImport); | 679 element: compiler.mainFunction, import: _fakeMainImport); |
| 678 | 680 |
| 679 // Also add "global" dependencies to the main OutputUnit. These | 681 // Also add "global" dependencies to the main OutputUnit. These |
| 680 // are things that the backend needs but cannot associate with a | 682 // are things that the backend needs but cannot associate with a |
| 681 // particular element, for example, startRootIsolate. This set | 683 // particular element, for example, startRootIsolate. This set |
| 682 // also contains elements for which we lack precise information. | 684 // also contains elements for which we lack precise information. |
| 683 for (Element element in backend.backendUsage.globalDependencies) { | 685 for (Element element in _backendUsage.globalDependencies) { |
| 684 _mapDependencies(element: element, import: _fakeMainImport); | 686 _mapDependencies(element: element, import: _fakeMainImport); |
| 685 } | 687 } |
| 686 | 688 |
| 687 // Now check to see if we have to add more elements due to | 689 // Now check to see if we have to add more elements due to |
| 688 // mirrors. | 690 // mirrors. |
| 689 if (compiler.commonElements.mirrorsLibrary != null) { | 691 if (compiler.commonElements.mirrorsLibrary != null) { |
| 690 _addMirrorElements(); | 692 _addMirrorElements(); |
| 691 } | 693 } |
| 692 | 694 |
| 693 // Build the OutputUnits using these two maps. | 695 // Build the OutputUnits using these two maps. |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 | 1052 |
| 1051 bool operator ==(other) { | 1053 bool operator ==(other) { |
| 1052 if (other is! _DeclaredDeferredImport) return false; | 1054 if (other is! _DeclaredDeferredImport) return false; |
| 1053 return declaration == other.declaration; | 1055 return declaration == other.declaration; |
| 1054 } | 1056 } |
| 1055 | 1057 |
| 1056 int get hashCode => declaration.hashCode * 17; | 1058 int get hashCode => declaration.hashCode * 17; |
| 1057 | 1059 |
| 1058 String toString() => '$declaration'; | 1060 String toString() => '$declaration'; |
| 1059 } | 1061 } |
| OLD | NEW |