| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 abstract class HType { | 5 abstract class HType { |
| 6 const HType(); | 6 const HType(); |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Returns an [HType] that represents [type] and all types that have | 9 * Returns an [HType] that represents [type] and all types that have |
| 10 * [type] as supertype. | 10 * [type] as supertype. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 static const HType CONFLICTING = const HConflictingType(); | 45 static const HType CONFLICTING = const HConflictingType(); |
| 46 static const HType UNKNOWN = const HUnknownType(); | 46 static const HType UNKNOWN = const HUnknownType(); |
| 47 static const HType BOOLEAN = const HBooleanType(); | 47 static const HType BOOLEAN = const HBooleanType(); |
| 48 static const HType NUMBER = const HNumberType(); | 48 static const HType NUMBER = const HNumberType(); |
| 49 static const HType INTEGER = const HIntegerType(); | 49 static const HType INTEGER = const HIntegerType(); |
| 50 static const HType DOUBLE = const HDoubleType(); | 50 static const HType DOUBLE = const HDoubleType(); |
| 51 static const HType INDEXABLE_PRIMITIVE = const HIndexablePrimitiveType(); | 51 static const HType INDEXABLE_PRIMITIVE = const HIndexablePrimitiveType(); |
| 52 static const HType STRING = const HStringType(); | 52 static const HType STRING = const HStringType(); |
| 53 static const HType READABLE_ARRAY = const HReadableArrayType(); | 53 static const HType READABLE_ARRAY = const HReadableArrayType(); |
| 54 static const HType MUTABLE_ARRAY = const HMutableArrayType(); | 54 static const HType MUTABLE_ARRAY = const HMutableArrayType(); |
| 55 static const HType FIXED_ARRAY = const HFixedArrayType(); |
| 55 static const HType EXTENDABLE_ARRAY = const HExtendableArrayType(); | 56 static const HType EXTENDABLE_ARRAY = const HExtendableArrayType(); |
| 56 static const HType NULL = const HNullType(); | 57 static const HType NULL = const HNullType(); |
| 57 | 58 |
| 58 static const HType BOOLEAN_OR_NULL = const HBooleanOrNullType(); | 59 static const HType BOOLEAN_OR_NULL = const HBooleanOrNullType(); |
| 59 static const HType NUMBER_OR_NULL = const HNumberOrNullType(); | 60 static const HType NUMBER_OR_NULL = const HNumberOrNullType(); |
| 60 static const HType INTEGER_OR_NULL = const HIntegerOrNullType(); | 61 static const HType INTEGER_OR_NULL = const HIntegerOrNullType(); |
| 61 static const HType DOUBLE_OR_NULL = const HDoubleOrNullType(); | 62 static const HType DOUBLE_OR_NULL = const HDoubleOrNullType(); |
| 62 static const HType STRING_OR_NULL = const HStringOrNullType(); | 63 static const HType STRING_OR_NULL = const HStringOrNullType(); |
| 63 | 64 |
| 64 bool isConflicting() => this === CONFLICTING; | 65 bool isConflicting() => this === CONFLICTING; |
| 65 bool isUnknown() => this === UNKNOWN; | 66 bool isUnknown() => this === UNKNOWN; |
| 66 bool isNull() => false; | 67 bool isNull() => false; |
| 67 bool isBoolean() => false; | 68 bool isBoolean() => false; |
| 68 bool isNumber() => false; | 69 bool isNumber() => false; |
| 69 bool isInteger() => false; | 70 bool isInteger() => false; |
| 70 bool isDouble() => false; | 71 bool isDouble() => false; |
| 71 bool isString() => false; | 72 bool isString() => false; |
| 72 bool isBooleanOrNull() => false; | 73 bool isBooleanOrNull() => false; |
| 73 bool isNumberOrNull() => false; | 74 bool isNumberOrNull() => false; |
| 74 bool isIntegerOrNull() => false; | 75 bool isIntegerOrNull() => false; |
| 75 bool isDoubleOrNull() => false; | 76 bool isDoubleOrNull() => false; |
| 76 bool isStringOrNull() => false; | 77 bool isStringOrNull() => false; |
| 77 bool isIndexablePrimitive() => false; | 78 bool isIndexablePrimitive() => false; |
| 79 bool isFixedArray() => false; |
| 78 bool isReadableArray() => false; | 80 bool isReadableArray() => false; |
| 79 bool isMutableArray() => false; | 81 bool isMutableArray() => false; |
| 80 bool isExtendableArray() => false; | 82 bool isExtendableArray() => false; |
| 81 bool isPrimitive() => false; | 83 bool isPrimitive() => false; |
| 82 bool isExact() => false; | 84 bool isExact() => false; |
| 83 bool isPrimitiveOrNull() => false; | 85 bool isPrimitiveOrNull() => false; |
| 84 | 86 |
| 85 bool canBePrimitive() => false; | 87 bool canBePrimitive() => false; |
| 86 bool canBeNull() => false; | 88 bool canBeNull() => false; |
| 87 | 89 |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 if (other.isConflicting()) return HType.CONFLICTING; | 604 if (other.isConflicting()) return HType.CONFLICTING; |
| 603 if (other.isUnknown()) return HType.MUTABLE_ARRAY; | 605 if (other.isUnknown()) return HType.MUTABLE_ARRAY; |
| 604 if (other.isMutableArray()) return other; | 606 if (other.isMutableArray()) return other; |
| 605 if (other.isString()) return HType.CONFLICTING; | 607 if (other.isString()) return HType.CONFLICTING; |
| 606 if (other.isIndexablePrimitive()) return HType.MUTABLE_ARRAY; | 608 if (other.isIndexablePrimitive()) return HType.MUTABLE_ARRAY; |
| 607 if (other is HBoundedPotentialPrimitiveArray) return HType.MUTABLE_ARRAY; | 609 if (other is HBoundedPotentialPrimitiveArray) return HType.MUTABLE_ARRAY; |
| 608 return HType.CONFLICTING; | 610 return HType.CONFLICTING; |
| 609 } | 611 } |
| 610 } | 612 } |
| 611 | 613 |
| 614 class HFixedArrayType extends HMutableArrayType { |
| 615 const HFixedArrayType(); |
| 616 bool isFixedArray() => true; |
| 617 String toString() => "fixed array"; |
| 618 |
| 619 HType union(HType other) { |
| 620 if (other.isConflicting()) return HType.FIXED_ARRAY; |
| 621 if (other.isUnknown()) return HType.UNKNOWN; |
| 622 if (other.isFixedArray()) return HType.FIXED_ARRAY; |
| 623 if (other.isMutableArray()) return HType.MUTABLE_ARRAY; |
| 624 if (other.isReadableArray()) return HType.READABLE_ARRAY; |
| 625 if (other.isIndexablePrimitive()) return HType.INDEXABLE_PRIMITIVE; |
| 626 if (other is HBoundedPotentialPrimitiveArray) return other; |
| 627 return HType.UNKNOWN; |
| 628 } |
| 629 |
| 630 HType intersection(HType other) { |
| 631 if (other.isConflicting()) return HType.CONFLICTING; |
| 632 if (other.isUnknown()) return HType.FIXED_ARRAY; |
| 633 if (other.isFixedArray()) return HType.FIXED_ARRAY; |
| 634 if (other.isExtendableArray()) return HType.CONFLICTING; |
| 635 if (other.isString()) return HType.CONFLICTING; |
| 636 if (other.isIndexablePrimitive()) return HType.FIXED_ARRAY; |
| 637 if (other is HBoundedPotentialPrimitiveArray) return HType.FIXED_ARRAY; |
| 638 return HType.CONFLICTING; |
| 639 } |
| 640 } |
| 641 |
| 612 class HExtendableArrayType extends HMutableArrayType { | 642 class HExtendableArrayType extends HMutableArrayType { |
| 613 const HExtendableArrayType(); | 643 const HExtendableArrayType(); |
| 614 bool isExtendableArray() => true; | 644 bool isExtendableArray() => true; |
| 615 String toString() => "extendable array"; | 645 String toString() => "extendable array"; |
| 616 | 646 |
| 617 HType union(HType other) { | 647 HType union(HType other) { |
| 618 if (other.isConflicting()) return HType.EXTENDABLE_ARRAY; | 648 if (other.isConflicting()) return HType.EXTENDABLE_ARRAY; |
| 619 if (other.isUnknown()) return HType.UNKNOWN; | 649 if (other.isUnknown()) return HType.UNKNOWN; |
| 620 if (other.isExtendableArray()) return HType.EXTENDABLE_ARRAY; | 650 if (other.isExtendableArray()) return HType.EXTENDABLE_ARRAY; |
| 621 if (other.isMutableArray()) return HType.MUTABLE_ARRAY; | 651 if (other.isMutableArray()) return HType.MUTABLE_ARRAY; |
| 622 if (other.isReadableArray()) return HType.READABLE_ARRAY; | 652 if (other.isReadableArray()) return HType.READABLE_ARRAY; |
| 623 if (other.isIndexablePrimitive()) return HType.INDEXABLE_PRIMITIVE; | 653 if (other.isIndexablePrimitive()) return HType.INDEXABLE_PRIMITIVE; |
| 624 if (other is HBoundedPotentialPrimitiveArray) return other; | 654 if (other is HBoundedPotentialPrimitiveArray) return other; |
| 625 return HType.UNKNOWN; | 655 return HType.UNKNOWN; |
| 626 } | 656 } |
| 627 | 657 |
| 628 HType intersection(HType other) { | 658 HType intersection(HType other) { |
| 629 if (other.isConflicting()) return HType.CONFLICTING; | 659 if (other.isConflicting()) return HType.CONFLICTING; |
| 630 if (other.isUnknown()) return HType.EXTENDABLE_ARRAY; | 660 if (other.isUnknown()) return HType.EXTENDABLE_ARRAY; |
| 631 if (other.isExtendableArray()) return HType.EXTENDABLE_ARRAY; | 661 if (other.isExtendableArray()) return HType.EXTENDABLE_ARRAY; |
| 632 if (other.isString()) return HType.CONFLICTING; | 662 if (other.isString()) return HType.CONFLICTING; |
| 663 if (other.isFixedArray()) return HType.CONFLICTING; |
| 633 if (other.isIndexablePrimitive()) return HType.EXTENDABLE_ARRAY; | 664 if (other.isIndexablePrimitive()) return HType.EXTENDABLE_ARRAY; |
| 634 if (other is HBoundedPotentialPrimitiveArray) return HType.EXTENDABLE_ARRAY; | 665 if (other is HBoundedPotentialPrimitiveArray) return HType.EXTENDABLE_ARRAY; |
| 635 return HType.CONFLICTING; | 666 return HType.CONFLICTING; |
| 636 } | 667 } |
| 637 } | 668 } |
| 638 | 669 |
| 639 class HBoundedType extends HType { | 670 class HBoundedType extends HType { |
| 640 final DartType type; | 671 final DartType type; |
| 641 final bool _canBeNull; | 672 final bool _canBeNull; |
| 642 final bool _isExact; | 673 final bool _isExact; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 operator [](HInstruction instruction) { | 867 operator [](HInstruction instruction) { |
| 837 HType result = _map[instruction]; | 868 HType result = _map[instruction]; |
| 838 if (result == null) return instruction.guaranteedType; | 869 if (result == null) return instruction.guaranteedType; |
| 839 return result; | 870 return result; |
| 840 } | 871 } |
| 841 | 872 |
| 842 operator []=(HInstruction instruction, HType value) { | 873 operator []=(HInstruction instruction, HType value) { |
| 843 _map[instruction] = value; | 874 _map[instruction] = value; |
| 844 } | 875 } |
| 845 } | 876 } |
| OLD | NEW |