@@ -4000,18 +4000,26 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
4000
4000
let llfn = f_res. val ; bcx = f_res. bcx ;
4001
4001
4002
4002
// Translate the callee.
4003
- let fn_ty = ty:: expr_ty ( bcx_tcx ( bcx) , f) ;
4003
+ let { params : _ , ty : fn_ty } = ty:: expr_ty_params_and_ty ( bcx_tcx ( bcx) , f) ;
4004
4004
let fn_arg_tys = ty:: ty_fn_args ( bcx_tcx ( bcx) , fn_ty) ;
4005
4005
4006
4006
// Translate arguments.
4007
4007
let ( to_zero, to_revoke) = ( [ ] , [ ] ) ;
4008
4008
let llargs = vec:: map2 ( { |ty_arg, arg|
4009
4009
let arg_ty = ty_arg. ty ;
4010
- check type_has_static_size ( ccx, arg_ty) ;
4011
- let llargty = type_of ( ccx, f. span , arg_ty) ;
4010
+
4011
+ let static, llargty;
4012
+ if check type_has_static_size ( ccx, arg_ty) {
4013
+ static = true ;
4014
+ llargty = type_of ( ccx, f. span , arg_ty) ;
4015
+ } else {
4016
+ static = false ;
4017
+ llargty = T_ptr ( T_i8 ( ) ) ;
4018
+ }
4019
+
4012
4020
let r = trans_arg_expr ( bcx, ty_arg, llargty, to_zero, to_revoke, arg) ;
4013
4021
let llargval = r. val ; bcx = r. bcx ;
4014
- { llval: llargval, llty: llargty }
4022
+ { llval: llargval, llty: llargty, static : static }
4015
4023
} , fn_arg_tys, args) ;
4016
4024
4017
4025
// Allocate the argument bundle.
@@ -4023,8 +4031,14 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
4023
4031
4024
4032
// Copy in arguments.
4025
4033
vec:: eachi ( { |llarg, i|
4026
- // FIXME: This load is unfortunate.
4027
- let llargval = Load ( bcx, llarg. llval ) ;
4034
+ let llargval;
4035
+ if llarg. static {
4036
+ // FIXME: This load is unfortunate. It won't be necessary once we
4037
+ // have reference types again.
4038
+ llargval = Load ( bcx, llarg. llval ) ;
4039
+ } else {
4040
+ llargval = llarg. llval ;
4041
+ }
4028
4042
store_inbounds ( bcx, llargval, llargbundle, [ C_int ( 0 ) , C_uint ( i) ] ) ;
4029
4043
} , llargs) ;
4030
4044
0 commit comments