@@ -194,8 +194,12 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
194
194
T_fn_pair ( * cx, type_of_fn_from_ty ( cx, sp, t, 0 u) )
195
195
}
196
196
ty:: ty_native_fn ( abi, args, out) {
197
- let nft = native_fn_wrapper_type ( cx, sp, 0 u, t) ;
198
- T_fn_pair ( * cx, nft)
197
+ if native_abi_requires_pair ( abi) {
198
+ let nft = native_fn_wrapper_type ( cx, sp, 0 u, t) ;
199
+ T_fn_pair ( * cx, nft)
200
+ } else {
201
+ raw_native_fn_type ( cx, sp, args, out)
202
+ }
199
203
}
200
204
ty:: ty_obj ( meths) { cx. rust_object_type }
201
205
ty:: ty_res ( _, sub, tps) {
@@ -5658,6 +5662,15 @@ fn native_fn_ty_param_count(cx: @crate_ctxt, id: ast::node_id) -> uint {
5658
5662
ret count;
5659
5663
}
5660
5664
5665
+ fn native_abi_requires_pair ( abi : ast:: native_abi ) -> bool {
5666
+ alt abi {
5667
+ ast : : native_abi_rust. | ast:: native_abi_cdecl. |
5668
+ ast:: native_abi_llvm. | ast:: native_abi_rust_intrinsic. |
5669
+ ast:: native_abi_x86stdcall. { ret true ; }
5670
+ ast:: native_abi_c_stack_cdecl. { ret false ; }
5671
+ }
5672
+ }
5673
+
5661
5674
fn native_fn_wrapper_type ( cx : @crate_ctxt , sp : span , ty_param_count : uint ,
5662
5675
x : ty:: t ) -> TypeRef {
5663
5676
alt ty:: struct ( cx. tcx , x) {
@@ -5669,6 +5682,12 @@ fn native_fn_wrapper_type(cx: @crate_ctxt, sp: span, ty_param_count: uint,
5669
5682
}
5670
5683
}
5671
5684
5685
+ fn raw_native_fn_type ( ccx : @crate_ctxt , sp : span , args : [ ty:: arg ] ,
5686
+ ret_ty : ty:: t ) -> TypeRef {
5687
+ check type_has_static_size ( ccx, ret_ty) ;
5688
+ ret T_fn ( type_of_explicit_args ( ccx, sp, args) , type_of ( ccx, sp, ret_ty) ) ;
5689
+ }
5690
+
5672
5691
fn register_native_fn( ccx : @crate_ctxt , sp : span , path : [ str ] , name : str ,
5673
5692
id : ast:: node_id ) {
5674
5693
let path = path;
0 commit comments