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