@@ -565,12 +565,12 @@ fn type_of_fn(@crate_ctxt cx,
565
565
566
566
fn type_of_native_fn ( @crate_ctxt cx , ast. native_abi abi ,
567
567
vec[ ty. arg] inputs ,
568
- @ty. t output ) -> TypeRef {
568
+ @ty. t output ,
569
+ uint ty_param_count ) -> TypeRef {
569
570
let vec[ TypeRef ] atys = vec ( ) ;
570
571
if ( abi == ast. native_abi_rust ) {
571
572
atys += vec ( T_taskptr ( cx. tn ) ) ;
572
573
auto t = ty. ty_native_fn ( abi, inputs, output) ;
573
- auto ty_param_count = ty. count_ty_params ( plain_ty ( t) ) ;
574
574
auto i = 0 u;
575
575
while ( i < ty_param_count) {
576
576
atys += vec ( T_ptr ( T_tydesc ( cx. tn ) ) ) ;
@@ -638,7 +638,8 @@ fn type_of_inner(@crate_ctxt cx, @ty.t t, bool boxed) -> TypeRef {
638
638
llty = T_fn_pair ( cx. tn , type_of_fn ( cx, proto, args, out, 0 u) ) ;
639
639
}
640
640
case ( ty. ty_native_fn ( ?abi, ?args, ?out) ) {
641
- llty = T_fn_pair ( cx. tn , type_of_native_fn ( cx, abi, args, out) ) ;
641
+ auto nft = type_of_native_fn ( cx, abi, args, out, 0 u) ;
642
+ llty = T_fn_pair ( cx. tn , nft) ;
642
643
}
643
644
case ( ty. ty_obj ( ?meths) ) {
644
645
auto th = mk_type_handle ( ) ;
@@ -5417,17 +5418,20 @@ fn decl_native_fn_and_pair(@crate_ctxt cx,
5417
5418
5418
5419
register_fn_pair ( cx, ps, wrapper_pair_type, wrapper_fn, id) ;
5419
5420
5420
- // Declare the function itself.
5421
- auto llfty = get_pair_fn_ty ( node_type ( cx, ann) ) ;
5422
- auto function = decl_cdecl_fn ( cx. llmod , name, llfty) ;
5423
-
5424
5421
// Build the wrapper.
5425
5422
auto fcx = new_fn_ctxt ( cx, wrapper_fn) ;
5426
5423
auto bcx = new_top_block_ctxt ( fcx) ;
5427
- auto fn_type = node_ann_type ( cx, ann) ;
5428
5424
5429
- let vec[ ValueRef ] call_args = vec ( ) ;
5425
+ // Declare the function itself.
5426
+ auto item = cx. native_items . get ( id) ;
5427
+ auto fn_type = node_ann_type ( cx, ann) ; // NB: has no type params
5428
+
5430
5429
auto abi = ty. ty_fn_abi ( fn_type) ;
5430
+ auto llfnty = type_of_native_fn ( cx, abi, ty. ty_fn_args ( fn_type) ,
5431
+ ty. ty_fn_ret ( fn_type) , num_ty_param) ;
5432
+ auto function = decl_cdecl_fn ( cx. llmod , name, llfnty) ;
5433
+
5434
+ let vec[ ValueRef ] call_args = vec ( ) ;
5431
5435
auto arg_n = 3 u;
5432
5436
alt ( abi) {
5433
5437
case ( ast. native_abi_rust ) {
0 commit comments