| 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/backend_api.dart' show Backend; | 7 import 'common/backend_api.dart' show Backend; |
| 8 import 'common/tasks.dart' show CompilerTask; | 8 import 'common/tasks.dart' show CompilerTask; |
| 9 import 'common.dart'; | 9 import 'common.dart'; |
| 10 import 'compiler.dart' show Compiler; | 10 import 'compiler.dart' show Compiler; |
| 11 import 'constants/expressions.dart' |
| 12 show |
| 13 ConstantExpression, |
| 14 ConstantExpressionKind; |
| 11 import 'constants/values.dart' | 15 import 'constants/values.dart' |
| 12 show | 16 show |
| 13 ConstantValue, | 17 ConstantValue, |
| 14 ConstructedConstantValue, | 18 ConstructedConstantValue, |
| 15 DeferredConstantValue, | 19 DeferredConstantValue, |
| 16 StringConstantValue; | 20 StringConstantValue; |
| 17 import 'dart_types.dart'; | 21 import 'dart_types.dart'; |
| 18 import 'elements/elements.dart' | 22 import 'elements/elements.dart' |
| 19 show | 23 show |
| 20 AccessorElement, | 24 AccessorElement, |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 }), | 331 }), |
| 328 IMPACT_USE); | 332 IMPACT_USE); |
| 329 | 333 |
| 330 if (analyzableElement.resolvedAst.kind != ResolvedAstKind.PARSED) { | 334 if (analyzableElement.resolvedAst.kind != ResolvedAstKind.PARSED) { |
| 331 return; | 335 return; |
| 332 } | 336 } |
| 333 | 337 |
| 334 TreeElements treeElements = analyzableElement.resolvedAst.elements; | 338 TreeElements treeElements = analyzableElement.resolvedAst.elements; |
| 335 assert(treeElements != null); | 339 assert(treeElements != null); |
| 336 | 340 |
| 337 treeElements.forEachConstantNode((Node node, _) { | 341 treeElements.forEachConstantNode( |
| 342 (Node node, ConstantExpression expression) { |
| 338 // Explicitly depend on the backend constants. | 343 // Explicitly depend on the backend constants. |
| 339 ConstantValue value = | 344 ConstantValue value = backend.constants.getConstantValue(expression); |
| 340 backend.constants.getConstantValueForNode(node, treeElements); | 345 assert(invariant(node, value != null, |
| 341 if (value != null) { | 346 message: "No constant value for ${expression.toStructuredText()}."
)); |
| 342 // TODO(johnniwinther): Assert that all constants have values when | 347 constants.add(value); |
| 343 // these are directly evaluated. | |
| 344 constants.add(value); | |
| 345 } | |
| 346 }); | 348 }); |
| 347 } | 349 } |
| 348 } | 350 } |
| 349 | 351 |
| 350 // TODO(sigurdm): How is metadata on a patch-class handled? | 352 // TODO(sigurdm): How is metadata on a patch-class handled? |
| 351 for (MetadataAnnotation metadata in element.metadata) { | 353 for (MetadataAnnotation metadata in element.metadata) { |
| 352 ConstantValue constant = | 354 ConstantValue constant = |
| 353 backend.constants.getConstantValueForMetadata(metadata); | 355 backend.constants.getConstantValueForMetadata(metadata); |
| 354 if (constant != null) { | 356 if (constant != null) { |
| 355 constants.add(constant); | 357 constants.add(constant); |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 return result; | 984 return result; |
| 983 } | 985 } |
| 984 | 986 |
| 985 bool operator ==(other) { | 987 bool operator ==(other) { |
| 986 if (other is! _DeclaredDeferredImport) return false; | 988 if (other is! _DeclaredDeferredImport) return false; |
| 987 return declaration == other.declaration; | 989 return declaration == other.declaration; |
| 988 } | 990 } |
| 989 | 991 |
| 990 int get hashCode => declaration.hashCode * 17; | 992 int get hashCode => declaration.hashCode * 17; |
| 991 } | 993 } |
| OLD | NEW |