diff options
| author | Patrick Walton <[email protected]> | 2011-04-29 11:54:41 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-04-29 11:54:41 -0700 |
| commit | f0d24ff49e1578bf28de3cad808c8d68437c44d4 (patch) | |
| tree | 71b2bde2fb233d43ab1a23b8bd84b4200edc98ad /src/comp/middle | |
| parent | stdlib: Add a Time module to the standard library (diff) | |
| download | rust-f0d24ff49e1578bf28de3cad808c8d68437c44d4.tar.xz rust-f0d24ff49e1578bf28de3cad808c8d68437c44d4.zip | |
rustc: Handle alias parameters in native functions properly
Diffstat (limited to 'src/comp/middle')
| -rw-r--r-- | src/comp/middle/trans.rs | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 788c2fee..54ad505e 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -6655,21 +6655,27 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx, fn push_arg(@block_ctxt cx, &mutable vec[ValueRef] args, ValueRef v, - ty.t t) { - if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t)) { - auto lldsttype = T_int(); - auto llsrctype = type_of(cx.fcx.lcx.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())); + ty.t t, + ast.mode mode) { + if (mode == ast.val) { + if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t)) { + auto lldsttype = T_int(); + auto llsrctype = type_of(cx.fcx.lcx.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())); + } + ret; + } + if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) { + args += vec(cx.build.FPToSI(v, T_int())); + ret; } - } else if (ty.type_is_fp(cx.fcx.lcx.ccx.tcx, t)) { - args += vec(cx.build.FPToSI(v, T_int())); - } else { - args += vec(vp2i(cx, v)); } + + args += vec(vp2i(cx, v)); } auto r; @@ -6699,7 +6705,7 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx, for (ty.arg arg in args) { auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n); check (llarg as int != 0); - push_arg(bcx, call_args, llarg, arg.ty); + push_arg(bcx, call_args, llarg, arg.ty, arg.mode); if (arg.mode == ast.val) { drop_args += vec(tup(llarg, arg.ty)); } |