Chromium Code Reviews| 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 'constants/expressions.dart'; | 7 import 'constants/expressions.dart'; |
| 8 import 'constants/values.dart' show | 8 import 'constants/values.dart' show |
| 9 ConstantValue, | 9 ConstantValue, |
| 10 ConstructedConstantValue, | 10 ConstructedConstantValue, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 /// Returns the [OutputUnit] where [constant] belongs. | 194 /// Returns the [OutputUnit] where [constant] belongs. |
| 195 OutputUnit outputUnitForConstant(ConstantValue constant) { | 195 OutputUnit outputUnitForConstant(ConstantValue constant) { |
| 196 if (!isProgramSplit) return mainOutputUnit; | 196 if (!isProgramSplit) return mainOutputUnit; |
| 197 return _constantToOutputUnit[constant]; | 197 return _constantToOutputUnit[constant]; |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool isDeferred(Element element) { | 200 bool isDeferred(Element element) { |
| 201 return outputUnitForElement(element) != mainOutputUnit; | 201 return outputUnitForElement(element) != mainOutputUnit; |
| 202 } | 202 } |
| 203 | 203 |
| 204 /// Returns true if e1 and e2 are in the same output unit. | 204 /// Returns `true` if element [to] is reachable from element [from] without |
| 205 bool inSameOutputUnit(Element e1, Element e2) { | 205 /// crossing a deferred import. |
| 206 return outputUnitForElement(e1) == outputUnitForElement(e2); | 206 /// For example, if we have two deferred libraries `A` and `B` that both |
|
floitsch
2015/05/05 17:58:15
new line before.
herhut
2015/05/06 08:37:09
Done.
| |
| 207 /// import a library `C`, then even though elements from `A` and `C` end up in | |
| 208 /// different output units, there is a non-deferred path between `A` and `C`. | |
| 209 bool hasNonDeferredImportPath(Element from, Element to) { | |
| 210 OutputUnit outputUnitFrom = outputUnitForElement(from); | |
| 211 OutputUnit outputUnitTo = outputUnitForElement(to); | |
| 212 return outputUnitTo.imports.containsAll(outputUnitFrom.imports); | |
| 213 } | |
| 214 | |
| 215 bool isFromMainOutputUnit(Element element) { | |
| 216 return outputUnitForElement(element) == mainOutputUnit; | |
| 207 } | 217 } |
| 208 | 218 |
| 209 void registerConstantDeferredUse(DeferredConstantValue constant, | 219 void registerConstantDeferredUse(DeferredConstantValue constant, |
| 210 PrefixElement prefix) { | 220 PrefixElement prefix) { |
| 211 OutputUnit outputUnit = new OutputUnit(); | 221 OutputUnit outputUnit = new OutputUnit(); |
| 212 outputUnit.imports.add(prefix.deferredImport); | 222 outputUnit.imports.add(prefix.deferredImport); |
| 213 _constantToOutputUnit[constant] = outputUnit; | 223 _constantToOutputUnit[constant] = outputUnit; |
| 214 } | 224 } |
| 215 | 225 |
| 216 /// Answers whether [element] is explicitly deferred when referred to from | 226 /// Answers whether [element] is explicitly deferred when referred to from |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 882 _importingLibrary = importingLibrary; | 892 _importingLibrary = importingLibrary; |
| 883 | 893 |
| 884 String get importingLibraryName { | 894 String get importingLibraryName { |
| 885 String libraryName = _importingLibrary.getLibraryName(); | 895 String libraryName = _importingLibrary.getLibraryName(); |
| 886 return libraryName == "" | 896 return libraryName == "" |
| 887 ? "<unnamed>" | 897 ? "<unnamed>" |
| 888 : libraryName; | 898 : libraryName; |
| 889 } | 899 } |
| 890 | 900 |
| 891 } | 901 } |
| OLD | NEW |