@@ -1336,11 +1336,15 @@ fn make_take_glue(cx: @block_ctxt, v: ValueRef, t: ty::t) {
1336
1336
bcx
1337
1337
}
1338
1338
ty:: ty_fn ( ast:: proto_send. , _, _, _, _) {
1339
- take_fn_env ( bcx, v, { |bcx, _box_ptr_v|
1340
- bcx // NDM
1339
+ take_fn_env ( bcx, v, { |bcx, box_ptr_v|
1340
+ // Here, box_ptr_v is a unique pointer which
1341
+ // must be cloned.
1342
+ call_bound_data_glue_for_closure (
1343
+ bcx, box_ptr_v, abi:: tydesc_field_take_glue) ;
1344
+ bcx
1341
1345
} )
1342
1346
}
1343
- ty:: ty_fn ( ast:: proto_shared ( _) , _, _, _, _) {
1347
+ ty:: ty_native_fn ( _ , _ ) | ty :: ty_fn ( ast:: proto_shared ( _) , _, _, _, _) {
1344
1348
take_fn_env ( bcx, v, { |bcx, box_ptr_v|
1345
1349
incr_refcnt_of_boxed ( bcx, box_ptr_v)
1346
1350
} )
@@ -2633,6 +2637,7 @@ fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
2633
2637
} ;
2634
2638
}
2635
2639
2640
+ let ccx = bcx_ccx ( bcx) ;
2636
2641
let tcx = bcx_tcx ( bcx) ;
2637
2642
2638
2643
// First, synthesize a tuple type containing the types of all the
@@ -2661,12 +2666,11 @@ fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
2661
2666
// ourselves) into a vector. The whole things ends up looking
2662
2667
// like:
2663
2668
2664
- // closure_tys = [ tydesc_ty, [ bound_ty1, bound_ty2, ...], [ tydesc_ty,
2665
- // tydesc_ty, ...]]
2669
+ // closure_ty = ( tydesc_ty, ( bound_ty1, bound_ty2, ...), int, ( tydesc_ty,
2670
+ // tydesc_ty, ...))
2666
2671
let closure_tys: [ ty:: t ] =
2667
- [ tydesc_ty, bindings_ty, ty:: mk_tup ( tcx, captured_tys) ] ;
2668
-
2669
- // Finally, synthesize a type for that whole vector.
2672
+ [ tydesc_ty, bindings_ty,
2673
+ ty:: mk_uint ( tcx) , ty:: mk_tup ( tcx, captured_tys) ] ;
2670
2674
let closure_ty: ty:: t = ty:: mk_tup ( tcx, closure_tys) ;
2671
2675
2672
2676
let temp_cleanups = [ ] ;
@@ -2758,13 +2762,17 @@ fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
2758
2762
// appropriate slot in the closure.
2759
2763
// Silly check as well
2760
2764
check type_is_tup_like ( bcx, closure_ty) ;
2761
- let ty_params_slot =
2765
+ let { bcx: bcx , val : n_ty_params_slot } =
2766
+ GEP_tup_like ( bcx, closure_ty, closure,
2767
+ [ 0 , abi:: closure_elt_n_ty_params] ) ;
2768
+ Store ( bcx, C_uint ( ccx, vec:: len ( lltydescs) ) , n_ty_params_slot) ;
2769
+ check type_is_tup_like ( bcx, closure_ty) ;
2770
+ let { bcx: bcx , val : ty_params_slot } =
2762
2771
GEP_tup_like ( bcx, closure_ty, closure,
2763
2772
[ 0 , abi:: closure_elt_ty_params] ) ;
2764
- bcx = ty_params_slot. bcx ;
2765
2773
i = 0 u;
2766
2774
for td: ValueRef in lltydescs {
2767
- let ty_param_slot = GEPi ( bcx, ty_params_slot. val , [ 0 , i as int ] ) ;
2775
+ let ty_param_slot = GEPi ( bcx, ty_params_slot, [ 0 , i as int ] ) ;
2768
2776
let cloned_td = clone_tydesc ( bcx, mode, td) ;
2769
2777
Store ( bcx, cloned_td, ty_param_slot) ;
2770
2778
i += 1 u;
@@ -3817,10 +3825,6 @@ fn trans_call(in_cx: @block_ctxt, f: @ast::expr,
3817
3825
let tcx = bcx_tcx ( in_cx) ;
3818
3826
let fn_expr_ty = ty:: expr_ty ( tcx, f) ;
3819
3827
3820
- //NDM if check type_is_native_fn_on_c_stack(tcx, fn_expr_ty) {
3821
- //NDM ret trans_c_stack_native_call(in_cx, f, args, dest);
3822
- //NDM }
3823
-
3824
3828
let cx = new_scope_block_ctxt ( in_cx, "call" ) ;
3825
3829
Br ( in_cx, cx. llbb ) ;
3826
3830
let f_res = trans_callee ( cx, f) ;
0 commit comments