about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-09-28 15:15:54 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-09-29 17:34:49 -0700
commit41ab324539976cadc01f3d150b976cc4d2ca9d1d (patch)
tree2c8d078aec43b0dc5d5a7f12d431a67a533c469b /src/comp
parent4dafbcd992f756c41943b2444e57bddb6127ab3a (diff)
rustc: Generate types in trans for the C-stack native ABI
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/middle/trans.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index e53b18b916f..765e5815983 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -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;