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/values.dart' show | 7 import 'constants/values.dart' show |
8 ConstantValue, | 8 ConstantValue, |
9 ConstructedConstantValue, | 9 ConstructedConstantValue, |
10 DeferredConstantValue, | 10 DeferredConstantValue, |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 273 |
274 assert(treeElements != null); | 274 assert(treeElements != null); |
275 | 275 |
276 for (Element dependency in treeElements.allElements) { | 276 for (Element dependency in treeElements.allElements) { |
277 if (dependency.isLocal && !dependency.isFunction) continue; | 277 if (dependency.isLocal && !dependency.isFunction) continue; |
278 if (dependency.isErroneous) continue; | 278 if (dependency.isErroneous) continue; |
279 if (dependency.isTypeVariable) continue; | 279 if (dependency.isTypeVariable) continue; |
280 | 280 |
281 elements.add(dependency); | 281 elements.add(dependency); |
282 } | 282 } |
| 283 |
| 284 void registerTypeArgumentsAsDependencies(DartType type) { |
| 285 Element dependency = type.element; |
| 286 if (dependency == null || dependency.isErroneous || |
| 287 dependency.isTypeVariable) { |
| 288 return; |
| 289 } |
| 290 elements.add(dependency); |
| 291 if (type is GenericType) { |
| 292 type.typeArguments.forEach(registerTypeArgumentsAsDependencies); |
| 293 } |
| 294 } |
| 295 |
| 296 treeElements.forEachType((Node node, DartType type) { |
| 297 if (node is NewExpression) registerTypeArgumentsAsDependencies(type); |
| 298 }); |
| 299 |
283 treeElements.forEachConstantNode((Node node, _) { | 300 treeElements.forEachConstantNode((Node node, _) { |
284 // Explicitly depend on the backend constants. | 301 // Explicitly depend on the backend constants. |
285 ConstantValue value = | 302 ConstantValue value = |
286 backend.constants.getConstantValueForNode(node, treeElements); | 303 backend.constants.getConstantValueForNode(node, treeElements); |
287 if (value != null) { | 304 if (value != null) { |
288 // TODO(johnniwinther): Assert that all constants have values when | 305 // TODO(johnniwinther): Assert that all constants have values when |
289 // these are directly evaluated. | 306 // these are directly evaluated. |
290 constants.add(value); | 307 constants.add(value); |
291 } | 308 } |
292 }); | 309 }); |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 _importingLibrary = importingLibrary; | 901 _importingLibrary = importingLibrary; |
885 | 902 |
886 String get importingLibraryName { | 903 String get importingLibraryName { |
887 String libraryName = _importingLibrary.getLibraryName(); | 904 String libraryName = _importingLibrary.getLibraryName(); |
888 return libraryName == "" | 905 return libraryName == "" |
889 ? "<unnamed>" | 906 ? "<unnamed>" |
890 : libraryName; | 907 : libraryName; |
891 } | 908 } |
892 | 909 |
893 } | 910 } |
OLD | NEW |