| 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; |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 342 |
| 343 // TODO(johnniwinther): Add only expressions that are actually needed. | 343 // TODO(johnniwinther): Add only expressions that are actually needed. |
| 344 // Currently we have some noise here: Some potential expressions are | 344 // Currently we have some noise here: Some potential expressions are |
| 345 // seen that should never be added (for instance field initializers | 345 // seen that should never be added (for instance field initializers |
| 346 // in constant constructors, like `this.field = parameter`). And some | 346 // in constant constructors, like `this.field = parameter`). And some |
| 347 // implicit constant expression are seen that we should be able to add | 347 // implicit constant expression are seen that we should be able to add |
| 348 // (like primitive constant literals like `true`, `"foo"` and `0`). | 348 // (like primitive constant literals like `true`, `"foo"` and `0`). |
| 349 // See dartbug.com/26406 for context. | 349 // See dartbug.com/26406 for context. |
| 350 treeElements | 350 treeElements |
| 351 .forEachConstantNode((Node node, ConstantExpression expression) { | 351 .forEachConstantNode((Node node, ConstantExpression expression) { |
| 352 if (compiler.serialization.isDeserialized(analyzableElement)) { |
| 353 if (!expression.isImplicit && !expression.isPotential) { |
| 354 // Enforce evaluation of [expression]. |
| 355 backend.constants.getConstantValue(expression); |
| 356 } |
| 357 } |
| 358 |
| 352 // Explicitly depend on the backend constants. | 359 // Explicitly depend on the backend constants. |
| 353 if (backend.constants.hasConstantValue(expression)) { | 360 if (backend.constants.hasConstantValue(expression)) { |
| 354 ConstantValue value = | 361 ConstantValue value = |
| 355 backend.constants.getConstantValue(expression); | 362 backend.constants.getConstantValue(expression); |
| 356 assert(invariant(node, value != null, | 363 assert(invariant(node, value != null, |
| 357 message: "Constant expression without value: " | 364 message: "Constant expression without value: " |
| 358 "${expression.toStructuredText()}.")); | 365 "${expression.toStructuredText()}.")); |
| 359 constants.add(value); | 366 constants.add(value); |
| 360 } else { | 367 } else { |
| 361 assert( | 368 assert( |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 return result; | 1018 return result; |
| 1012 } | 1019 } |
| 1013 | 1020 |
| 1014 bool operator ==(other) { | 1021 bool operator ==(other) { |
| 1015 if (other is! _DeclaredDeferredImport) return false; | 1022 if (other is! _DeclaredDeferredImport) return false; |
| 1016 return declaration == other.declaration; | 1023 return declaration == other.declaration; |
| 1017 } | 1024 } |
| 1018 | 1025 |
| 1019 int get hashCode => declaration.hashCode * 17; | 1026 int get hashCode => declaration.hashCode * 17; |
| 1020 } | 1027 } |
| OLD | NEW |