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 visitAwait(HAwait node); | 9 R visitAwait(HAwait node); |
10 R visitBitAnd(HBitAnd node); | 10 R visitBitAnd(HBitAnd node); |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 /// This used for attaching source information to reads of locals. | 1314 /// This used for attaching source information to reads of locals. |
1315 class HRef extends HInstruction { | 1315 class HRef extends HInstruction { |
1316 HRef(HInstruction value, SourceInformation sourceInformation) | 1316 HRef(HInstruction value, SourceInformation sourceInformation) |
1317 : super([value], value.instructionType) { | 1317 : super([value], value.instructionType) { |
1318 this.sourceInformation = sourceInformation; | 1318 this.sourceInformation = sourceInformation; |
1319 } | 1319 } |
1320 | 1320 |
1321 HInstruction get value => inputs[0]; | 1321 HInstruction get value => inputs[0]; |
1322 | 1322 |
1323 @override | 1323 @override |
| 1324 HInstruction convertType(Compiler compiler, DartType type, int kind) { |
| 1325 HInstruction converted = value.convertType(compiler, type, kind); |
| 1326 if (converted == value) return this; |
| 1327 HTypeConversion conversion = converted; |
| 1328 conversion.inputs[0] = this; |
| 1329 return conversion; |
| 1330 } |
| 1331 |
| 1332 @override |
1324 accept(HVisitor visitor) => visitor.visitRef(this); | 1333 accept(HVisitor visitor) => visitor.visitRef(this); |
1325 | 1334 |
1326 String toString() => 'HRef(${value})'; | 1335 String toString() => 'HRef(${value})'; |
1327 } | 1336 } |
1328 | 1337 |
1329 /** | 1338 /** |
1330 * Late instructions are used after the main optimization phases. They capture | 1339 * Late instructions are used after the main optimization phases. They capture |
1331 * codegen decisions just prior to generating JavaScript. | 1340 * codegen decisions just prior to generating JavaScript. |
1332 */ | 1341 */ |
1333 abstract class HLateInstruction extends HInstruction { | 1342 abstract class HLateInstruction extends HInstruction { |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2736 return typeExpression.isInterfaceType && inputs.length > 1; | 2745 return typeExpression.isInterfaceType && inputs.length > 1; |
2737 } | 2746 } |
2738 HInstruction get typeRepresentation => inputs[1]; | 2747 HInstruction get typeRepresentation => inputs[1]; |
2739 | 2748 |
2740 bool get hasContext { | 2749 bool get hasContext { |
2741 return typeExpression.isFunctionType && inputs.length > 1; | 2750 return typeExpression.isFunctionType && inputs.length > 1; |
2742 } | 2751 } |
2743 HInstruction get context => inputs[1]; | 2752 HInstruction get context => inputs[1]; |
2744 | 2753 |
2745 HInstruction convertType(Compiler compiler, DartType type, int kind) { | 2754 HInstruction convertType(Compiler compiler, DartType type, int kind) { |
2746 if (typeExpression == type) return this; | 2755 if (typeExpression == type) { |
| 2756 // Don't omit a boolean conversion (which doesn't allow `null`) unless |
| 2757 // this type conversion is already a boolean conversion. |
| 2758 if (kind != BOOLEAN_CONVERSION_CHECK || |
| 2759 isBooleanConversionCheck) { |
| 2760 return this; |
| 2761 } |
| 2762 } |
2747 return super.convertType(compiler, type, kind); | 2763 return super.convertType(compiler, type, kind); |
2748 } | 2764 } |
2749 | 2765 |
2750 bool get isCheckedModeCheck { | 2766 bool get isCheckedModeCheck { |
2751 return kind == CHECKED_MODE_CHECK | 2767 return kind == CHECKED_MODE_CHECK |
2752 || kind == BOOLEAN_CONVERSION_CHECK; | 2768 || kind == BOOLEAN_CONVERSION_CHECK; |
2753 } | 2769 } |
2754 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK; | 2770 bool get isArgumentTypeCheck => kind == ARGUMENT_TYPE_CHECK; |
2755 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK; | 2771 bool get isReceiverTypeCheck => kind == RECEIVER_TYPE_CHECK; |
2756 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK; | 2772 bool get isCastTypeCheck => kind == CAST_TYPE_CHECK; |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3269 class HDynamicType extends HRuntimeType { | 3285 class HDynamicType extends HRuntimeType { |
3270 HDynamicType(DynamicType dartType, TypeMask instructionType) | 3286 HDynamicType(DynamicType dartType, TypeMask instructionType) |
3271 : super(const <HInstruction>[], dartType, instructionType); | 3287 : super(const <HInstruction>[], dartType, instructionType); |
3272 | 3288 |
3273 accept(HVisitor visitor) => visitor.visitDynamicType(this); | 3289 accept(HVisitor visitor) => visitor.visitDynamicType(this); |
3274 | 3290 |
3275 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; | 3291 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; |
3276 | 3292 |
3277 bool typeEquals(HInstruction other) => other is HDynamicType; | 3293 bool typeEquals(HInstruction other) => other is HDynamicType; |
3278 } | 3294 } |
OLD | NEW |