rustc: Handle alias parameters in native functions properly
This commit is contained in:
parent
5d3e553141
commit
f0d24ff49e
1 changed files with 20 additions and 14 deletions
|
@ -6655,21 +6655,27 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
|
||||||
fn push_arg(@block_ctxt cx,
|
fn push_arg(@block_ctxt cx,
|
||||||
&mutable vec[ValueRef] args,
|
&mutable vec[ValueRef] args,
|
||||||
ValueRef v,
|
ValueRef v,
|
||||||
ty.t t) {
|
ty.t t,
|
||||||
if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t)) {
|
ast.mode mode) {
|
||||||
auto lldsttype = T_int();
|
if (mode == ast.val) {
|
||||||
auto llsrctype = type_of(cx.fcx.lcx.ccx, t);
|
if (ty.type_is_integral(cx.fcx.lcx.ccx.tcx, t)) {
|
||||||
if (llvm.LLVMGetIntTypeWidth(lldsttype) >
|
auto lldsttype = T_int();
|
||||||
llvm.LLVMGetIntTypeWidth(llsrctype)) {
|
auto llsrctype = type_of(cx.fcx.lcx.ccx, t);
|
||||||
args += vec(cx.build.ZExtOrBitCast(v, T_int()));
|
if (llvm.LLVMGetIntTypeWidth(lldsttype) >
|
||||||
} else {
|
llvm.LLVMGetIntTypeWidth(llsrctype)) {
|
||||||
args += vec(cx.build.TruncOrBitCast(v, T_int()));
|
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;
|
auto r;
|
||||||
|
@ -6699,7 +6705,7 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
|
||||||
for (ty.arg arg in args) {
|
for (ty.arg arg in args) {
|
||||||
auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n);
|
auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n);
|
||||||
check (llarg as int != 0);
|
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) {
|
if (arg.mode == ast.val) {
|
||||||
drop_args += vec(tup(llarg, arg.ty));
|
drop_args += vec(tup(llarg, arg.ty));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue