| 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.dart'; | 7 import 'common.dart'; |
| 8 import 'common/backend_api.dart' show | 8 import 'common/backend_api.dart' show |
| 9 Backend; | 9 Backend; |
| 10 import 'common/tasks.dart' show | 10 import 'common/tasks.dart' show |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 import 'tree/tree.dart' as ast; | 41 import 'tree/tree.dart' as ast; |
| 42 import 'tree/tree.dart' show | 42 import 'tree/tree.dart' show |
| 43 Import, | 43 Import, |
| 44 LibraryTag, | 44 LibraryTag, |
| 45 LibraryDependency, | 45 LibraryDependency, |
| 46 LiteralDartString, | 46 LiteralDartString, |
| 47 LiteralString, | 47 LiteralString, |
| 48 NewExpression, | 48 NewExpression, |
| 49 Node; | 49 Node; |
| 50 import 'universe/use.dart' show | 50 import 'universe/use.dart' show |
| 51 StaticUse; | 51 StaticUse, |
| 52 TypeUse, |
| 53 TypeUseKind; |
| 52 import 'universe/world_impact.dart' show | 54 import 'universe/world_impact.dart' show |
| 53 WorldImpact; | 55 WorldImpact; |
| 54 import 'util/setlet.dart' show | 56 import 'util/setlet.dart' show |
| 55 Setlet; | 57 Setlet; |
| 56 import 'util/uri_extras.dart' as uri_extras; | 58 import 'util/uri_extras.dart' as uri_extras; |
| 57 import 'util/util.dart' show | 59 import 'util/util.dart' show |
| 58 Link, makeUnique; | 60 Link, makeUnique; |
| 59 | 61 |
| 60 /// A "hunk" of the program that will be loaded whenever one of its [imports] | 62 /// A "hunk" of the program that will be loaded whenever one of its [imports] |
| 61 /// are loaded. | 63 /// are loaded. |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 if (!compiler.enqueuer.resolution.hasBeenProcessed(analyzableElement)) { | 313 if (!compiler.enqueuer.resolution.hasBeenProcessed(analyzableElement)) { |
| 312 return; | 314 return; |
| 313 } | 315 } |
| 314 | 316 |
| 315 WorldImpact worldImpact = | 317 WorldImpact worldImpact = |
| 316 compiler.resolution.getWorldImpact(analyzableElement); | 318 compiler.resolution.getWorldImpact(analyzableElement); |
| 317 worldImpact.staticUses.forEach((StaticUse staticUse) { | 319 worldImpact.staticUses.forEach((StaticUse staticUse) { |
| 318 elements.add(staticUse.element); | 320 elements.add(staticUse.element); |
| 319 }); | 321 }); |
| 320 elements.addAll(worldImpact.closures); | 322 elements.addAll(worldImpact.closures); |
| 321 for (DartType type in worldImpact.typeLiterals) { | 323 for (TypeUse typeUse in worldImpact.typeUses) { |
| 322 if (type.isTypedef || type.isInterfaceType) { | 324 DartType type = typeUse.type; |
| 323 elements.add(type.element); | 325 switch (typeUse.kind) { |
| 326 case TypeUseKind.TYPE_LITERAL: |
| 327 if (type.isTypedef || type.isInterfaceType) { |
| 328 elements.add(type.element); |
| 329 } |
| 330 break; |
| 331 case TypeUseKind.INSTANTIATION: |
| 332 case TypeUseKind.IS_CHECK: |
| 333 case TypeUseKind.AS_CAST: |
| 334 case TypeUseKind.CATCH_TYPE: |
| 335 collectTypeDependencies(type); |
| 336 break; |
| 337 case TypeUseKind.CHECKED_MODE_CHECK: |
| 338 if (compiler.enableTypeAssertions) { |
| 339 collectTypeDependencies(type); |
| 340 } |
| 341 break; |
| 324 } | 342 } |
| 325 } | 343 } |
| 326 worldImpact.instantiatedTypes.forEach(collectTypeDependencies); | |
| 327 worldImpact.isChecks.forEach(collectTypeDependencies); | |
| 328 worldImpact.asCasts.forEach(collectTypeDependencies); | |
| 329 worldImpact.onCatchTypes.forEach(collectTypeDependencies); | |
| 330 if (compiler.enableTypeAssertions) { | |
| 331 worldImpact.checkedModeChecks.forEach(collectTypeDependencies); | |
| 332 } | |
| 333 | 344 |
| 334 TreeElements treeElements = analyzableElement.resolvedAst.elements; | 345 TreeElements treeElements = analyzableElement.resolvedAst.elements; |
| 335 assert(treeElements != null); | 346 assert(treeElements != null); |
| 336 | 347 |
| 337 treeElements.forEachConstantNode((Node node, _) { | 348 treeElements.forEachConstantNode((Node node, _) { |
| 338 // Explicitly depend on the backend constants. | 349 // Explicitly depend on the backend constants. |
| 339 ConstantValue value = | 350 ConstantValue value = |
| 340 backend.constants.getConstantValueForNode(node, treeElements); | 351 backend.constants.getConstantValueForNode(node, treeElements); |
| 341 if (value != null) { | 352 if (value != null) { |
| 342 // TODO(johnniwinther): Assert that all constants have values when | 353 // TODO(johnniwinther): Assert that all constants have values when |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 return result; | 997 return result; |
| 987 } | 998 } |
| 988 | 999 |
| 989 bool operator ==(other) { | 1000 bool operator ==(other) { |
| 990 if (other is! _DeclaredDeferredImport) return false; | 1001 if (other is! _DeclaredDeferredImport) return false; |
| 991 return declaration == other.declaration; | 1002 return declaration == other.declaration; |
| 992 } | 1003 } |
| 993 | 1004 |
| 994 int get hashCode => declaration.hashCode * 17; | 1005 int get hashCode => declaration.hashCode * 17; |
| 995 } | 1006 } |
| OLD | NEW |