Skip to content

Commit 020726c

Browse files
nikomatsakisbrson
authored andcommitted
update trans_c_stack_native_call() to use type_of_explicit_args()
currently trans_c_stack_native_call() had some ad-hoc code for determining the type of the arguments. this code was not in agreement with the rest of trans. now it uses the same code path.
1 parent 67d3d93 commit 020726c

File tree

1 file changed

+18
-28
lines changed

1 file changed

+18
-28
lines changed

src/comp/middle/trans.rs

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,25 +3831,23 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
38313831
// Translate the callee.
38323832
let { params: _, ty: fn_ty } = ty::expr_ty_params_and_ty(bcx_tcx(bcx), f);
38333833
let fn_arg_tys = ty::ty_fn_args(bcx_tcx(bcx), fn_ty);
3834+
let llargtys = type_of_explicit_args(ccx, f.span, fn_arg_tys);
38343835

38353836
// Translate arguments.
38363837
let (to_zero, to_revoke) = ([], []);
3837-
let llargs = vec::map2({ |ty_arg, arg|
3838-
let arg_ty = ty_arg.ty;
3839-
3840-
let static, llargty;
3841-
if check type_has_static_size(ccx, arg_ty) {
3842-
static = true;
3843-
llargty = type_of(ccx, f.span, arg_ty);
3844-
} else {
3845-
static = false;
3846-
llargty = T_ptr(T_i8());
3847-
}
3848-
3838+
let i = 0u, n = vec::len(args);
3839+
let llargs = [];
3840+
while i < n {
3841+
let ty_arg = fn_arg_tys[i];
3842+
let arg = args[i];
3843+
let llargty = llargtys[i];
38493844
let r = trans_arg_expr(bcx, ty_arg, llargty, to_zero, to_revoke, arg);
38503845
let llargval = r.val; bcx = r.bcx;
3851-
{ llval: llargval, llty: llargty, static: static, mode: ty_arg.mode }
3852-
}, fn_arg_tys, args);
3846+
llargs += [
3847+
{ llval: llargval, llty: llargty }
3848+
];
3849+
i += 1u;
3850+
}
38533851

38543852
// Allocate the argument bundle.
38553853
let llargbundlety = T_struct(vec::map({ |r| r.llty }, llargs));
@@ -3859,20 +3857,12 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
38593857
let llargbundle = PointerCast(bcx, llrawargbundle, T_ptr(llargbundlety));
38603858

38613859
// Copy in arguments.
3862-
vec::eachi({ |llarg, i|
3863-
let llargval;
3864-
if llarg.static {
3865-
// FIXME: This load is unfortunate. It won't be necessary once we
3866-
// have reference types again.
3867-
llargval = alt llarg.mode {
3868-
ast::by_val. | ast::by_mut_ref. { llarg.llval }
3869-
ast::by_ref. | ast::mode_infer. { Load(bcx, llarg.llval) }
3870-
};
3871-
} else {
3872-
llargval = llarg.llval;
3873-
}
3874-
store_inbounds(bcx, llargval, llargbundle, [C_int(0), C_uint(i)]);
3875-
}, llargs);
3860+
let i = 0u, n = vec::len(llargs);
3861+
while i < n {
3862+
let llarg = llargs[i].llval;
3863+
store_inbounds(bcx, llarg, llargbundle, [C_int(0), C_uint(i)]);
3864+
i += 1u;
3865+
}
38763866

38773867
// Call.
38783868
// TODO: Invoke instead.

0 commit comments

Comments
 (0)