1
Fork 0

rustc: Handle alias parameters in native functions properly

This commit is contained in:
Patrick Walton 2011-04-29 11:54:41 -07:00
parent 5d3e553141
commit f0d24ff49e

View file

@ -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));
}