diff options
| author | Graydon Hoare <[email protected]> | 2011-04-05 21:21:32 +0000 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-04-05 21:52:48 +0000 |
| commit | 8703c8067fb8a22ec9b296efea162aac3e7f9521 (patch) | |
| tree | c83079b978da5eb7db59ba80810c96bdfeb71099 /src/comp | |
| parent | Oops -- if we're going to use the pretty-printer, we need it to work. (diff) | |
| download | rust-8703c8067fb8a22ec9b296efea162aac3e7f9521.tar.xz rust-8703c8067fb8a22ec9b296efea162aac3e7f9521.zip | |
FIx native wrapper generation to handle more arg types.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/trans.rs | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 1ab8a18d..6e3550bd 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -6148,7 +6148,7 @@ fn decl_native_fn_and_pair(@crate_ctxt cx, auto arg_n = 3u; auto pass_task; - auto lltaskptr = bcx.build.PtrToInt(fcx.lltaskptr, T_int()); + auto lltaskptr = vp2i(bcx, fcx.lltaskptr); alt (abi) { case (ast.native_abi_rust) { pass_task = true; @@ -6156,7 +6156,7 @@ fn decl_native_fn_and_pair(@crate_ctxt cx, for each (uint i in _uint.range(0u, num_ty_param)) { auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n); check (llarg as int != 0); - call_args += vec(bcx.build.PointerCast(llarg, T_i32())); + call_args += vec(vp2i(bcx, llarg)); arg_n += 1u; } } @@ -6169,6 +6169,26 @@ fn decl_native_fn_and_pair(@crate_ctxt cx, } } + fn push_arg(@block_ctxt cx, + &mutable vec[ValueRef] args, + ValueRef v, + @ty.t t) { + if (ty.type_is_integral(t)) { + auto lldsttype = T_int(); + auto llsrctype = type_of(cx.fcx.ccx, t); + if (llvm.LLVMGetIntTypeWidth(lldsttype) > + llvm.LLVMGetIntTypeWidth(llsrctype)) { + args += vec(cx.build.ZExtOrBitCast(v, T_int())); + } else { + args += vec(cx.build.TruncOrBitCast(v, T_int())); + } + } else if (ty.type_is_fp(t)) { + args += vec(cx.build.FPToSI(v, T_int())); + } else { + args += vec(vp2i(cx, v)); + } + } + auto r; auto rptr; auto args = ty.ty_fn_args(fn_type); @@ -6192,7 +6212,7 @@ fn decl_native_fn_and_pair(@crate_ctxt cx, for (ty.arg arg in args) { auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n); check (llarg as int != 0); - call_args += vec(bcx.build.PointerCast(llarg, T_i32())); + push_arg(bcx, call_args, llarg, arg.ty); arg_n += 1u; } |