@@ -3687,8 +3687,7 @@ fn build_environment_heap(bcx: @block_ctxt, lltydescs: ValueRef[],
3687
3687
let closure = r. body ;
3688
3688
3689
3689
// Store bindings tydesc.
3690
- let bound_tydesc =
3691
- bcx. build . GEP ( closure, ~[ C_int ( 0 ) , C_int ( abi:: closure_elt_tydesc) ] ) ;
3690
+ let bound_tydesc = GEPi ( bcx, closure, ~[ 0 , abi:: closure_elt_tydesc] ) ;
3692
3691
let ti = none;
3693
3692
let bindings_tydesc = get_tydesc ( bcx, bindings_ty, true , ti) ;
3694
3693
lazily_emit_tydesc_glue ( bcx, abi:: tydesc_field_drop_glue, ti) ;
@@ -3718,8 +3717,7 @@ fn build_environment_heap(bcx: @block_ctxt, lltydescs: ValueRef[],
3718
3717
bcx = ty_params_slot. bcx ;
3719
3718
i = 0 u;
3720
3719
for td: ValueRef in lltydescs {
3721
- let ty_param_slot =
3722
- bcx. build . GEP ( ty_params_slot. val , ~[ C_int ( 0 ) , C_int ( i as int ) ] ) ;
3720
+ let ty_param_slot = GEPi ( bcx, ty_params_slot. val , ~[ 0 , i as int ] ) ;
3723
3721
bcx. build . Store ( td, ty_param_slot) ;
3724
3722
i += 1 u;
3725
3723
}
@@ -3767,8 +3765,7 @@ fn build_environment(cx: &@block_ctxt, upvars: &@ast::node_id[]) ->
3767
3765
let upvar_count = std:: ivec:: len ( llbindings) ;
3768
3766
let i = 0 u;
3769
3767
while i < upvar_count {
3770
- let llbindingptr =
3771
- cx. build . GEP ( llbindingsptr, ~[ C_int ( 0 ) , C_int ( i as int ) ] ) ;
3768
+ let llbindingptr = GEPi ( cx, llbindingsptr, ~[ 0 , i as int ] ) ;
3772
3769
cx. build . Store ( llbindings. ( i) , llbindingptr) ;
3773
3770
i += 1 u;
3774
3771
}
@@ -3783,21 +3780,18 @@ fn build_environment(cx: &@block_ctxt, upvars: &@ast::node_id[]) ->
3783
3780
T_closure_ptr ( * bcx_ccx ( cx) , val_ty ( llbindingsptr) , tydesc_count) ;
3784
3781
let llenvptr = alloca ( cx, llvm:: LLVMGetElementType ( llenvptrty) ) ;
3785
3782
let llbindingsptrptr =
3786
- cx. build . GEP ( llenvptr,
3787
- ~[ C_int ( 0 ) , C_int ( abi:: box_rc_field_body) ,
3788
- C_int ( abi:: closure_elt_bindings) ] ) ;
3783
+ GEPi ( cx, llenvptr,
3784
+ ~[ 0 , abi:: box_rc_field_body, abi:: closure_elt_bindings] ) ;
3789
3785
cx. build . Store ( llbindingsptr, llbindingsptrptr) ;
3790
3786
3791
3787
// Copy in our type descriptors, in case the iterator body needs to refer
3792
3788
// to them.
3793
3789
let lltydescsptr =
3794
- cx. build . GEP ( llenvptr,
3795
- ~[ C_int ( 0 ) , C_int ( abi:: box_rc_field_body) ,
3796
- C_int ( abi:: closure_elt_ty_params) ] ) ;
3790
+ GEPi ( cx, llenvptr,
3791
+ ~[ 0 , abi:: box_rc_field_body, abi:: closure_elt_ty_params] ) ;
3797
3792
let i = 0 u;
3798
3793
while i < tydesc_count {
3799
- let lltydescptr =
3800
- cx. build . GEP ( lltydescsptr, ~[ C_int ( 0 ) , C_int ( i as int ) ] ) ;
3794
+ let lltydescptr = GEPi ( cx, lltydescsptr, ~[ 0 , i as int ] ) ;
3801
3795
cx. build . Store ( cx. fcx . lltydescs . ( i) , lltydescptr) ;
3802
3796
i += 1 u;
3803
3797
}
@@ -3878,42 +3872,34 @@ fn load_environment(enclosing_cx: &@block_ctxt, fcx: &@fn_ctxt,
3878
3872
3879
3873
// Populate the upvars from the environment.
3880
3874
let llenvptr = bcx. build . PointerCast ( fcx. llenv , llenvptrty) ;
3881
- llenvptr =
3882
- bcx. build . GEP ( llenvptr, ~[ C_int ( 0 ) , C_int ( abi:: box_rc_field_body) ] ) ;
3875
+ llenvptr = GEPi ( bcx, llenvptr, ~[ 0 , abi:: box_rc_field_body] ) ;
3883
3876
let llbindingsptrptr =
3884
- bcx. build . GEP ( llenvptr,
3885
- ~[ C_int ( 0 ) , C_int ( abi:: closure_elt_bindings) ] ) ;
3877
+ GEPi ( bcx, llenvptr, ~[ 0 , abi:: closure_elt_bindings] ) ;
3886
3878
let llbindingsptr = bcx. build . Load ( llbindingsptrptr) ;
3887
3879
3888
3880
let i = 0 u;
3889
3881
if !option:: is_none ( enclosing_cx. fcx . lliterbody ) {
3890
3882
i += 1 u;
3891
- let lliterbodyptr =
3892
- bcx. build . GEP ( llbindingsptr, ~[ C_int ( 0 ) , C_int ( 0 ) ] ) ;
3883
+ let lliterbodyptr = GEPi ( bcx, llbindingsptr, ~[ 0 , 0 ] ) ;
3893
3884
fcx. lliterbody = some ( bcx. build . Load ( lliterbodyptr) ) ;
3894
3885
}
3895
3886
for upvar_id: ast:: node_id in * upvars {
3896
- let llupvarptrptr =
3897
- bcx. build . GEP ( llbindingsptr, ~[ C_int ( 0 ) , C_int ( i as int ) ] ) ;
3887
+ let llupvarptrptr = GEPi ( bcx, llbindingsptr, ~[ 0 , i as int ] ) ;
3898
3888
let llupvarptr = bcx. build . Load ( llupvarptrptr) ;
3899
3889
let def_id = ast:: def_id_of_def ( bcx_tcx ( bcx) . def_map . get ( upvar_id) ) ;
3900
3890
fcx. llupvars . insert ( def_id. node , llupvarptr) ;
3901
3891
i += 1 u;
3902
3892
}
3903
3893
3904
3894
// Populate the type parameters from the environment.
3905
- let lltydescsptr =
3906
- bcx. build . GEP ( llenvptr,
3907
- ~[ C_int ( 0 ) , C_int ( abi:: closure_elt_ty_params) ] ) ;
3895
+ let lltydescsptr = GEPi ( bcx, llenvptr, ~[ 0 , abi:: closure_elt_ty_params] ) ;
3908
3896
let tydesc_count = std:: ivec:: len ( enclosing_cx. fcx . lltydescs ) ;
3909
3897
i = 0 u;
3910
3898
while i < tydesc_count {
3911
- let lltydescptr =
3912
- bcx. build . GEP ( lltydescsptr, ~[ C_int ( 0 ) , C_int ( i as int ) ] ) ;
3899
+ let lltydescptr = GEPi ( bcx, lltydescsptr, ~[ 0 , i as int ] ) ;
3913
3900
fcx. lltydescs += ~[ bcx. build . Load ( lltydescptr) ] ;
3914
3901
i += 1 u;
3915
3902
}
3916
-
3917
3903
}
3918
3904
3919
3905
fn trans_for_each ( cx : & @block_ctxt , local : & @ast:: local , seq : & @ast:: expr ,
0 commit comments