| 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, |
| 11 Constant, | 11 Constant, |
| 12 ConstructedConstant, | 12 ConstructedConstant, |
| 13 MessageKind, | 13 MessageKind, |
| 14 DeferredConstant, |
| 14 StringConstant, | 15 StringConstant, |
| 15 invariant; | 16 invariant; |
| 16 | 17 |
| 17 import 'dart_backend/dart_backend.dart' show | 18 import 'dart_backend/dart_backend.dart' show |
| 18 DartBackend; | 19 DartBackend; |
| 19 | 20 |
| 20 import 'js_backend/js_backend.dart' show | 21 import 'js_backend/js_backend.dart' show |
| 21 JavaScriptBackend; | 22 JavaScriptBackend; |
| 22 | 23 |
| 23 import 'elements/elements.dart' show | 24 import 'elements/elements.dart' show |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 | 183 |
| 183 bool isDeferred(Element element) { | 184 bool isDeferred(Element element) { |
| 184 return outputUnitForElement(element) != mainOutputUnit; | 185 return outputUnitForElement(element) != mainOutputUnit; |
| 185 } | 186 } |
| 186 | 187 |
| 187 /// Returns true if e1 and e2 are in the same output unit. | 188 /// Returns true if e1 and e2 are in the same output unit. |
| 188 bool inSameOutputUnit(Element e1, Element e2) { | 189 bool inSameOutputUnit(Element e1, Element e2) { |
| 189 return outputUnitForElement(e1) == outputUnitForElement(e2); | 190 return outputUnitForElement(e1) == outputUnitForElement(e2); |
| 190 } | 191 } |
| 191 | 192 |
| 193 void registerConstantDeferredUse(DeferredConstant constant, |
| 194 PrefixElement prefix) { |
| 195 OutputUnit outputUnit = new OutputUnit(); |
| 196 outputUnit.imports.add(prefix.deferredImport); |
| 197 _constantToOutputUnit[constant] = outputUnit; |
| 198 } |
| 199 |
| 192 /// Mark that [import] is part of the [OutputputUnit] for [element]. | 200 /// Mark that [import] is part of the [OutputputUnit] for [element]. |
| 193 /// | 201 /// |
| 194 /// [element] can be either a [Constant] or an [Element]. | 202 /// [element] can be either a [Constant] or an [Element]. |
| 195 void _addImportToOutputUnitOfElement(Element element, Import import) { | 203 void _addImportToOutputUnitOfElement(Element element, Import import) { |
| 196 // Only one file should be loaded when the program starts, so make | 204 // Only one file should be loaded when the program starts, so make |
| 197 // sure that only one OutputUnit is created for [fakeMainImport]. | 205 // sure that only one OutputUnit is created for [fakeMainImport]. |
| 198 if (import == _fakeMainImport) { | 206 if (import == _fakeMainImport) { |
| 199 _elementToOutputUnit[element] = mainOutputUnit; | 207 _elementToOutputUnit[element] = mainOutputUnit; |
| 200 } | 208 } |
| 201 _elementToOutputUnit.putIfAbsent(element, () => new OutputUnit()) | 209 _elementToOutputUnit.putIfAbsent(element, () => new OutputUnit()) |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 Element maybePrefix = elements[identifier]; | 779 Element maybePrefix = elements[identifier]; |
| 772 if (maybePrefix != null && maybePrefix.isPrefix) { | 780 if (maybePrefix != null && maybePrefix.isPrefix) { |
| 773 PrefixElement prefixElement = maybePrefix; | 781 PrefixElement prefixElement = maybePrefix; |
| 774 if (prefixElement.isDeferred) { | 782 if (prefixElement.isDeferred) { |
| 775 return prefixElement; | 783 return prefixElement; |
| 776 } | 784 } |
| 777 } | 785 } |
| 778 return null; | 786 return null; |
| 779 } | 787 } |
| 780 } | 788 } |
| OLD | NEW |