@@ -317,7 +317,7 @@ impl<'a> AstBytecodeGen<'a> {
317
317
let context_register = self . builder . alloc_global ( BytecodeType :: Ptr ) ;
318
318
let idx = self . builder . add_const_cls_types (
319
319
ClassId ( class_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
320
- convert_tya ( & self . identity_type_params ( ) ) ,
320
+ self . emitter . convert_tya ( & self . identity_type_params ( ) ) ,
321
321
) ;
322
322
self . builder
323
323
. emit_new_object ( context_register, idx, self . loc ( self . span ) ) ;
@@ -352,7 +352,7 @@ impl<'a> AstBytecodeGen<'a> {
352
352
assert ! ( context_data. has_parent_slot( ) ) ;
353
353
let idx = self . builder . add_const_field_types (
354
354
ClassId ( class_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
355
- convert_tya ( & self . identity_type_params ( ) ) ,
355
+ self . emitter . convert_tya ( & self . identity_type_params ( ) ) ,
356
356
0 ,
357
357
) ;
358
358
self . builder . emit_store_field (
@@ -706,7 +706,7 @@ impl<'a> AstBytecodeGen<'a> {
706
706
let enum_ = self . sa . enum_ ( enum_id) ;
707
707
708
708
let bc_enum_id = EnumId ( enum_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ;
709
- let bc_enum_type_params = convert_tya ( enum_type_params) ;
709
+ let bc_enum_type_params = self . emitter . convert_tya ( enum_type_params) ;
710
710
711
711
let match_reg = self . alloc_temp ( BytecodeType :: Bool ) ;
712
712
let actual_variant_reg = self . alloc_temp ( BytecodeType :: Int32 ) ;
@@ -772,7 +772,7 @@ impl<'a> AstBytecodeGen<'a> {
772
772
let register_ty = register_bty_from_ty ( field_ty. clone ( ) ) ;
773
773
let idx = self . builder . add_const_struct_field (
774
774
StructId ( struct_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
775
- convert_tya ( struct_type_params) ,
775
+ self . convert_tya ( struct_type_params) ,
776
776
idx as u32 ,
777
777
) ;
778
778
let temp_reg = self . alloc_temp ( register_ty) ;
@@ -799,7 +799,7 @@ impl<'a> AstBytecodeGen<'a> {
799
799
let register_ty = register_bty_from_ty ( field_ty. clone ( ) ) ;
800
800
let idx = self . builder . add_const_field_types (
801
801
ClassId ( class_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
802
- convert_tya ( class_type_params) ,
802
+ self . convert_tya ( class_type_params) ,
803
803
idx as u32 ,
804
804
) ;
805
805
let temp_reg = self . alloc_temp ( register_ty) ;
@@ -887,7 +887,7 @@ impl<'a> AstBytecodeGen<'a> {
887
887
self . builder . emit_push_register ( object_reg) ;
888
888
let fct_idx = self . builder . add_const_fct_types (
889
889
FunctionId ( iter_fct_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
890
- convert_tya ( & iter_type_params) ,
890
+ self . convert_tya ( & iter_type_params) ,
891
891
) ;
892
892
self . builder
893
893
. emit_invoke_direct ( iterator_reg, fct_idx, self . loc ( stmt. expr . span ( ) ) ) ;
@@ -903,7 +903,7 @@ impl<'a> AstBytecodeGen<'a> {
903
903
self . enter_block_context ( stmt. id ) ;
904
904
905
905
let iterator_type = for_type_info. iterator_type . clone ( ) ;
906
- let iterator_type_params = convert_tya ( & iterator_type. type_params ( ) ) ;
906
+ let iterator_type_params = self . convert_tya ( & iterator_type. type_params ( ) ) ;
907
907
908
908
self . builder . emit_push_register ( iterator_reg) ;
909
909
@@ -948,7 +948,7 @@ impl<'a> AstBytecodeGen<'a> {
948
948
. try_into ( )
949
949
. expect ( "overflow" ) ,
950
950
) ,
951
- convert_tya ( & option_type_params) ,
951
+ self . convert_tya ( & option_type_params) ,
952
952
) ;
953
953
self . builder . emit_push_register ( next_result_reg) ;
954
954
self . builder
@@ -972,7 +972,7 @@ impl<'a> AstBytecodeGen<'a> {
972
972
. try_into ( )
973
973
. expect ( "overflow" ) ,
974
974
) ,
975
- convert_tya ( & option_type_params) ,
975
+ self . convert_tya ( & option_type_params) ,
976
976
) ;
977
977
self . builder . emit_push_register ( next_result_reg) ;
978
978
self . builder
@@ -1141,7 +1141,7 @@ impl<'a> AstBytecodeGen<'a> {
1141
1141
. get ( part. id ( ) )
1142
1142
. expect ( "missing toString id" ) ;
1143
1143
1144
- let type_params = convert_tya ( & type_params) ;
1144
+ let type_params = self . convert_tya ( & type_params) ;
1145
1145
1146
1146
let fct_idx = self . builder . add_const_fct_types (
1147
1147
FunctionId ( to_string_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
@@ -1212,7 +1212,7 @@ impl<'a> AstBytecodeGen<'a> {
1212
1212
location : Location ,
1213
1213
dest : DataDest ,
1214
1214
) -> Register {
1215
- let type_params = convert_tya ( & type_params) ;
1215
+ let type_params = self . convert_tya ( & type_params) ;
1216
1216
let enum_id = EnumId ( enum_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ;
1217
1217
let bty = BytecodeType :: Enum ( enum_id, type_params. clone ( ) ) ;
1218
1218
let dest = self . ensure_register ( dest, bty) ;
@@ -1312,7 +1312,7 @@ impl<'a> AstBytecodeGen<'a> {
1312
1312
1313
1313
let idx = self . builder . add_const_fct_types (
1314
1314
FunctionId ( lambda_fct_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
1315
- convert_tya ( & self . identity_type_params ( ) ) ,
1315
+ self . convert_tya ( & self . identity_type_params ( ) ) ,
1316
1316
) ;
1317
1317
self . builder . emit_new_lambda ( dest, idx, self . loc ( node. span ) ) ;
1318
1318
@@ -1396,7 +1396,7 @@ impl<'a> AstBytecodeGen<'a> {
1396
1396
1397
1397
let field_idx = self . builder . add_const_field_types (
1398
1398
ClassId ( cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
1399
- convert_tya ( & type_params) ,
1399
+ self . convert_tya ( & type_params) ,
1400
1400
field_id. 0 as u32 ,
1401
1401
) ;
1402
1402
@@ -1440,7 +1440,7 @@ impl<'a> AstBytecodeGen<'a> {
1440
1440
let dest = self . ensure_register ( dest, ty) ;
1441
1441
let const_idx = self . builder . add_const_struct_field (
1442
1442
StructId ( struct_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
1443
- convert_tya ( & type_params) ,
1443
+ self . convert_tya ( & type_params) ,
1444
1444
field_idx. 0 as u32 ,
1445
1445
) ;
1446
1446
self . builder
@@ -1599,7 +1599,7 @@ impl<'a> AstBytecodeGen<'a> {
1599
1599
1600
1600
let idx = self . builder . add_const_enum_variant (
1601
1601
EnumId ( enum_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
1602
- convert_tya ( & type_params) ,
1602
+ self . convert_tya ( & type_params) ,
1603
1603
variant_idx,
1604
1604
) ;
1605
1605
let bytecode_ty = register_bty_from_ty ( enum_ty) ;
@@ -1635,7 +1635,7 @@ impl<'a> AstBytecodeGen<'a> {
1635
1635
}
1636
1636
1637
1637
let idx = self . builder . add_const_lambda (
1638
- convert_tya ( & params) ,
1638
+ self . convert_tya ( & params) ,
1639
1639
self . emitter . convert_ty ( return_type. clone ( ) ) ,
1640
1640
) ;
1641
1641
@@ -1680,8 +1680,8 @@ impl<'a> AstBytecodeGen<'a> {
1680
1680
1681
1681
let idx = self
1682
1682
. builder
1683
- . add_const_struct ( struct_id, convert_tya ( & type_params) ) ;
1684
- let bytecode_ty = BytecodeType :: Struct ( struct_id, convert_tya ( type_params) ) ;
1683
+ . add_const_struct ( struct_id, self . convert_tya ( & type_params) ) ;
1684
+ let bytecode_ty = BytecodeType :: Struct ( struct_id, self . convert_tya ( type_params) ) ;
1685
1685
let dest_reg = self . ensure_register ( dest, bytecode_ty) ;
1686
1686
self . builder
1687
1687
. emit_new_struct ( dest_reg, idx, self . loc ( expr. span ) ) ;
@@ -1722,7 +1722,7 @@ impl<'a> AstBytecodeGen<'a> {
1722
1722
let cls_id = ClassId ( cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ;
1723
1723
let idx = self
1724
1724
. builder
1725
- . add_const_cls_types ( cls_id, convert_tya ( type_params) ) ;
1725
+ . add_const_cls_types ( cls_id, self . convert_tya ( type_params) ) ;
1726
1726
let dest_reg = self . ensure_register ( dest, BytecodeType :: Ptr ) ;
1727
1727
self . builder
1728
1728
. emit_new_object_initialized ( dest_reg, idx, self . loc ( expr. span ) ) ;
@@ -1847,7 +1847,7 @@ impl<'a> AstBytecodeGen<'a> {
1847
1847
let ( cls_id, type_params) = ty. to_class ( ) . expect ( "class expected" ) ;
1848
1848
let cls_idx = self . builder . add_const_cls_types (
1849
1849
ClassId ( cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
1850
- convert_tya ( & type_params) ,
1850
+ self . convert_tya ( & type_params) ,
1851
1851
) ;
1852
1852
1853
1853
// Store length in a register
@@ -2111,7 +2111,7 @@ impl<'a> AstBytecodeGen<'a> {
2111
2111
}
2112
2112
2113
2113
let subtypes = ty. tuple_subtypes ( ) . expect ( "tuple expected" ) ;
2114
- let idx = self . builder . add_const_tuple ( convert_tya ( & subtypes) ) ;
2114
+ let idx = self . builder . add_const_tuple ( self . convert_tya ( & subtypes) ) ;
2115
2115
self . builder . emit_new_tuple ( result, idx, self . loc ( e. span ) ) ;
2116
2116
2117
2117
for arg_reg in values {
@@ -2338,7 +2338,7 @@ impl<'a> AstBytecodeGen<'a> {
2338
2338
let ( cls_id, type_params) = element_ty. to_class ( ) . expect ( "class expected" ) ;
2339
2339
let cls_idx = self . builder . add_const_cls_types (
2340
2340
ClassId ( cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
2341
- convert_tya ( & type_params) ,
2341
+ self . convert_tya ( & type_params) ,
2342
2342
) ;
2343
2343
2344
2344
let array_reg = self . ensure_register ( dest, BytecodeType :: Ptr ) ;
@@ -2469,7 +2469,7 @@ impl<'a> AstBytecodeGen<'a> {
2469
2469
let intrinsic = info. intrinsic ;
2470
2470
2471
2471
let fct = self . sa . fct ( info. fct_id . expect ( "missing method" ) ) ;
2472
- let ty = fct. return_type_bty ( ) ;
2472
+ let ty = self . emitter . convert_ty ( fct. return_type ( ) ) ;
2473
2473
let dest = self . ensure_register ( dest, ty) ;
2474
2474
2475
2475
let src = gen_expr ( self , opnd, DataDest :: Alloc ) ;
@@ -2518,7 +2518,7 @@ impl<'a> AstBytecodeGen<'a> {
2518
2518
let fct_id = info. fct_id . expect ( "missing function" ) ;
2519
2519
let fct = self . sa . fct ( fct_id) ;
2520
2520
2521
- let result_type = fct. return_type_bty ( ) ;
2521
+ let result_type = self . emitter . convert_ty ( fct. return_type ( ) ) ;
2522
2522
2523
2523
let dest = self . ensure_register ( dest, result_type) ;
2524
2524
@@ -2611,7 +2611,7 @@ impl<'a> AstBytecodeGen<'a> {
2611
2611
2612
2612
let callee_idx = self . builder . add_const_fct_types (
2613
2613
FunctionId ( fct_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
2614
- convert_tya ( & type_params) ,
2614
+ self . convert_tya ( & type_params) ,
2615
2615
) ;
2616
2616
self . builder
2617
2617
. emit_invoke_direct ( current, callee_idx, location) ;
@@ -2647,7 +2647,7 @@ impl<'a> AstBytecodeGen<'a> {
2647
2647
2648
2648
let callee_idx = self . builder . add_const_fct_types (
2649
2649
FunctionId ( fct_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
2650
- convert_tya ( & type_params) ,
2650
+ self . convert_tya ( & type_params) ,
2651
2651
) ;
2652
2652
let dest = self . ensure_unit_register ( ) ;
2653
2653
self . builder . emit_invoke_direct ( dest, callee_idx, location) ;
@@ -2672,7 +2672,7 @@ impl<'a> AstBytecodeGen<'a> {
2672
2672
2673
2673
let field_idx = self . builder . add_const_field_types (
2674
2674
ClassId ( cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
2675
- convert_tya ( & type_params) ,
2675
+ self . convert_tya ( & type_params) ,
2676
2676
field_id. 0 as u32 ,
2677
2677
) ;
2678
2678
@@ -2884,7 +2884,7 @@ impl<'a> AstBytecodeGen<'a> {
2884
2884
let outer_cls_id = outer_context_class. class_id ( ) ;
2885
2885
let idx = self . builder . add_const_field_types (
2886
2886
ClassId ( outer_cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
2887
- convert_tya ( & self . identity_type_params ( ) ) ,
2887
+ self . convert_tya ( & self . identity_type_params ( ) ) ,
2888
2888
0 ,
2889
2889
) ;
2890
2890
assert ! ( outer_context_class. has_parent_slot( ) ) ;
@@ -2905,7 +2905,7 @@ impl<'a> AstBytecodeGen<'a> {
2905
2905
2906
2906
let idx = self . builder . add_const_field_types (
2907
2907
ClassId ( outer_cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
2908
- convert_tya ( & self . identity_type_params ( ) ) ,
2908
+ self . convert_tya ( & self . identity_type_params ( ) ) ,
2909
2909
field_id. 0 as u32 ,
2910
2910
) ;
2911
2911
self . builder
@@ -3052,7 +3052,7 @@ impl<'a> AstBytecodeGen<'a> {
3052
3052
3053
3053
let idx = self . builder . add_const_field_types (
3054
3054
ClassId ( outer_cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
3055
- convert_tya ( & self . identity_type_params ( ) ) ,
3055
+ self . convert_tya ( & self . identity_type_params ( ) ) ,
3056
3056
0 ,
3057
3057
) ;
3058
3058
self . builder
@@ -3072,7 +3072,7 @@ impl<'a> AstBytecodeGen<'a> {
3072
3072
. try_into ( )
3073
3073
. expect ( "overflow" ) ,
3074
3074
) ,
3075
- convert_tya ( & self . identity_type_params ( ) ) ,
3075
+ self . convert_tya ( & self . identity_type_params ( ) ) ,
3076
3076
field_id. 0 as u32 ,
3077
3077
) ;
3078
3078
self . builder
@@ -3114,7 +3114,7 @@ impl<'a> AstBytecodeGen<'a> {
3114
3114
let outer_cls_id = outer_context_class. class_id ( ) ;
3115
3115
let idx = self . builder . add_const_field_types (
3116
3116
ClassId ( outer_cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
3117
- convert_tya ( & self . identity_type_params ( ) ) ,
3117
+ self . convert_tya ( & self . identity_type_params ( ) ) ,
3118
3118
0 ,
3119
3119
) ;
3120
3120
assert ! ( outer_context_class. has_parent_slot( ) ) ;
@@ -3135,7 +3135,7 @@ impl<'a> AstBytecodeGen<'a> {
3135
3135
3136
3136
let idx = self . builder . add_const_field_types (
3137
3137
ClassId ( outer_cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
3138
- convert_tya ( & self . identity_type_params ( ) ) ,
3138
+ self . convert_tya ( & self . identity_type_params ( ) ) ,
3139
3139
field_id. 0 as u32 ,
3140
3140
) ;
3141
3141
self . builder
@@ -3160,7 +3160,7 @@ impl<'a> AstBytecodeGen<'a> {
3160
3160
let field_id = field_id_from_context_idx ( field_id, context_data. has_parent_slot ( ) ) ;
3161
3161
let field_idx = self . builder . add_const_field_types (
3162
3162
ClassId ( cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
3163
- convert_tya ( & self . identity_type_params ( ) ) ,
3163
+ self . convert_tya ( & self . identity_type_params ( ) ) ,
3164
3164
field_id. 0 as u32 ,
3165
3165
) ;
3166
3166
self . builder
@@ -3182,7 +3182,7 @@ impl<'a> AstBytecodeGen<'a> {
3182
3182
let field_id = field_id_from_context_idx ( field_id, context_data. has_parent_slot ( ) ) ;
3183
3183
let field_idx = self . builder . add_const_field_types (
3184
3184
ClassId ( cls_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
3185
- convert_tya ( & self . identity_type_params ( ) ) ,
3185
+ self . convert_tya ( & self . identity_type_params ( ) ) ,
3186
3186
field_id. 0 as u32 ,
3187
3187
) ;
3188
3188
self . builder
@@ -3219,8 +3219,8 @@ impl<'a> AstBytecodeGen<'a> {
3219
3219
self . builder . add_const ( ConstPoolEntry :: Generic (
3220
3220
id. index ( ) as u32 ,
3221
3221
FunctionId ( fct. id ( ) . index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
3222
- convert_tya ( & trait_type_params) ,
3223
- convert_tya ( & fct_type_params) ,
3222
+ self . convert_tya ( & trait_type_params) ,
3223
+ self . convert_tya ( & fct_type_params) ,
3224
3224
) )
3225
3225
}
3226
3226
CallType :: GenericMethodSelf ( _, fct_id, ref trait_type_params, ref fct_type_params)
@@ -3231,8 +3231,8 @@ impl<'a> AstBytecodeGen<'a> {
3231
3231
ref fct_type_params,
3232
3232
) => self . builder . add_const ( ConstPoolEntry :: GenericSelf (
3233
3233
FunctionId ( fct_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
3234
- convert_tya ( & trait_type_params) ,
3235
- convert_tya ( & fct_type_params) ,
3234
+ self . convert_tya ( & trait_type_params) ,
3235
+ self . convert_tya ( & fct_type_params) ,
3236
3236
) ) ,
3237
3237
CallType :: GenericMethodNew {
3238
3238
object_type,
@@ -3241,9 +3241,9 @@ impl<'a> AstBytecodeGen<'a> {
3241
3241
fct_type_params,
3242
3242
} => self . builder . add_const ( ConstPoolEntry :: GenericNew {
3243
3243
object_type : self . emitter . convert_ty ( object_type. clone ( ) ) ,
3244
- trait_ty : convert_trait_type ( & trait_ty) ,
3244
+ trait_ty : self . emitter . convert_trait_ty ( & trait_ty) ,
3245
3245
fct_id : FunctionId ( fct_id. index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
3246
- fct_type_params : convert_tya ( fct_type_params) ,
3246
+ fct_type_params : self . convert_tya ( fct_type_params) ,
3247
3247
} ) ,
3248
3248
CallType :: TraitObjectMethod ( ref trait_object_ty, _) => {
3249
3249
self . builder . add_const ( ConstPoolEntry :: TraitObjectMethod (
@@ -3261,7 +3261,7 @@ impl<'a> AstBytecodeGen<'a> {
3261
3261
) ;
3262
3262
self . builder . add_const_fct_types (
3263
3263
FunctionId ( fct. id ( ) . index ( ) . try_into ( ) . expect ( "overflow" ) ) ,
3264
- convert_tya ( & type_params) ,
3264
+ self . convert_tya ( & type_params) ,
3265
3265
)
3266
3266
}
3267
3267
@@ -3373,6 +3373,10 @@ impl<'a> AstBytecodeGen<'a> {
3373
3373
new_identity_type_params ( 0 , self . type_params_len )
3374
3374
}
3375
3375
3376
+ fn convert_tya ( & self , ty : & SourceTypeArray ) -> BytecodeTypeArray {
3377
+ convert_tya ( & ty)
3378
+ }
3379
+
3376
3380
fn ensure_unit_register ( & mut self ) -> Register {
3377
3381
if let Some ( register) = self . unit_register {
3378
3382
return register;
0 commit comments