@@ -812,6 +812,23 @@ fn iter_structural_ty(@block_ctxt cx,
812
812
-> result {
813
813
let result r = res ( cx, C_nil ( ) ) ;
814
814
815
+ fn iter_boxpp ( @block_ctxt cx ,
816
+ ValueRef box_cell,
817
+ val_and_ty_fn f) -> result {
818
+ auto box_ptr = cx. build . Load ( box_cell) ;
819
+ auto tnil = typeck. plain_ty ( typeck. ty_nil ) ;
820
+ auto tbox = typeck. plain_ty ( typeck. ty_box ( tnil) ) ;
821
+
822
+ auto inner_cx = new_sub_block_ctxt ( cx, "iter box" ) ;
823
+ auto next_cx = new_sub_block_ctxt ( cx, "next" ) ;
824
+ auto null_test = cx. build . IsNull ( box_ptr) ;
825
+ cx. build . CondBr ( null_test, next_cx. llbb , inner_cx. llbb ) ;
826
+
827
+ auto r = f ( inner_cx, box_ptr, tbox) ;
828
+ r. bcx . build . Br ( next_cx. llbb ) ;
829
+ ret res ( next_cx, r. val ) ;
830
+ }
831
+
815
832
alt ( t. struct ) {
816
833
case ( typeck. ty_tup ( ?args) ) {
817
834
let int i = 0 ;
@@ -919,20 +936,14 @@ fn iter_structural_ty(@block_ctxt cx,
919
936
cx. build. GEP ( v,
920
937
vec( C_int ( 0 ) ,
921
938
C_int ( abi. fn_field_box) ) ) ;
922
- auto box_ptr = cx. build. Load ( box_cell) ;
923
- auto tnil = typeck. plain_ty( typeck. ty_nil) ;
924
- auto tbox = typeck. plain_ty( typeck. ty_box( tnil) ) ;
925
- ret f( cx, box_ptr, tbox) ;
939
+ ret iter_boxpp( cx, box_cell, f) ;
926
940
}
927
941
case ( typeck. ty_obj( _) ) {
928
942
auto box_cell =
929
943
cx. build. GEP ( v,
930
944
vec( C_int ( 0 ) ,
931
945
C_int ( abi. obj_field_box) ) ) ;
932
- auto box_ptr = cx. build. Load ( box_cell) ;
933
- auto tnil = typeck. plain_ty( typeck. ty_nil) ;
934
- auto tbox = typeck. plain_ty( typeck. ty_box( tnil) ) ;
935
- ret f( cx, box_ptr, tbox) ;
946
+ ret iter_boxpp( cx, box_cell, f) ;
936
947
}
937
948
case ( _) {
938
949
cx. fcx. ccx. sess. unimpl( "type in iter_structural_ty" ) ;
@@ -2447,7 +2458,14 @@ impure fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,
2447
2458
auto pair_vtbl = bcx. build. GEP ( pair,
2448
2459
vec( C_int ( 0 ) ,
2449
2460
C_int ( abi. obj_field_vtbl) ) ) ;
2461
+ auto pair_box = bcx. build. GEP ( pair,
2462
+ vec( C_int ( 0 ) ,
2463
+ C_int ( abi. obj_field_box) ) ) ;
2450
2464
bcx. build. Store ( vtbl, pair_vtbl) ;
2465
+
2466
+ // FIXME: allocate the object body, copy the args in, etc.
2467
+ bcx. build. Store ( C_null ( T_ptr ( T_box ( T_nil ( ) ) ) ) , pair_box) ;
2468
+
2451
2469
bcx. build. Ret ( bcx. build. Load ( pair) ) ;
2452
2470
}
2453
2471
0 commit comments