@@ -5199,9 +5199,10 @@ fn trans_expr_out(cx: &@block_ctxt, e: &@ast::expr, output: out_method) ->
5199
5199
let fn_pair =
5200
5200
alt fn_res {
5201
5201
some( fn_pair) { fn_pair }
5202
- none. { create_fn_pair ( ccx, s, llfnty, llfn, false ) }
5202
+ none. { { fn_pair: create_fn_pair ( ccx, s, llfnty, llfn, false ) ,
5203
+ bcx: cx} }
5203
5204
} ;
5204
- ret rslt( cx , fn_pair) ;
5205
+ ret rslt( fn_pair . bcx , fn_pair . fn_pair ) ;
5205
5206
}
5206
5207
ast:: expr_block ( blk) {
5207
5208
let sub_cx = new_scope_block_ctxt ( cx, "block-expr body" ) ;
@@ -6446,8 +6447,8 @@ fn finish_fn(fcx: &@fn_ctxt, lltop: BasicBlockRef) {
6446
6447
fn trans_closure ( bcx_maybe : & option:: t[ @block_ctxt ] ,
6447
6448
llfnty : & option:: t [ TypeRef ] , cx : @local_ctxt , sp : & span ,
6448
6449
f : & ast:: _fn , llfndecl : ValueRef , ty_self : option:: t [ ty:: t ] ,
6449
- ty_params : & ast:: ty_param [ ] , id : ast:: node_id ) ->
6450
- option:: t [ ValueRef ] {
6450
+ ty_params : & ast:: ty_param [ ] , id : ast:: node_id )
6451
+ -> option:: t [ { fn_pair : ValueRef , bcx : @block_ctxt } ] {
6451
6452
set_uwtable ( llfndecl) ;
6452
6453
6453
6454
// Set up arguments to the function.
@@ -6464,28 +6465,27 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
6464
6465
copy_args_to_allocas ( fcx, f. decl . inputs , arg_tys) ;
6465
6466
6466
6467
// Figure out if we need to build a closure and act accordingly
6467
- let closure = none;
6468
- alt f. proto {
6468
+ let res = alt f. proto {
6469
6469
ast:: proto_block. | ast:: proto_closure. {
6470
6470
let bcx = option:: get ( bcx_maybe) ;
6471
6471
let upvars = get_freevars ( cx. ccx . tcx , id) ;
6472
6472
6473
- let llenvptr = if ( f. proto == ast:: proto_block) {
6473
+ let env = if ( f. proto == ast:: proto_block) {
6474
6474
let llenv = build_environment ( bcx, upvars) ;
6475
6475
load_environment ( bcx, fcx, llenv. ptrty , upvars) ;
6476
- llenv. ptr
6476
+ { ptr : llenv. ptr , bcx : bcx }
6477
6477
} else {
6478
6478
let llenv = build_copying_closure ( bcx, upvars) ;
6479
6479
load_environment_heap ( bcx, fcx, llenv. ptrty , upvars) ;
6480
- llenv. ptr
6480
+ { ptr : llenv. ptr , bcx : llenv . bcx }
6481
6481
} ;
6482
6482
6483
- closure =
6484
- some ( create_real_fn_pair ( bcx , option :: get ( llfnty ) , llfndecl,
6485
- llenvptr ) ) ;
6483
+ let closure = create_real_fn_pair ( env . bcx , option :: get ( llfnty ) ,
6484
+ llfndecl, env . ptr ) ;
6485
+ some ( { fn_pair : closure , bcx : env . bcx } )
6486
6486
}
6487
- _ { }
6488
- }
6487
+ _ { none }
6488
+ } ;
6489
6489
6490
6490
// Create the first basic block in the function and keep a handle on it to
6491
6491
// pass to finish_fn later.
@@ -6520,7 +6520,7 @@ fn trans_closure(bcx_maybe: &option::t[@block_ctxt],
6520
6520
// Insert the mandatory first few basic blocks before lltop.
6521
6521
finish_fn ( fcx, lltop) ;
6522
6522
6523
- ret closure ;
6523
+ ret res ;
6524
6524
}
6525
6525
6526
6526
fn trans_fn_inner ( cx : @local_ctxt , sp : & span , f : & ast:: _fn ,
0 commit comments