@@ -610,6 +610,8 @@ fn dynamic_size_of(cx: @block_ctxt, t: ty::t) -> result {
610
610
}
611
611
612
612
fn dynamic_align_of ( cx : @block_ctxt , t : ty:: t ) -> result {
613
+ // FIXME: Typestate constraint that shows this alt is
614
+ // exhaustive
613
615
alt ty:: struct ( bcx_tcx ( cx) , t) {
614
616
ty:: ty_param ( p, _) {
615
617
let aptr = field_of_tydesc ( cx, t, false , abi:: tydesc_field_align) ;
@@ -668,9 +670,8 @@ fn bump_ptr(bcx: @block_ctxt, t: ty::t, base: ValueRef, sz: ValueRef) ->
668
670
// ty::struct and knows what to do when it runs into a ty_param stuck in the
669
671
// middle of the thing it's GEP'ing into. Much like size_of and align_of,
670
672
// above.
671
- fn GEP_tup_like ( cx : @block_ctxt , t : ty:: t , base : ValueRef , ixs : [ int ] ) ->
672
- result {
673
- assert ( ty:: type_is_tup_like ( bcx_tcx ( cx) , t) ) ;
673
+ fn GEP_tup_like ( cx : @block_ctxt , t : ty:: t , base : ValueRef , ixs : [ int ] )
674
+ : type_is_tup_like ( cx , t ) -> result {
674
675
// It might be a static-known type. Handle this.
675
676
if !ty:: type_has_dynamic_size ( bcx_tcx ( cx) , t) {
676
677
ret rslt ( cx, GEPi ( cx, base, ixs) ) ;
@@ -785,6 +786,8 @@ fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: ast::def_id,
785
786
} else { llunionptr = llblobptr; }
786
787
787
788
// Do the GEP_tup_like().
789
+ // Silly check -- postcondition on mk_tup?
790
+ check type_is_tup_like ( cx, tup_ty) ;
788
791
let rs = GEP_tup_like ( cx, tup_ty, llunionptr, [ 0 , ix as int ] ) ;
789
792
// Cast the result to the appropriate type, if necessary.
790
793
@@ -1403,12 +1406,15 @@ fn trans_res_drop(cx: @block_ctxt, rs: ValueRef, did: ast::def_id,
1403
1406
let drop_cx = new_sub_block_ctxt ( cx, "drop res" ) ;
1404
1407
let next_cx = new_sub_block_ctxt ( cx, "next" ) ;
1405
1408
1409
+ // Silly check
1410
+ check type_is_tup_like ( cx, tup_ty) ;
1406
1411
let drop_flag = GEP_tup_like ( cx, tup_ty, rs, [ 0 , 0 ] ) ;
1407
1412
cx = drop_flag. bcx ;
1408
1413
let null_test = IsNull ( cx, Load ( cx, drop_flag. val ) ) ;
1409
1414
CondBr ( cx, null_test, next_cx. llbb , drop_cx. llbb ) ;
1410
1415
cx = drop_cx;
1411
1416
1417
+ check type_is_tup_like ( cx, tup_ty) ;
1412
1418
let val = GEP_tup_like ( cx, tup_ty, rs, [ 0 , 1 ] ) ;
1413
1419
cx = val. bcx ;
1414
1420
// Find and call the actual destructor.
@@ -1641,10 +1647,15 @@ fn iter_structural_ty(cx: @block_ctxt, av: ValueRef, t: ty::t,
1641
1647
ret cx;
1642
1648
}
1643
1649
1650
+ /*
1651
+ Typestate constraint that shows the unimpl case doesn't happen?
1652
+ */
1644
1653
alt ty:: struct ( bcx_tcx ( cx) , t) {
1645
1654
ty:: ty_rec ( fields) {
1646
1655
let i: int = 0 ;
1647
1656
for fld: ty:: field in fields {
1657
+ // Silly check
1658
+ check type_is_tup_like ( cx, t) ;
1648
1659
let { bcx: bcx , val : llfld_a } = GEP_tup_like ( cx, t, av, [ 0 , i] ) ;
1649
1660
cx = f ( bcx, llfld_a, fld. mt . ty ) ;
1650
1661
i += 1 ;
@@ -1653,6 +1664,8 @@ fn iter_structural_ty(cx: @block_ctxt, av: ValueRef, t: ty::t,
1653
1664
ty:: ty_tup ( args) {
1654
1665
let i = 0 ;
1655
1666
for arg in args {
1667
+ // Silly check
1668
+ check type_is_tup_like ( cx, t) ;
1656
1669
let { bcx: bcx , val : llfld_a } = GEP_tup_like ( cx, t, av, [ 0 , i] ) ;
1657
1670
cx = f ( bcx, llfld_a, arg) ;
1658
1671
i += 1 ;
@@ -1663,6 +1676,8 @@ fn iter_structural_ty(cx: @block_ctxt, av: ValueRef, t: ty::t,
1663
1676
let inner1 = ty:: substitute_type_params ( tcx, tps, inner) ;
1664
1677
let inner_t_s = ty:: substitute_type_params ( tcx, tps, inner) ;
1665
1678
let tup_t = ty:: mk_tup ( tcx, [ ty:: mk_int ( tcx) , inner_t_s] ) ;
1679
+ // Silly check
1680
+ check type_is_tup_like ( cx, tup_t) ;
1666
1681
let { bcx: bcx , val : llfld_a } = GEP_tup_like ( cx, tup_t, av, [ 0 , 1 ] ) ;
1667
1682
ret f( bcx, llfld_a, inner1) ;
1668
1683
}
@@ -2543,11 +2558,15 @@ fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
2543
2558
2544
2559
// Copy expr values into boxed bindings.
2545
2560
let i = 0 u;
2561
+ // Silly check
2562
+ check type_is_tup_like ( bcx, closure_ty) ;
2546
2563
let bindings =
2547
2564
GEP_tup_like ( bcx, closure_ty, closure,
2548
2565
[ 0 , abi:: closure_elt_bindings] ) ;
2549
2566
bcx = bindings. bcx ;
2550
2567
for lv: lval_result in bound_vals {
2568
+ // Also a silly check
2569
+ check type_is_tup_like ( bcx, bindings_ty) ;
2551
2570
let bound =
2552
2571
GEP_tup_like ( bcx, bindings_ty, bindings. val , [ 0 , i as int ] ) ;
2553
2572
bcx = bound. bcx ;
@@ -2559,6 +2578,8 @@ fn build_environment(bcx: @block_ctxt, lltydescs: [ValueRef],
2559
2578
2560
2579
// If necessary, copy tydescs describing type parameters into the
2561
2580
// appropriate slot in the closure.
2581
+ // Silly check as well
2582
+ check type_is_tup_like ( bcx, closure_ty) ;
2562
2583
let ty_params_slot =
2563
2584
GEP_tup_like ( bcx, closure_ty, closure,
2564
2585
[ 0 , abi:: closure_elt_ty_params] ) ;
@@ -2663,6 +2684,8 @@ fn load_environment(enclosing_cx: @block_ctxt, fcx: @fn_ctxt, envty: ty::t,
2663
2684
// If this is an aliasing closure/for-each body, we need to load
2664
2685
// the iterbody.
2665
2686
if !copying && !option:: is_none ( enclosing_cx. fcx . lliterbody ) {
2687
+ // Silly check
2688
+ check type_is_tup_like ( bcx, ty) ;
2666
2689
let iterbodyptr = GEP_tup_like ( bcx, ty, llclosure, path + [ 0 ] ) ;
2667
2690
fcx. lliterbody = some ( Load ( bcx, iterbodyptr. val ) ) ;
2668
2691
bcx = iterbodyptr. bcx ;
@@ -2671,6 +2694,8 @@ fn load_environment(enclosing_cx: @block_ctxt, fcx: @fn_ctxt, envty: ty::t,
2671
2694
2672
2695
// Load the actual upvars.
2673
2696
for upvar_def in * upvars {
2697
+ // Silly check
2698
+ check type_is_tup_like ( bcx, ty) ;
2674
2699
let upvarptr = GEP_tup_like ( bcx, ty, llclosure, path + [ i as int ] ) ;
2675
2700
bcx = upvarptr. bcx ;
2676
2701
let llupvarptr = upvarptr. val ;
@@ -2984,7 +3009,10 @@ fn trans_field_inner(cx: @block_ctxt, sp: span, v: ValueRef, t0: ty::t,
2984
3009
alt ty:: struct ( bcx_tcx ( cx) , t) {
2985
3010
ty:: ty_rec ( fields) {
2986
3011
let ix: uint = ty:: field_idx ( bcx_ccx ( cx) . sess , sp, field, fields) ;
2987
- let v = GEP_tup_like ( r. bcx , t, r. val , [ 0 , ix as int ] ) ;
3012
+ let r_bcx = r. bcx ;
3013
+ // Silly check
3014
+ check type_is_tup_like ( r_bcx, t) ;
3015
+ let v = GEP_tup_like ( r_bcx, t, r. val , [ 0 , ix as int ] ) ;
2988
3016
ret lval_no_env ( v. bcx , v. val , true ) ;
2989
3017
}
2990
3018
ty:: ty_obj ( methods) {
@@ -3329,6 +3357,8 @@ fn trans_bind_thunk(cx: @local_ctxt, sp: span, incoming_fty: ty::t,
3329
3357
( fptr, C_null ( T_opaque_closure_ptr ( * bcx_ccx ( bcx) ) ) , 0 )
3330
3358
}
3331
3359
none. {
3360
+ // Silly check
3361
+ check type_is_tup_like ( bcx, closure_ty) ;
3332
3362
let { bcx: cx , val : pair } =
3333
3363
GEP_tup_like ( bcx, closure_ty, llclosure,
3334
3364
[ 0 , abi:: box_rc_field_body,
@@ -3368,6 +3398,8 @@ fn trans_bind_thunk(cx: @local_ctxt, sp: span, incoming_fty: ty::t,
3368
3398
// Copy in the type parameters.
3369
3399
let i: uint = 0 u;
3370
3400
while i < ty_param_count {
3401
+ // Silly check
3402
+ check type_is_tup_like ( copy_args_bcx, closure_ty) ;
3371
3403
let lltyparam_ptr =
3372
3404
GEP_tup_like ( copy_args_bcx, closure_ty, llclosure,
3373
3405
[ 0 , abi:: box_rc_field_body,
@@ -3391,6 +3423,8 @@ fn trans_bind_thunk(cx: @local_ctxt, sp: span, incoming_fty: ty::t,
3391
3423
// Arg provided at binding time; thunk copies it from
3392
3424
// closure.
3393
3425
some( e) {
3426
+ // Silly check
3427
+ check type_is_tup_like( bcx, closure_ty) ;
3394
3428
let bound_arg =
3395
3429
GEP_tup_like ( bcx, closure_ty, llclosure,
3396
3430
[ 0 , abi : : box_rc_field_body,
@@ -3914,6 +3948,8 @@ fn trans_tup(cx: @block_ctxt, elts: [@ast::expr], id: ast::node_id) ->
3914
3948
let e_ty = ty:: expr_ty ( cx. fcx . lcx . ccx . tcx , e) ;
3915
3949
let src = trans_lval ( bcx, e) ;
3916
3950
bcx = src. bcx ;
3951
+ // FIXME: constraint on argument?
3952
+ check type_is_tup_like ( bcx, t) ;
3917
3953
let dst_res = GEP_tup_like ( bcx, t, tup_val, [ 0 , i] ) ;
3918
3954
bcx = move_val_if_temp ( dst_res. bcx , INIT , dst_res. val , src, e_ty) ;
3919
3955
i += 1 ;
@@ -3943,6 +3979,8 @@ fn trans_rec(cx: @block_ctxt, fields: [ast::field],
3943
3979
alt ty:: struct ( bcx_tcx ( cx) , t) { ty:: ty_rec ( flds) { ty_fields = flds; } }
3944
3980
for tf: ty:: field in ty_fields {
3945
3981
let e_ty = tf. mt . ty ;
3982
+ // FIXME: constraint on argument?
3983
+ check type_is_tup_like ( bcx, t) ;
3946
3984
let dst_res = GEP_tup_like ( bcx, t, rec_val, [ 0 , i] ) ;
3947
3985
bcx = dst_res. bcx ;
3948
3986
let expr_provided = false ;
@@ -3956,6 +3994,8 @@ fn trans_rec(cx: @block_ctxt, fields: [ast::field],
3956
3994
}
3957
3995
}
3958
3996
if !expr_provided {
3997
+ // FIXME: constraint on argument?
3998
+ check type_is_tup_like ( bcx, t) ;
3959
3999
let src_res = GEP_tup_like ( bcx, t, base_val, [ 0 , i] ) ;
3960
4000
src_res =
3961
4001
rslt ( src_res. bcx , load_if_immediate ( bcx, src_res. val , e_ty) ) ;
@@ -5100,6 +5140,8 @@ fn populate_fn_ctxt_from_llself(fcx: @fn_ctxt, llself: val_self_pair) {
5100
5140
}
5101
5141
i = 0 ;
5102
5142
for f: ast:: obj_field in fcx. lcx . obj_fields {
5143
+ // FIXME: silly check
5144
+ check type_is_tup_like ( bcx, fields_tup_ty) ;
5103
5145
let rslt = GEP_tup_like ( bcx, fields_tup_ty, obj_fields, [ 0 , i] ) ;
5104
5146
bcx = llstaticallocas_block_ctxt ( fcx) ;
5105
5147
let llfield = rslt. val ;
@@ -5248,9 +5290,12 @@ fn trans_res_ctor(cx: @local_ctxt, sp: span, dtor: ast::_fn,
5248
5290
llretptr = BitCast ( bcx, llretptr, llret_t) ;
5249
5291
}
5250
5292
5293
+ // FIXME: silly checks
5294
+ check type_is_tup_like ( bcx, tup_t) ;
5251
5295
let dst = GEP_tup_like ( bcx, tup_t, llretptr, [ 0 , 1 ] ) ;
5252
5296
bcx = dst. bcx ;
5253
5297
bcx = copy_val ( bcx, INIT , dst. val , arg, arg_t) ;
5298
+ check type_is_tup_like ( bcx, tup_t) ;
5254
5299
let flag = GEP_tup_like ( bcx, tup_t, llretptr, [ 0 , 0 ] ) ;
5255
5300
bcx = flag. bcx ;
5256
5301
Store ( bcx, C_int ( 1 ) , flag. val ) ;
0 commit comments