rustc: Generate types in trans for the C-stack native ABI

This commit is contained in:
Patrick Walton 2011-09-28 15:15:54 -07:00
parent 4dafbcd992
commit 41ab324539
1 changed files with 21 additions and 2 deletions

View File

@ -194,8 +194,12 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
T_fn_pair(*cx, type_of_fn_from_ty(cx, sp, t, 0u))
}
ty::ty_native_fn(abi, args, out) {
let nft = native_fn_wrapper_type(cx, sp, 0u, t);
T_fn_pair(*cx, nft)
if native_abi_requires_pair(abi) {
let nft = native_fn_wrapper_type(cx, sp, 0u, t);
T_fn_pair(*cx, nft)
} else {
raw_native_fn_type(cx, sp, args, out)
}
}
ty::ty_obj(meths) { cx.rust_object_type }
ty::ty_res(_, sub, tps) {
@ -5658,6 +5662,15 @@ fn native_fn_ty_param_count(cx: @crate_ctxt, id: ast::node_id) -> uint {
ret count;
}
fn native_abi_requires_pair(abi: ast::native_abi) -> bool {
alt abi {
ast::native_abi_rust. | ast::native_abi_cdecl. |
ast::native_abi_llvm. | ast::native_abi_rust_intrinsic. |
ast::native_abi_x86stdcall. { ret true; }
ast::native_abi_c_stack_cdecl. { ret false; }
}
}
fn native_fn_wrapper_type(cx: @crate_ctxt, sp: span, ty_param_count: uint,
x: ty::t) -> TypeRef {
alt ty::struct(cx.tcx, x) {
@ -5669,6 +5682,12 @@ fn native_fn_wrapper_type(cx: @crate_ctxt, sp: span, ty_param_count: uint,
}
}
fn raw_native_fn_type(ccx: @crate_ctxt, sp: span, args: [ty::arg],
ret_ty: ty::t) -> TypeRef {
check type_has_static_size(ccx, ret_ty);
ret T_fn(type_of_explicit_args(ccx, sp, args), type_of(ccx, sp, ret_ty));
}
fn register_native_fn(ccx: @crate_ctxt, sp: span, path: [str], name: str,
id: ast::node_id) {
let path = path;