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 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 return 'BoundedType($type, $_canBeNull, $_isExact)'; | 676 return 'BoundedType($type, $_canBeNull, $_isExact)'; |
677 } | 677 } |
678 | 678 |
679 bool canBeNull() => _canBeNull; | 679 bool canBeNull() => _canBeNull; |
680 | 680 |
681 bool isExact() => _isExact; | 681 bool isExact() => _isExact; |
682 | 682 |
683 const HBoundedType(DartType this.type, | 683 const HBoundedType(DartType this.type, |
684 [bool canBeNull = false, isExact = false]) | 684 [bool canBeNull = false, isExact = false]) |
685 : _canBeNull = canBeNull, _isExact = isExact; | 685 : _canBeNull = canBeNull, _isExact = isExact; |
686 const HBoundedType.exact(DartType type) : this(type, isExact: true); | 686 const HBoundedType.exact(DartType type) : this(type, false, true); |
687 const HBoundedType.withNull(DartType type) : this(type, canBeNull: true); | 687 const HBoundedType.withNull(DartType type) : this(type, true, false); |
688 const HBoundedType.nonNull(DartType type) : this(type); | 688 const HBoundedType.nonNull(DartType type) : this(type); |
689 | 689 |
690 DartType computeType(Compiler compiler) => type; | 690 DartType computeType(Compiler compiler) => type; |
691 | 691 |
692 Element lookupMember(SourceString name) { | 692 Element lookupMember(SourceString name) { |
693 if (!isExact()) return null; | 693 if (!isExact()) return null; |
694 ClassElement classElement = type.element; | 694 ClassElement classElement = type.element; |
695 return classElement.lookupMember(name); | 695 return classElement.lookupMember(name); |
696 } | 696 } |
697 | 697 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 operator [](HInstruction instruction) { | 867 operator [](HInstruction instruction) { |
868 HType result = _map[instruction]; | 868 HType result = _map[instruction]; |
869 if (result == null) return instruction.guaranteedType; | 869 if (result == null) return instruction.guaranteedType; |
870 return result; | 870 return result; |
871 } | 871 } |
872 | 872 |
873 operator []=(HInstruction instruction, HType value) { | 873 operator []=(HInstruction instruction, HType value) { |
874 _map[instruction] = value; | 874 _map[instruction] = value; |
875 } | 875 } |
876 } | 876 } |
OLD | NEW |