OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 compiler.src.inferrer.type_graph_nodes; | 5 library compiler.src.inferrer.type_graph_nodes; |
6 | 6 |
7 import 'dart:collection' show IterableBase; | 7 import 'dart:collection' show IterableBase; |
8 | 8 |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../common/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 * | 376 * |
377 * These should never be created directly but instead are constructed by | 377 * These should never be created directly but instead are constructed by |
378 * the [ElementTypeInformation] factory. | 378 * the [ElementTypeInformation] factory. |
379 */ | 379 */ |
380 class MemberTypeInformation extends ElementTypeInformation | 380 class MemberTypeInformation extends ElementTypeInformation |
381 with ApplyableTypeInformation { | 381 with ApplyableTypeInformation { |
382 TypedElement get element => super.element; | 382 TypedElement get element => super.element; |
383 | 383 |
384 /** | 384 /** |
385 * If [element] is a function, [closurizedCount] is the number of | 385 * If [element] is a function, [closurizedCount] is the number of |
386 * times it is closurized. The value gets updated while infering. | 386 * times it is closurized. The value gets updated while inferring. |
387 */ | 387 */ |
388 int closurizedCount = 0; | 388 int closurizedCount = 0; |
389 | 389 |
390 // Strict `bool` value is computed in cleanup(). Also used as a flag to see if | 390 // Strict `bool` value is computed in cleanup(). Also used as a flag to see if |
391 // cleanup has been called. | 391 // cleanup has been called. |
392 bool _isCalledOnce = null; | 392 bool _isCalledOnce = null; |
393 | 393 |
394 /** | 394 /** |
395 * This map contains the callers of [element]. It stores all unique call sites | 395 * This map contains the callers of [element]. It stores all unique call sites |
396 * to enable counting the global number of call sites of [element]. | 396 * to enable counting the global number of call sites of [element]. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 if (count > 1) return false; | 449 if (count > 1) return false; |
450 } | 450 } |
451 return count == 1; | 451 return count == 1; |
452 } | 452 } |
453 | 453 |
454 bool get isClosurized => closurizedCount > 0; | 454 bool get isClosurized => closurizedCount > 0; |
455 | 455 |
456 // Closurized methods never become stable to ensure that the information in | 456 // Closurized methods never become stable to ensure that the information in |
457 // [users] is accurate. The inference stops tracking users for stable types. | 457 // [users] is accurate. The inference stops tracking users for stable types. |
458 // Note that we only override the getter, the setter will still modify the | 458 // Note that we only override the getter, the setter will still modify the |
459 // state of the [isStable] field inhertied from [TypeInformation]. | 459 // state of the [isStable] field inherited from [TypeInformation]. |
460 bool get isStable => super.isStable && !isClosurized; | 460 bool get isStable => super.isStable && !isClosurized; |
461 | 461 |
462 TypeMask handleSpecialCases(InferrerEngine inferrer) { | 462 TypeMask handleSpecialCases(InferrerEngine inferrer) { |
463 if (element.isField && | 463 if (element.isField && |
464 (!inferrer.backend.canFieldBeUsedForGlobalOptimizations( | 464 (!inferrer.backend.canFieldBeUsedForGlobalOptimizations( |
465 element, inferrer.closedWorld) || | 465 element, inferrer.closedWorld) || |
466 inferrer.assumeDynamic(element))) { | 466 inferrer.assumeDynamic(element))) { |
467 // Do not infer types for fields that have a corresponding annotation or | 467 // Do not infer types for fields that have a corresponding annotation or |
468 // are assigned by synthesized calls | 468 // are assigned by synthesized calls |
469 | 469 |
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1763 // TODO(ngeoffray): Narrow to bound. | 1763 // TODO(ngeoffray): Narrow to bound. |
1764 return type; | 1764 return type; |
1765 } else { | 1765 } else { |
1766 ResolutionInterfaceType interfaceType = annotation; | 1766 ResolutionInterfaceType interfaceType = annotation; |
1767 otherType = new TypeMask.nonNullSubtype(interfaceType.element, closedWorld); | 1767 otherType = new TypeMask.nonNullSubtype(interfaceType.element, closedWorld); |
1768 } | 1768 } |
1769 if (isNullable) otherType = otherType.nullable(); | 1769 if (isNullable) otherType = otherType.nullable(); |
1770 if (type == null) return otherType; | 1770 if (type == null) return otherType; |
1771 return type.intersection(otherType, closedWorld); | 1771 return type.intersection(otherType, closedWorld); |
1772 } | 1772 } |
OLD | NEW |