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 visitBitAnd(HBitAnd node); | 9 R visitBitAnd(HBitAnd node); |
10 R visitBitNot(HBitNot node); | 10 R visitBitNot(HBitNot node); |
(...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 return false; | 1220 return false; |
1221 } | 1221 } |
1222 | 1222 |
1223 HInstruction convertType(Compiler compiler, DartType type, int kind) { | 1223 HInstruction convertType(Compiler compiler, DartType type, int kind) { |
1224 if (type == null) return this; | 1224 if (type == null) return this; |
1225 type = type.unalias(compiler); | 1225 type = type.unalias(compiler); |
1226 // Only the builder knows how to create [HTypeConversion] | 1226 // Only the builder knows how to create [HTypeConversion] |
1227 // instructions with generics. It has the generic type context | 1227 // instructions with generics. It has the generic type context |
1228 // available. | 1228 // available. |
1229 assert(type.kind != TypeKind.TYPE_VARIABLE); | 1229 assert(type.kind != TypeKind.TYPE_VARIABLE); |
1230 assert(type.treatAsRaw || type.kind == TypeKind.FUNCTION); | 1230 assert(type.treatAsRaw || type.isFunctionType); |
1231 if (type.isDynamic) return this; | 1231 if (type.isDynamic) return this; |
1232 // The type element is either a class or the void element. | 1232 // The type element is either a class or the void element. |
1233 Element element = type.element; | 1233 Element element = type.element; |
1234 if (identical(element, compiler.objectClass)) return this; | 1234 if (identical(element, compiler.objectClass)) return this; |
1235 JavaScriptBackend backend = compiler.backend; | 1235 JavaScriptBackend backend = compiler.backend; |
1236 if (type.kind != TypeKind.INTERFACE) { | 1236 if (type.kind != TypeKind.INTERFACE) { |
1237 return new HTypeConversion(type, kind, backend.dynamicType, this); | 1237 return new HTypeConversion(type, kind, backend.dynamicType, this); |
1238 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { | 1238 } else if (kind == HTypeConversion.BOOLEAN_CONVERSION_CHECK) { |
1239 // Boolean conversion checks work on non-nullable booleans. | 1239 // Boolean conversion checks work on non-nullable booleans. |
1240 return new HTypeConversion(type, kind, backend.boolType, this); | 1240 return new HTypeConversion(type, kind, backend.boolType, this); |
(...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 HInstruction context, | 2489 HInstruction context, |
2490 {bool this.contextIsTypeArguments}) | 2490 {bool this.contextIsTypeArguments}) |
2491 : super(<HInstruction>[input, context], type), | 2491 : super(<HInstruction>[input, context], type), |
2492 checkedType = type, | 2492 checkedType = type, |
2493 receiverTypeCheckSelector = null { | 2493 receiverTypeCheckSelector = null { |
2494 assert(typeExpression.kind != TypeKind.TYPEDEF); | 2494 assert(typeExpression.kind != TypeKind.TYPEDEF); |
2495 sourceElement = input.sourceElement; | 2495 sourceElement = input.sourceElement; |
2496 } | 2496 } |
2497 | 2497 |
2498 bool get hasTypeRepresentation { | 2498 bool get hasTypeRepresentation { |
2499 return typeExpression.kind == TypeKind.INTERFACE && inputs.length > 1; | 2499 return typeExpression.isInterfaceType && inputs.length > 1; |
2500 } | 2500 } |
2501 HInstruction get typeRepresentation => inputs[1]; | 2501 HInstruction get typeRepresentation => inputs[1]; |
2502 | 2502 |
2503 bool get hasContext { | 2503 bool get hasContext { |
2504 return typeExpression.kind == TypeKind.FUNCTION && inputs.length > 1; | 2504 return typeExpression.isFunctionType && inputs.length > 1; |
2505 } | 2505 } |
2506 HInstruction get context => inputs[1]; | 2506 HInstruction get context => inputs[1]; |
2507 | 2507 |
2508 HInstruction convertType(Compiler compiler, DartType type, int kind) { | 2508 HInstruction convertType(Compiler compiler, DartType type, int kind) { |
2509 if (typeExpression == type) return this; | 2509 if (typeExpression == type) return this; |
2510 return super.convertType(compiler, type, kind); | 2510 return super.convertType(compiler, type, kind); |
2511 } | 2511 } |
2512 | 2512 |
2513 bool get isCheckedModeCheck { | 2513 bool get isCheckedModeCheck { |
2514 return kind == CHECKED_MODE_CHECK | 2514 return kind == CHECKED_MODE_CHECK |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3033 class HDynamicType extends HRuntimeType { | 3033 class HDynamicType extends HRuntimeType { |
3034 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3034 HDynamicType(DynamicType dartType, TypeMask instructionType) |
3035 : super(const <HInstruction>[], dartType, instructionType); | 3035 : super(const <HInstruction>[], dartType, instructionType); |
3036 | 3036 |
3037 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3037 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
3038 | 3038 |
3039 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3039 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
3040 | 3040 |
3041 bool typeEquals(HInstruction other) => other is HDynamicType; | 3041 bool typeEquals(HInstruction other) => other is HDynamicType; |
3042 } | 3042 } |
OLD | NEW |