@@ -929,7 +929,7 @@ fn trans_stack_local_derived_tydesc(cx: @block_ctxt, llsz: ValueRef,
929
929
let llmyroottydesc = alloca ( cx, bcx_ccx ( cx) . tydesc_type ) ;
930
930
931
931
// By convention, desc 0 is the root descriptor.
932
- llroottydesc = Load ( cx, llroottydesc) ;
932
+ let llroottydesc = Load ( cx, llroottydesc) ;
933
933
Store ( cx, llroottydesc, llmyroottydesc) ;
934
934
935
935
// Store a pointer to the rest of the descriptors.
@@ -1352,7 +1352,7 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
1352
1352
// everything to a pointer to the type that the glue acts on).
1353
1353
let bcx = alt ty:: struct ( bcx_tcx ( bcx) , t) {
1354
1354
ty:: ty_box ( body_mt) {
1355
- v = PointerCast ( bcx, v, type_of_1 ( bcx, t) ) ;
1355
+ let v = PointerCast ( bcx, v, type_of_1 ( bcx, t) ) ;
1356
1356
let body = GEPi ( bcx, v, [ 0 , abi:: box_rc_field_body] ) ;
1357
1357
let bcx = drop_ty ( bcx, body, body_mt. ty ) ;
1358
1358
if !bcx_ccx ( bcx) . sess . get_opts ( ) . do_gc {
@@ -1361,7 +1361,7 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
1361
1361
}
1362
1362
ty:: ty_uniq ( content_mt) {
1363
1363
check trans_uniq:: type_is_unique_box ( bcx, t) ;
1364
- v = PointerCast ( bcx, v, type_of_1 ( bcx, t) ) ;
1364
+ let v = PointerCast ( bcx, v, type_of_1 ( bcx, t) ) ;
1365
1365
trans_uniq:: make_free_glue ( bcx, v, t)
1366
1366
}
1367
1367
ty:: ty_vec ( _) | ty:: ty_str. {
@@ -1388,7 +1388,7 @@ fn make_free_glue(bcx: @block_ctxt, v: ValueRef, t: ty::t) {
1388
1388
// Call through the closure's own fields-drop glue first.
1389
1389
// Then free the body.
1390
1390
let ccx = bcx_ccx ( bcx) ;
1391
- v = PointerCast ( bcx, v, T_opaque_closure_ptr ( ccx) ) ;
1391
+ let v = PointerCast ( bcx, v, T_opaque_closure_ptr ( ccx) ) ;
1392
1392
let body = GEPi ( bcx, v, [ 0 , abi:: box_rc_field_body] ) ;
1393
1393
let bindings =
1394
1394
GEPi ( bcx, body, [ 0 , abi:: closure_elt_bindings] ) ;
@@ -1448,7 +1448,7 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: ast::def_id,
1448
1448
// Silly check
1449
1449
check type_is_tup_like ( cx, tup_ty) ;
1450
1450
let drop_flag = GEP_tup_like ( cx, tup_ty, rs, [ 0 , 0 ] ) ;
1451
- cx = drop_flag. bcx ;
1451
+ let cx = drop_flag. bcx ;
1452
1452
let null_test = IsNull ( cx, Load ( cx, drop_flag. val ) ) ;
1453
1453
CondBr ( cx, null_test, next_cx. llbb , drop_cx. llbb ) ;
1454
1454
cx = drop_cx;
@@ -1487,7 +1487,7 @@ fn decr_refcnt_maybe_free(cx: @block_ctxt, box_ptr: ValueRef, t: ty::t)
1487
1487
let free_cx = new_sub_block_ctxt ( cx, "free" ) ;
1488
1488
let next_cx = new_sub_block_ctxt ( cx, "next" ) ;
1489
1489
let llbox_ty = T_opaque_obj_ptr ( ccx) ;
1490
- box_ptr = PointerCast ( cx, box_ptr, llbox_ty) ;
1490
+ let box_ptr = PointerCast ( cx, box_ptr, llbox_ty) ;
1491
1491
let null_test = IsNull ( cx, box_ptr) ;
1492
1492
CondBr ( cx, null_test, next_cx. llbb , rc_adj_cx. llbb ) ;
1493
1493
let rc_ptr =
@@ -1640,6 +1640,7 @@ fn iter_structural_ty(cx: @block_ctxt, av: ValueRef, t: ty::t,
1640
1640
if std:: vec:: len :: < ty:: t > ( variant. args ) == 0 u { ret cx; }
1641
1641
let fn_ty = variant. ctor_ty ;
1642
1642
let ccx = bcx_ccx ( cx) ;
1643
+ let cx = cx;
1643
1644
alt ty:: struct ( ccx. tcx , fn_ty) {
1644
1645
ty:: ty_fn ( _, args, _, _, _) {
1645
1646
let j = 0 u;
@@ -1661,6 +1662,7 @@ fn iter_structural_ty(cx: @block_ctxt, av: ValueRef, t: ty::t,
1661
1662
/*
1662
1663
Typestate constraint that shows the unimpl case doesn't happen?
1663
1664
*/
1665
+ let cx = cx;
1664
1666
alt ty:: struct ( bcx_tcx ( cx) , t) {
1665
1667
ty:: ty_rec ( fields) {
1666
1668
let i: int = 0 ;
@@ -2054,7 +2056,7 @@ fn copy_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
2054
2056
2055
2057
fn copy_val_no_check ( bcx : @block_ctxt , action : copy_action , dst : ValueRef ,
2056
2058
src : ValueRef , t : ty:: t ) -> @block_ctxt {
2057
- let ccx = bcx_ccx ( bcx) ;
2059
+ let ccx = bcx_ccx ( bcx) , bcx = bcx ;
2058
2060
if ty:: type_is_scalar ( ccx. tcx , t) || ty:: type_is_native ( ccx. tcx , t) {
2059
2061
Store ( bcx, src, dst) ;
2060
2062
ret bcx;
@@ -2084,7 +2086,7 @@ fn copy_val_no_check(bcx: @block_ctxt, action: copy_action, dst: ValueRef,
2084
2086
fn move_val ( cx : @block_ctxt , action : copy_action , dst : ValueRef ,
2085
2087
src : lval_result , t : ty:: t ) -> @block_ctxt {
2086
2088
let src_val = src. val ;
2087
- let tcx = bcx_tcx ( cx) ;
2089
+ let tcx = bcx_tcx ( cx) , cx = cx ;
2088
2090
if ty:: type_is_scalar ( tcx, t) || ty:: type_is_native ( tcx, t) {
2089
2091
if src. kind == owned { src_val = Load ( cx, src_val) ; }
2090
2092
Store ( cx, src_val, dst) ;
@@ -2230,17 +2232,16 @@ fn trans_unary(bcx: @block_ctxt, op: ast::unop, e: @ast::expr,
2230
2232
fn trans_expr_fn ( bcx : @block_ctxt , f : ast:: _fn , sp : span ,
2231
2233
id : ast:: node_id , dest : dest ) -> @block_ctxt {
2232
2234
if dest == ignore { ret bcx; }
2233
- let ccx = bcx_ccx ( bcx) ;
2235
+ let ccx = bcx_ccx ( bcx) , bcx = bcx ;
2234
2236
let fty = node_id_type ( ccx, id) ;
2235
2237
check returns_non_ty_var ( ccx, fty) ;
2236
2238
let llfnty = type_of_fn_from_ty ( ccx, sp, fty, 0 u) ;
2237
2239
let sub_cx = extend_path ( bcx. fcx . lcx , ccx. names . next ( "anon" ) ) ;
2238
2240
let s = mangle_internal_name_by_path ( ccx, sub_cx. path ) ;
2239
2241
let llfn = decl_internal_cdecl_fn ( ccx. llmod , s, llfnty) ;
2240
2242
2241
- let copying =
2242
- f. proto == ast:: proto_shared ( ast:: sugar_normal)
2243
- || f. proto == ast:: proto_shared ( ast:: sugar_sexy) ;
2243
+ let copying = f. proto == ast:: proto_shared ( ast:: sugar_normal)
2244
+ || f. proto == ast:: proto_shared ( ast:: sugar_sexy) ;
2244
2245
let env;
2245
2246
alt f. proto {
2246
2247
ast:: proto_block. | ast:: proto_shared ( _) {
@@ -2300,7 +2301,7 @@ fn trans_eager_binop(cx: @block_ctxt, op: ast::binop, lhs: ValueRef,
2300
2301
if op == ast:: add && ty:: type_is_sequence ( bcx_tcx ( cx) , intype) {
2301
2302
ret tvec:: trans_add ( cx, intype, lhs, rhs, dest) ;
2302
2303
}
2303
- let val = alt op {
2304
+ let cx = cx , val = alt op {
2304
2305
ast : : add. {
2305
2306
if is_float { FAdd ( cx, lhs, rhs) }
2306
2307
else { Add ( cx, lhs, rhs) }
@@ -2573,9 +2574,9 @@ fn trans_for(cx: @block_ctxt, local: @ast::local, seq: @ast::expr,
2573
2574
new_loop_scope_block_ctxt ( bcx, option:: some ( next_cx) ,
2574
2575
outer_next_cx, "for loop scope" ) ;
2575
2576
Br ( bcx, scope_cx. llbb ) ;
2576
- curr = PointerCast ( bcx, curr, T_ptr ( type_of_or_i8 ( bcx, t) ) ) ;
2577
- bcx = trans_alt:: bind_irrefutable_pat ( scope_cx, local. node . pat , curr ,
2578
- false ) ;
2577
+ let curr = PointerCast ( bcx, curr, T_ptr ( type_of_or_i8 ( bcx, t) ) ) ;
2578
+ let bcx = trans_alt:: bind_irrefutable_pat ( scope_cx, local. node . pat ,
2579
+ curr , false ) ;
2579
2580
bcx = trans_block_dps ( bcx, body, ignore) ;
2580
2581
Br ( bcx, next_cx. llbb ) ;
2581
2582
ret next_cx;
@@ -2649,7 +2650,7 @@ fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
2649
2650
// Finally, synthesize a type for that whole vector.
2650
2651
let closure_ty: ty:: t = ty:: mk_tup ( tcx, closure_tys) ;
2651
2652
2652
- let temp_cleanups = [ ] ;
2653
+ let temp_cleanups = [ ] , bcx = bcx ;
2653
2654
// Allocate a box that can hold something closure-sized.
2654
2655
let ( closure, box) = if copying {
2655
2656
let r = trans_malloc_boxed ( bcx, closure_ty) ;
@@ -2903,7 +2904,7 @@ fn lval_static_fn(bcx: @block_ctxt, tpt: ty::ty_param_kinds_and_ty,
2903
2904
trans_external_path ( bcx, fn_id, tpt)
2904
2905
} ;
2905
2906
let tys = ty:: node_id_to_type_params ( bcx_tcx ( bcx) , id) ;
2906
- let gen = none;
2907
+ let gen = none, bcx = bcx ;
2907
2908
if std:: vec:: len :: < ty:: t > ( tys) != 0 u {
2908
2909
let tydescs = [ ] , tis = [ ] ;
2909
2910
for t in tys {
@@ -3736,7 +3737,7 @@ fn trans_args(cx: @block_ctxt, outer_cx: @block_ctxt, llenv: ValueRef,
3736
3737
// This will be needed if this is a generic call, because the callee has
3737
3738
// to cast her view of the arguments to the caller's view.
3738
3739
let arg_tys = type_of_explicit_args ( ccx, cx. sp , args) ;
3739
- let i = 0 u;
3740
+ let i = 0 u, outer_cx = outer_cx ;
3740
3741
for e: @ast:: expr in es {
3741
3742
let is_referenced = alt ret_style {
3742
3743
ast : : return_ref ( _, arg_n) { i + 1 u == arg_n }
@@ -3838,7 +3839,7 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
3838
3839
args : [ @ast:: expr ] , dest : dest ) -> @block_ctxt {
3839
3840
let ccx = bcx_ccx ( bcx) ;
3840
3841
let f_res = trans_callee ( bcx, f) ;
3841
- let llfn = f_res. val ; bcx = f_res. bcx ;
3842
+ let llfn = f_res. val , bcx = f_res. bcx ;
3842
3843
3843
3844
// Translate the callee.
3844
3845
let { params: _ , ty: fn_ty } = ty:: expr_ty_params_and_ty ( bcx_tcx ( bcx) , f) ;
@@ -4033,6 +4034,7 @@ fn trans_landing_pad(bcx: @block_ctxt,
4033
4034
fn trans_tup ( bcx : @block_ctxt , elts : [ @ast:: expr ] , id : ast:: node_id ,
4034
4035
dest : dest ) -> @block_ctxt {
4035
4036
let t = node_id_type ( bcx. fcx . lcx . ccx , id) ;
4037
+ let bcx = bcx;
4036
4038
let addr = alt dest {
4037
4039
ignore. {
4038
4040
for ex in elts { bcx = trans_expr ( bcx, ex, ignore) ; }
@@ -4057,6 +4059,7 @@ fn trans_rec(bcx: @block_ctxt, fields: [ast::field],
4057
4059
base : option:: t < @ast:: expr > , id : ast:: node_id ,
4058
4060
dest : dest ) -> @block_ctxt {
4059
4061
let t = node_id_type ( bcx_ccx ( bcx) , id) ;
4062
+ let bcx = bcx;
4060
4063
let addr = alt dest {
4061
4064
ignore. {
4062
4065
for fld in fields {
@@ -4116,6 +4119,7 @@ fn trans_expr_save_in(bcx: @block_ctxt, e: @ast::expr, dest: ValueRef)
4116
4119
// trans_expr_save_in. For intermediates where you don't care about lval-ness,
4117
4120
// use trans_temp_expr.
4118
4121
fn trans_temp_lval ( bcx : @block_ctxt , e : @ast:: expr ) -> lval_result {
4122
+ let bcx = bcx;
4119
4123
if expr_is_lval ( bcx_tcx ( bcx) , e) {
4120
4124
ret trans_lval ( bcx, e) ;
4121
4125
} else {
@@ -4429,6 +4433,7 @@ fn trans_check_expr(cx: @block_ctxt, e: @ast::expr, s: str) -> @block_ctxt {
4429
4433
4430
4434
fn trans_fail_expr ( bcx : @block_ctxt , sp_opt : option:: t < span > ,
4431
4435
fail_expr : option:: t < @ast:: expr > ) -> @block_ctxt {
4436
+ let bcx = bcx;
4432
4437
alt fail_expr {
4433
4438
some( expr) {
4434
4439
let tcx = bcx_tcx ( bcx) ;
@@ -4483,7 +4488,7 @@ fn trans_fail_value(bcx: @block_ctxt, sp_opt: option::t<span>,
4483
4488
fn trans_break_cont ( sp : span , bcx : @block_ctxt , to_end : bool )
4484
4489
-> @block_ctxt {
4485
4490
// Locate closest loop block, outputting cleanup as we go.
4486
- let cleanup_cx = bcx;
4491
+ let cleanup_cx = bcx, bcx = bcx ;
4487
4492
while true {
4488
4493
bcx = trans_block_cleanups ( bcx, cleanup_cx) ;
4489
4494
alt copy cleanup_cx. kind {
@@ -4524,7 +4529,7 @@ fn trans_cont(sp: span, cx: @block_ctxt) -> @block_ctxt {
4524
4529
}
4525
4530
4526
4531
fn trans_ret ( bcx : @block_ctxt , e : option:: t < @ast:: expr > ) -> @block_ctxt {
4527
- let cleanup_cx = bcx;
4532
+ let cleanup_cx = bcx, bcx = bcx ;
4528
4533
alt e {
4529
4534
some( x) {
4530
4535
if ast_util:: ret_by_ref ( bcx. fcx . ret_style ) {
@@ -4582,6 +4587,7 @@ fn init_local(bcx: @block_ctxt, local: @ast::local) -> @block_ctxt {
4582
4587
}
4583
4588
} ;
4584
4589
4590
+ let bcx = bcx;
4585
4591
alt local. node . init {
4586
4592
some ( init) {
4587
4593
if init. op == ast:: init_assign ||
@@ -4730,7 +4736,7 @@ fn trans_block_cleanups(bcx: @block_ctxt, cleanup_cx: @block_ctxt) ->
4730
4736
if cleanup_cx. kind == NON_SCOPE_BLOCK {
4731
4737
assert ( std:: vec:: len :: < cleanup > ( cleanup_cx. cleanups ) == 0 u) ;
4732
4738
}
4733
- let i = std:: vec:: len :: < cleanup > ( cleanup_cx. cleanups ) ;
4739
+ let i = std:: vec:: len :: < cleanup > ( cleanup_cx. cleanups ) , bcx = bcx ;
4734
4740
while i > 0 u {
4735
4741
i -= 1 u;
4736
4742
let c = cleanup_cx. cleanups [ i] ;
@@ -4863,6 +4869,7 @@ fn trans_block(bcx: @block_ctxt, b: ast::blk) -> @block_ctxt {
4863
4869
4864
4870
fn trans_block_dps ( bcx : @block_ctxt , b : ast:: blk , dest : dest )
4865
4871
-> @block_ctxt {
4872
+ let bcx = bcx;
4866
4873
block_locals ( b) { |local| bcx = alloc_local ( bcx, local) ; } ;
4867
4874
for s: @ast:: stmt in b. node . stmts {
4868
4875
bcx = trans_stmt ( bcx, * s) ;
@@ -4998,41 +5005,25 @@ fn create_llargs_for_fn_args(cx: @fn_ctxt, ty_self: option::t<ty::t>,
4998
5005
}
4999
5006
5000
5007
fn copy_args_to_allocas ( fcx : @fn_ctxt , bcx : @block_ctxt , args : [ ast:: arg ] ,
5001
- arg_tys : [ ty:: arg ] , ignore_mut : bool )
5002
- -> @block_ctxt {
5003
- let arg_n: uint = 0 u;
5008
+ arg_tys : [ ty:: arg ] ) -> @block_ctxt {
5009
+ let arg_n: uint = 0 u, bcx = bcx;
5004
5010
for arg in arg_tys {
5005
5011
let id = args[ arg_n] . id ;
5006
- let mutated = !ignore_mut && fcx. lcx . ccx . mut_map . contains_key ( id) ;
5007
5012
let argval = alt fcx. llargs . get ( id) { local_mem ( v) { v } } ;
5008
5013
alt arg. mode {
5009
5014
ast:: by_mut_ref. { }
5010
5015
ast:: by_move. { add_clean ( bcx, argval, arg. ty ) ; }
5011
5016
ast:: by_val. {
5012
- if mutated || !ty:: type_is_immediate ( bcx_tcx ( bcx) , arg. ty ) {
5017
+ if !ty:: type_is_immediate ( bcx_tcx ( bcx) , arg. ty ) {
5013
5018
let { bcx: cx , val : alloc } = alloc_ty ( bcx, arg. ty ) ;
5014
5019
bcx = cx;
5015
5020
Store ( bcx, argval, alloc) ;
5016
- if mutated {
5017
- bcx = take_ty ( bcx, alloc, arg. ty ) ;
5018
- add_clean ( bcx, alloc, arg. ty ) ;
5019
- }
5020
5021
fcx. llargs . insert ( id, local_mem ( alloc) ) ;
5021
5022
} else {
5022
5023
fcx. llargs . insert ( id, local_imm ( argval) ) ;
5023
5024
}
5024
5025
}
5025
- ast:: by_ref. {
5026
- // Overwrite the llargs entry for locally mutated params
5027
- // with a local alloca.
5028
- if mutated {
5029
- let { bcx: cx , val : alloc } = alloc_ty ( bcx, arg. ty ) ;
5030
- bcx = copy_val ( cx, INIT , alloc,
5031
- load_if_immediate ( cx, argval, arg. ty ) , arg. ty ) ;
5032
- fcx. llargs . insert ( id, local_mem ( alloc) ) ;
5033
- add_clean ( bcx, alloc, arg. ty ) ;
5034
- }
5035
- }
5026
+ ast:: by_ref. { }
5036
5027
}
5037
5028
arg_n += 1 u;
5038
5029
}
@@ -5129,7 +5120,7 @@ fn trans_closure(cx: @local_ctxt, sp: span, f: ast::_fn, llfndecl: ValueRef,
5129
5120
let block_ty = node_id_type ( cx. ccx , f. body . node . id ) ;
5130
5121
5131
5122
let arg_tys = arg_tys_of_fn ( fcx. lcx . ccx , id) ;
5132
- bcx = copy_args_to_allocas ( fcx, bcx, f. decl . inputs , arg_tys, false ) ;
5123
+ bcx = copy_args_to_allocas ( fcx, bcx, f. decl . inputs , arg_tys) ;
5133
5124
5134
5125
maybe_load_env ( fcx) ;
5135
5126
@@ -5254,7 +5245,7 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id,
5254
5245
let arg_tys = arg_tys_of_fn ( ccx, variant. node . id ) ;
5255
5246
let bcx = new_top_block_ctxt ( fcx) ;
5256
5247
let lltop = bcx. llbb ;
5257
- bcx = copy_args_to_allocas ( fcx, bcx, fn_args, arg_tys, true ) ;
5248
+ bcx = copy_args_to_allocas ( fcx, bcx, fn_args, arg_tys) ;
5258
5249
5259
5250
// Cast the tag to a type we can GEP into.
5260
5251
let llblobptr =
@@ -5991,7 +5982,7 @@ fn decl_crate_map(sess: session::session, mapname: str,
5991
5982
let n_subcrates = 1 ;
5992
5983
let cstore = sess. get_cstore ( ) ;
5993
5984
while cstore:: have_crate_data ( cstore, n_subcrates) { n_subcrates += 1 ; }
5994
- if ! sess. get_opts ( ) . library { mapname = "toplevel" ; }
5985
+ let mapname = sess. get_opts ( ) . library ? mapname : "toplevel" ;
5995
5986
let sym_name = "_rust_crate_map_" + mapname;
5996
5987
let arrtype = T_array ( int_type, n_subcrates as uint ) ;
5997
5988
let maptype = T_struct ( [ int_type, arrtype] ) ;
0 commit comments