Skip to content

Commit 41ab324

Browse files
committed
rustc: Generate types in trans for the C-stack native ABI
1 parent 4dafbcd commit 41ab324

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/comp/middle/trans.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,12 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
194194
T_fn_pair(*cx, type_of_fn_from_ty(cx, sp, t, 0u))
195195
}
196196
ty::ty_native_fn(abi, args, out) {
197-
let nft = native_fn_wrapper_type(cx, sp, 0u, t);
198-
T_fn_pair(*cx, nft)
197+
if native_abi_requires_pair(abi) {
198+
let nft = native_fn_wrapper_type(cx, sp, 0u, t);
199+
T_fn_pair(*cx, nft)
200+
} else {
201+
raw_native_fn_type(cx, sp, args, out)
202+
}
199203
}
200204
ty::ty_obj(meths) { cx.rust_object_type }
201205
ty::ty_res(_, sub, tps) {
@@ -5658,6 +5662,15 @@ fn native_fn_ty_param_count(cx: @crate_ctxt, id: ast::node_id) -> uint {
56585662
ret count;
56595663
}
56605664

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+
56615674
fn native_fn_wrapper_type(cx: @crate_ctxt, sp: span, ty_param_count: uint,
56625675
x: ty::t) -> TypeRef {
56635676
alt ty::struct(cx.tcx, x) {
@@ -5669,6 +5682,12 @@ fn native_fn_wrapper_type(cx: @crate_ctxt, sp: span, ty_param_count: uint,
56695682
}
56705683
}
56715684

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+
56725691
fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
56735692
id: ast::node_id) {
56745693
let path = path;

0 commit comments

Comments
 (0)