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 part of ssa; | 5 part of ssa; |
6 | 6 |
7 abstract class HVisitor<R> { | 7 abstract class HVisitor<R> { |
8 R visitAdd(HAdd node); | 8 R visitAdd(HAdd node); |
9 R visitBailoutTarget(HBailoutTarget node); | 9 R visitBailoutTarget(HBailoutTarget node); |
10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 return false; | 1108 return false; |
1109 } | 1109 } |
1110 | 1110 |
1111 HInstruction convertType(Compiler compiler, DartType type, int kind) { | 1111 HInstruction convertType(Compiler compiler, DartType type, int kind) { |
1112 if (type == null) return this; | 1112 if (type == null) return this; |
1113 type = type.unalias(compiler); | 1113 type = type.unalias(compiler); |
1114 // Only the builder knows how to create [HTypeConversion] | 1114 // Only the builder knows how to create [HTypeConversion] |
1115 // instructions with generics. It has the generic type context | 1115 // instructions with generics. It has the generic type context |
1116 // available. | 1116 // available. |
1117 assert(type.kind != TypeKind.TYPE_VARIABLE); | 1117 assert(type.kind != TypeKind.TYPE_VARIABLE); |
1118 assert(type.isRaw | 1118 assert(type.isRaw || type.kind == TypeKind.FUNCTION); |
1119 || type.isMalformed | 1119 if (type.containsAmbiguousTypes) { |
1120 || type.kind == TypeKind.FUNCTION); | 1120 return new HTypeConversion(type, kind, HType.UNKNOWN, this); |
1121 if (identical(type.element, compiler.dynamicClass)) return this; | 1121 } |
| 1122 if (type.treatAsDynamic) return this; |
1122 if (identical(type.element, compiler.objectClass)) return this; | 1123 if (identical(type.element, compiler.objectClass)) return this; |
1123 if (type.isMalformed || type.kind != TypeKind.INTERFACE) { | 1124 if (type.kind != TypeKind.INTERFACE) { |
1124 return new HTypeConversion(type, kind, HType.UNKNOWN, this); | 1125 return new HTypeConversion(type, kind, HType.UNKNOWN, this); |
1125 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { | 1126 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { |
1126 // Boolean conversion checks work on non-nullable booleans. | 1127 // Boolean conversion checks work on non-nullable booleans. |
1127 return new HTypeConversion(type, kind, HType.BOOLEAN, this); | 1128 return new HTypeConversion(type, kind, HType.BOOLEAN, this); |
1128 } else if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.isRaw) { | 1129 } else if (kind == HTypeConversion.CHECKED_MODE_CHECK && !type.isRaw) { |
1129 throw 'creating compound check to $type (this = ${this})'; | 1130 throw 'creating compound check to $type (this = ${this})'; |
1130 } else { | 1131 } else { |
1131 HType subtype = new HType.subtype(type, compiler); | 1132 HType subtype = new HType.subtype(type, compiler); |
1132 return new HTypeConversion(type, kind, subtype, this); | 1133 return new HTypeConversion(type, kind, subtype, this); |
1133 } | 1134 } |
(...skipping 1578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 HBasicBlock get start => expression.start; | 2713 HBasicBlock get start => expression.start; |
2713 HBasicBlock get end { | 2714 HBasicBlock get end { |
2714 // We don't create a switch block if there are no cases. | 2715 // We don't create a switch block if there are no cases. |
2715 assert(!statements.isEmpty); | 2716 assert(!statements.isEmpty); |
2716 return statements.last.end; | 2717 return statements.last.end; |
2717 } | 2718 } |
2718 | 2719 |
2719 bool accept(HStatementInformationVisitor visitor) => | 2720 bool accept(HStatementInformationVisitor visitor) => |
2720 visitor.visitSwitchInfo(this); | 2721 visitor.visitSwitchInfo(this); |
2721 } | 2722 } |
OLD | NEW |