@@ -3793,7 +3793,7 @@ fn find_variable(&@fn_ctxt fcx, ast::node_id nid) -> ValueRef {
3793
3793
// contains pointers to all of the upvars and all of the tydescs in
3794
3794
// scope. Return the ValueRef and TypeRef corresponding to the closure.
3795
3795
fn build_environment( & @block_ctxt cx, & ast:: node_id[ ] upvars) ->
3796
- tup ( ValueRef , TypeRef ) {
3796
+ rec ( ValueRef ptr , TypeRef ptrty ) {
3797
3797
auto upvar_count = std:: ivec:: len( upvars) ;
3798
3798
auto has_iterbody = !option:: is_none( cx. fcx. lliterbody) ;
3799
3799
if ( has_iterbody) { upvar_count += 1 u; }
@@ -3852,7 +3852,7 @@ fn build_environment(&@block_ctxt cx, &ast::node_id[] upvars) ->
3852
3852
i += 1 u;
3853
3853
}
3854
3854
3855
- ret tup ( llenvptr, llenvptrty) ;
3855
+ ret rec ( ptr= llenvptr, ptrty= llenvptrty) ;
3856
3856
}
3857
3857
3858
3858
// Given an enclosing block context, a new function context, a closure type,
@@ -3943,9 +3943,7 @@ fn trans_for_each(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
3943
3943
auto decl_id = local. node. id;
3944
3944
auto upvars = get_freevars( lcx. ccx. tcx, body. node. id) ;
3945
3945
3946
- auto environment_data = build_environment( cx, * upvars) ;
3947
- auto llenvptr = environment_data. _0;
3948
- auto llenvptrty = environment_data. _1;
3946
+ auto llenv = build_environment( cx, * upvars) ;
3949
3947
3950
3948
// Step 2: Declare foreach body function.
3951
3949
let str s =
@@ -3966,7 +3964,7 @@ fn trans_for_each(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
3966
3964
3967
3965
// Generate code to load the environment out of the
3968
3966
// environment pointer.
3969
- load_environment( cx, fcx, llenvptrty , * upvars) ;
3967
+ load_environment( cx, fcx, llenv . ptrty , * upvars) ;
3970
3968
3971
3969
// Add an upvar for the loop variable alias.
3972
3970
fcx. llupvars. insert( decl_id, llvm:: LLVMGetParam ( fcx. llfn, 3 u) ) ;
@@ -3984,7 +3982,7 @@ fn trans_for_each(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
3984
3982
alt ( seq. node) {
3985
3983
case ( ast:: expr_call( ?f, ?args) ) {
3986
3984
auto pair = create_real_fn_pair( cx, iter_body_llty,
3987
- lliterbody, llenvptr ) ;
3985
+ lliterbody, llenv . ptr ) ;
3988
3986
r = trans_call( cx, f, some[ ValueRef ] ( cx. build. Load ( pair) ) ,
3989
3987
args, seq. id) ;
3990
3988
ret rslt( r. bcx, C_nil ( ) ) ;
0 commit comments