@@ -57,8 +57,6 @@ type tag_info = rec(type_handle th,
57
57
mutable vec[ tup( ast. def_id, arity) ] variants ,
58
58
mutable uint size) ;
59
59
60
- type ty_info = rec ( ValueRef take_glue , ValueRef drop_glue ) ;
61
-
62
60
state type crate_ctxt = rec ( session. session sess,
63
61
ModuleRef llmod,
64
62
target_data td,
@@ -222,7 +220,7 @@ fn T_tydesc() -> TypeRef {
222
220
ret T_struct ( vec ( pvoid, // first_param
223
221
T_int ( ) , // size
224
222
T_int ( ) , // align
225
- glue_fn_ty, // copy_glue_off
223
+ glue_fn_ty, // take_glue_off
226
224
glue_fn_ty, // drop_glue_off
227
225
glue_fn_ty, // free_glue_off
228
226
glue_fn_ty, // sever_glue_off
@@ -375,7 +373,7 @@ fn type_of_inner(@crate_ctxt cx, @typeck.ty t) -> TypeRef {
375
373
let TypeRef vtbl = T_struct ( mtys) ;
376
374
let TypeRef pair =
377
375
T_struct ( vec ( T_ptr ( vtbl) ,
378
- T_ptr ( T_box ( T_opaque ( ) ) ) ) ) ;
376
+ T_ptr ( T_box ( T_nil ( ) ) ) ) ) ;
379
377
ret pair;
380
378
}
381
379
case ( typeck. ty_var ( _) ) {
@@ -614,7 +612,7 @@ fn make_tydesc(@crate_ctxt cx, @typeck.ty ty) {
614
612
auto tydesc = C_struct ( vec ( C_null ( pvoid) ,
615
613
size_of ( llty) ,
616
614
align_of ( llty) ,
617
- take_glue, // copy_glue_off
615
+ take_glue, // take_glue_off
618
616
drop_glue, // drop_glue_off
619
617
C_null ( glue_fn_ty) , // free_glue_off
620
618
C_null ( glue_fn_ty) , // sever_glue_off
@@ -665,9 +663,6 @@ fn make_take_glue(@block_ctxt cx, ValueRef v, @typeck.ty t) -> result {
665
663
if ( typeck. type_is_boxed ( t) ) {
666
664
ret incr_refcnt_of_boxed ( cx, v) ;
667
665
668
- } else if ( typeck. type_is_binding ( t) ) {
669
- cx. fcx . ccx . sess . unimpl ( "binding type in trans.incr_all_refcnts" ) ;
670
-
671
666
} else if ( typeck. type_is_structural ( t) ) {
672
667
ret iter_structural_ty ( cx, v, t,
673
668
bind incr_all_refcnts ( _, _, _) ) ;
@@ -739,10 +734,6 @@ fn make_drop_glue(@block_ctxt cx, ValueRef v, @typeck.ty t) -> result {
739
734
ret iter_structural_ty ( cx, v, t,
740
735
bind drop_ty ( _, _, _) ) ;
741
736
742
- } else if ( typeck. type_is_binding ( t) ) {
743
- cx. fcx . ccx . sess . unimpl ( "binding type in " +
744
- "trans.make_drop_glue_inner" ) ;
745
-
746
737
} else if ( typeck. type_is_scalar ( t) ||
747
738
typeck. type_is_nil ( t) ) {
748
739
ret res ( cx, C_nil ( ) ) ;
@@ -813,13 +804,14 @@ fn type_of_variant(@crate_ctxt cx, &ast.variant v) -> TypeRef {
813
804
type val_and_ty_fn =
814
805
fn ( @block_ctxt cx , ValueRef v, @typeck. ty t ) -> result ;
815
806
816
- // Iterates through the elements of a box, tup, rec or tag .
807
+ // Iterates through the elements of a structural type .
817
808
fn iter_structural_ty ( @block_ctxt cx ,
818
809
ValueRef v,
819
810
@typeck. ty t ,
820
811
val_and_ty_fn f)
821
812
-> result {
822
813
let result r = res ( cx, C_nil ( ) ) ;
814
+
823
815
alt ( t. struct ) {
824
816
case ( typeck. ty_tup ( ?args) ) {
825
817
let int i = 0 ;
@@ -922,6 +914,26 @@ fn iter_structural_ty(@block_ctxt cx,
922
914
923
915
ret res( next_cx, C_nil ( ) ) ;
924
916
}
917
+ case ( typeck. ty_fn( _, _) ) {
918
+ auto box_cell =
919
+ cx. build. GEP ( v,
920
+ vec( C_int ( 0 ) ,
921
+ 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) ;
926
+ }
927
+ case ( typeck. ty_obj( _) ) {
928
+ auto box_cell =
929
+ cx. build. GEP ( v,
930
+ vec( C_int ( 0 ) ,
931
+ 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) ;
936
+ }
925
937
case ( _) {
926
938
cx. fcx. ccx. sess. unimpl( "type in iter_structural_ty" ) ;
927
939
}
@@ -1004,9 +1016,10 @@ fn iter_sequence(@block_ctxt cx,
1004
1016
fn incr_all_refcnts( @block_ctxt cx,
1005
1017
ValueRef v,
1006
1018
@typeck. ty t) -> result {
1019
+
1007
1020
if ( !typeck. type_is_scalar( t) ) {
1008
1021
auto llrawptr = cx. build. BitCast ( v, T_ptr ( T_i8 ( ) ) ) ;
1009
- auto llfnptr = field_of_tydesc( cx, t, abi. tydesc_field_copy_glue_off ) ;
1022
+ auto llfnptr = field_of_tydesc( cx, t, abi. tydesc_field_take_glue_off ) ;
1010
1023
auto llfn = cx. build. Load ( llfnptr) ;
1011
1024
cx. build. FastCall ( llfn, vec( cx. fcx. lltaskptr, llrawptr) ) ;
1012
1025
}
@@ -1028,6 +1041,7 @@ fn drop_slot(@block_ctxt cx,
1028
1041
fn drop_ty( @block_ctxt cx,
1029
1042
ValueRef v,
1030
1043
@typeck. ty t) -> result {
1044
+
1031
1045
if ( !typeck. type_is_scalar( t) ) {
1032
1046
auto llrawptr = cx. build. BitCast ( v, T_ptr ( T_i8 ( ) ) ) ;
1033
1047
auto llfnptr = field_of_tydesc( cx, t, abi. tydesc_field_drop_glue_off) ;
@@ -1072,9 +1086,6 @@ fn copy_ty(@block_ctxt cx,
1072
1086
} else if ( typeck. type_is_nil( t) ) {
1073
1087
ret res( cx, C_nil ( ) ) ;
1074
1088
1075
- } else if ( typeck. type_is_binding( t) ) {
1076
- cx. fcx. ccx. sess. unimpl( "binding type in trans.copy_ty" ) ;
1077
-
1078
1089
} else if ( typeck. type_is_boxed( t) ) {
1079
1090
auto r = incr_all_refcnts( cx, src, t) ;
1080
1091
if ( ! is_init) {
@@ -1452,7 +1463,7 @@ impure fn trans_pat_match(@block_ctxt cx, @ast.pat pat, ValueRef llval,
1452
1463
case ( ast. pat_tag( ?id, ?subpats, ?vdef_opt, ?ann) ) {
1453
1464
auto lltagptr = cx. build. GEP ( llval, vec( C_int ( 0 ) , C_int ( 0 ) ) ) ;
1454
1465
auto lltag = cx. build. Load ( lltagptr) ;
1455
-
1466
+
1456
1467
auto vdef = option. get[ ast. variant_def] ( vdef_opt) ;
1457
1468
auto variant_id = vdef. _1;
1458
1469
auto tinfo = cx. fcx. ccx. tags. get( vdef. _0) ;
@@ -2423,7 +2434,7 @@ impure fn trans_obj(@crate_ctxt cx, &ast._obj ob, ast.def_id oid,
2423
2434
vec( C_int ( 0 ) ,
2424
2435
C_int ( abi. obj_field_vtbl) ) ) ;
2425
2436
bcx. build. Store ( vtbl, pair_vtbl) ;
2426
- bcx. build. Ret ( pair) ;
2437
+ bcx. build. Ret ( bcx . build . Load ( pair) ) ;
2427
2438
}
2428
2439
2429
2440
fn trans_tag_variant( @crate_ctxt cx, ast. def_id tag_id,
0 commit comments