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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 // (like primitive constant literals like `true`, `"foo"` and `0`). | 344 // (like primitive constant literals like `true`, `"foo"` and `0`). |
345 // See dartbug.com/26406 for context. | 345 // See dartbug.com/26406 for context. |
346 treeElements | 346 treeElements |
347 .forEachConstantNode((Node node, ConstantExpression expression) { | 347 .forEachConstantNode((Node node, ConstantExpression expression) { |
348 // Explicitly depend on the backend constants. | 348 // Explicitly depend on the backend constants. |
349 if (backend.constants.hasConstantValue(expression)) { | 349 if (backend.constants.hasConstantValue(expression)) { |
350 ConstantValue value = | 350 ConstantValue value = |
351 backend.constants.getConstantValue(expression); | 351 backend.constants.getConstantValue(expression); |
352 assert(invariant(node, value != null, | 352 assert(invariant(node, value != null, |
353 message: "Constant expression without value: " | 353 message: "Constant expression without value: " |
354 "${expression.toStructuredText()}.")); | 354 "${expression.toStructuredText()}.")); |
355 constants.add(value); | 355 constants.add(value); |
356 } else { | 356 } else { |
357 assert(invariant(node, | 357 assert( |
358 expression.isImplicit || expression.isPotential, | 358 invariant(node, expression.isImplicit || expression.isPotential, |
359 message: "Unexpected unevaluated constant expression: " | 359 message: "Unexpected unevaluated constant expression: " |
360 "${expression.toStructuredText()}.")); | 360 "${expression.toStructuredText()}.")); |
361 } | 361 } |
362 }); | 362 }); |
363 } | 363 } |
364 } | 364 } |
365 | 365 |
366 // TODO(sigurdm): How is metadata on a patch-class handled? | 366 // TODO(sigurdm): How is metadata on a patch-class handled? |
367 for (MetadataAnnotation metadata in element.metadata) { | 367 for (MetadataAnnotation metadata in element.metadata) { |
368 ConstantValue constant = | 368 ConstantValue constant = |
369 backend.constants.getConstantValueForMetadata(metadata); | 369 backend.constants.getConstantValueForMetadata(metadata); |
370 if (constant != null) { | 370 if (constant != null) { |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 return result; | 998 return result; |
999 } | 999 } |
1000 | 1000 |
1001 bool operator ==(other) { | 1001 bool operator ==(other) { |
1002 if (other is! _DeclaredDeferredImport) return false; | 1002 if (other is! _DeclaredDeferredImport) return false; |
1003 return declaration == other.declaration; | 1003 return declaration == other.declaration; |
1004 } | 1004 } |
1005 | 1005 |
1006 int get hashCode => declaration.hashCode * 17; | 1006 int get hashCode => declaration.hashCode * 17; |
1007 } | 1007 } |
OLD | NEW |