OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library dart2js.ir_builder; | 5 library dart2js.ir_builder; |
6 | 6 |
7 import '../closure.dart' as closure; | 7 import '../closure.dart' as closure; |
8 import '../common.dart'; | 8 import '../common.dart'; |
9 import '../common/names.dart' show Selectors; | 9 import '../common/names.dart' show Selectors; |
10 import '../compile_time_constants.dart' show BackendConstantEnvironment; | 10 import '../compile_time_constants.dart' show BackendConstantEnvironment; |
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2727 /// Creates a type test or type cast of [value] against [type]. | 2727 /// Creates a type test or type cast of [value] against [type]. |
2728 ir.Primitive buildTypeOperator( | 2728 ir.Primitive buildTypeOperator( |
2729 ir.Primitive value, DartType type, SourceInformation sourceInformation, | 2729 ir.Primitive value, DartType type, SourceInformation sourceInformation, |
2730 {bool isTypeTest}) { | 2730 {bool isTypeTest}) { |
2731 assert(isOpen); | 2731 assert(isOpen); |
2732 assert(isTypeTest != null); | 2732 assert(isTypeTest != null); |
2733 | 2733 |
2734 type = program.unaliasType(type); | 2734 type = program.unaliasType(type); |
2735 | 2735 |
2736 if (type.isMalformed) { | 2736 if (type.isMalformed) { |
2737 ErroneousElement element = type.element; | 2737 String message; |
2738 ir.Primitive message = buildStringConstant(element.message); | 2738 if (type is MalformedType) { |
| 2739 ErroneousElement element = type.element; |
| 2740 message = element.message; |
| 2741 } else { |
| 2742 assert(type is MethodTypeVariableType); |
| 2743 message = "Method type variables are not reified, " |
| 2744 "so they cannot be tested dynamically"; |
| 2745 } |
| 2746 ir.Primitive irMessage = buildStringConstant(message); |
2739 return buildStaticFunctionInvocation(program.throwTypeErrorHelper, | 2747 return buildStaticFunctionInvocation(program.throwTypeErrorHelper, |
2740 <ir.Primitive>[message], sourceInformation); | 2748 <ir.Primitive>[irMessage], sourceInformation); |
2741 } | 2749 } |
2742 | 2750 |
2743 List<ir.Primitive> typeArguments = const <ir.Primitive>[]; | 2751 List<ir.Primitive> typeArguments = const <ir.Primitive>[]; |
2744 if (type is GenericType && type.typeArguments.isNotEmpty) { | 2752 if (type is GenericType && type.typeArguments.isNotEmpty) { |
2745 typeArguments = type.typeArguments.map(buildTypeExpression).toList(); | 2753 typeArguments = type.typeArguments.map(buildTypeExpression).toList(); |
2746 } else if (type is TypeVariableType) { | 2754 } else if (type is TypeVariableType) { |
2747 typeArguments = <ir.Primitive>[buildTypeVariableAccess(type)]; | 2755 typeArguments = <ir.Primitive>[buildTypeVariableAccess(type)]; |
2748 } else if (type is FunctionType) { | 2756 } else if (type is FunctionType) { |
2749 typeArguments = <ir.Primitive>[buildTypeExpression(type)]; | 2757 typeArguments = <ir.Primitive>[buildTypeExpression(type)]; |
2750 } | 2758 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2910 this.sourceInformation}); | 2918 this.sourceInformation}); |
2911 } | 2919 } |
2912 | 2920 |
2913 class SwitchCaseInfo { | 2921 class SwitchCaseInfo { |
2914 final SubbuildFunction buildCondition; | 2922 final SubbuildFunction buildCondition; |
2915 final SubbuildFunction buildBody; | 2923 final SubbuildFunction buildBody; |
2916 final SourceInformation sourceInformation; | 2924 final SourceInformation sourceInformation; |
2917 | 2925 |
2918 SwitchCaseInfo(this.buildCondition, this.buildBody, this.sourceInformation); | 2926 SwitchCaseInfo(this.buildCondition, this.buildBody, this.sourceInformation); |
2919 } | 2927 } |
OLD | NEW |