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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 if (analyzableElement.resolvedAst.kind != ResolvedAstKind.PARSED) { | 332 if (analyzableElement.resolvedAst.kind != ResolvedAstKind.PARSED) { |
333 return; | 333 return; |
334 } | 334 } |
335 | 335 |
336 TreeElements treeElements = analyzableElement.resolvedAst.elements; | 336 TreeElements treeElements = analyzableElement.resolvedAst.elements; |
337 assert(treeElements != null); | 337 assert(treeElements != null); |
338 | 338 |
339 treeElements | 339 treeElements |
340 .forEachConstantNode((Node node, ConstantExpression expression) { | 340 .forEachConstantNode((Node node, ConstantExpression expression) { |
341 // Explicitly depend on the backend constants. | 341 // Explicitly depend on the backend constants. |
342 ConstantValue value = backend.constants.getConstantValue(expression); | 342 ConstantValue value; |
343 assert(invariant(node, value != null, | 343 value = backend.constants.getConstantValue(expression); |
344 message: | 344 // TODO(johnniwinther): ensure `value` is not null or use directly the |
345 "No constant value for ${expression.toStructuredText()}.")); | 345 // expression to calculate dependencies. See dartbug.com/26406 for |
346 constants.add(value); | 346 // context. |
| 347 if (value != null) { |
| 348 constants.add(value); |
| 349 } |
347 }); | 350 }); |
348 } | 351 } |
349 } | 352 } |
350 | 353 |
351 // TODO(sigurdm): How is metadata on a patch-class handled? | 354 // TODO(sigurdm): How is metadata on a patch-class handled? |
352 for (MetadataAnnotation metadata in element.metadata) { | 355 for (MetadataAnnotation metadata in element.metadata) { |
353 ConstantValue constant = | 356 ConstantValue constant = |
354 backend.constants.getConstantValueForMetadata(metadata); | 357 backend.constants.getConstantValueForMetadata(metadata); |
355 if (constant != null) { | 358 if (constant != null) { |
356 constants.add(constant); | 359 constants.add(constant); |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 return result; | 986 return result; |
984 } | 987 } |
985 | 988 |
986 bool operator ==(other) { | 989 bool operator ==(other) { |
987 if (other is! _DeclaredDeferredImport) return false; | 990 if (other is! _DeclaredDeferredImport) return false; |
988 return declaration == other.declaration; | 991 return declaration == other.declaration; |
989 } | 992 } |
990 | 993 |
991 int get hashCode => declaration.hashCode * 17; | 994 int get hashCode => declaration.hashCode * 17; |
992 } | 995 } |
OLD | NEW |