@@ -1272,8 +1272,8 @@ fn static_size_of_tag(&@crate_ctxt cx, &ast::span sp, &ty::t t) -> uint {
1272
1272
1273
1273
// Compute max(variant sizes).
1274
1274
auto max_size = 0 u;
1275
- auto variants = tag_variants ( cx, tid) ;
1276
- for ( variant_info variant in variants) {
1275
+ auto variants = ty :: tag_variants ( cx. tcx , tid) ;
1276
+ for ( ty :: variant_info variant in variants) {
1277
1277
auto tup_ty = simplify_type( cx, ty:: mk_imm_tup( cx. tcx, variant. args) ) ;
1278
1278
1279
1279
// Perform any type parameter substitutions.
@@ -1345,8 +1345,8 @@ fn dynamic_size_of(&@block_ctxt cx, ty::t t) -> result {
1345
1345
let ValueRef max_size = alloca( bcx, T_int ( ) ) ;
1346
1346
bcx. build. Store ( C_int ( 0 ) , max_size) ;
1347
1347
1348
- auto variants = tag_variants( bcx. fcx. lcx. ccx, tid) ;
1349
- for ( variant_info variant in variants) {
1348
+ auto variants = ty :: tag_variants( bcx. fcx. lcx. ccx. tcx , tid) ;
1349
+ for ( ty :: variant_info variant in variants) {
1350
1350
// Perform type substitution on the raw argument types.
1351
1351
let vec[ ty:: t] raw_tys = variant. args;
1352
1352
let vec[ ty:: t] tys = [ ] ;
@@ -1521,7 +1521,8 @@ fn GEP_tag(@block_ctxt cx,
1521
1521
& vec[ ty:: t ] ty_substs ,
1522
1522
int ix)
1523
1523
-> result {
1524
- auto variant = tag_variant_with_id ( cx. fcx . lcx . ccx , tag_id, variant_id) ;
1524
+ auto variant = ty:: tag_variant_with_id ( cx. fcx . lcx . ccx . tcx ,
1525
+ tag_id, variant_id) ;
1525
1526
1526
1527
// Synthesize a tuple type so that GEP_tup_like() can work its magic.
1527
1528
// Separately, store the type of the element we're interested in.
@@ -2213,14 +2214,10 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
2213
2214
}
2214
2215
2215
2216
case ( _) {
2216
- if ( ty:: type_is_structural ( cx. fcx . lcx . ccx . tcx , t) ) {
2217
+ if ( ty:: type_contains_pointers ( cx. fcx . lcx . ccx . tcx , t) &&
2218
+ ty:: type_is_structural ( cx. fcx . lcx . ccx . tcx , t) ) {
2217
2219
rslt = iter_structural_ty ( cx, v0, t,
2218
2220
bind drop_ty ( _, _, _) ) ;
2219
-
2220
- } else if ( ty:: type_is_scalar ( cx. fcx . lcx . ccx . tcx , t) ||
2221
- ty:: type_is_native ( cx. fcx . lcx . ccx . tcx , t) ||
2222
- ty:: type_is_nil ( cx. fcx . lcx . ccx . tcx , t) ) {
2223
- rslt = res ( cx, C_nil ( ) ) ;
2224
2221
} else {
2225
2222
rslt = res ( cx, C_nil ( ) ) ;
2226
2223
}
@@ -2543,58 +2540,6 @@ fn make_integral_cmp_glue(&@block_ctxt cx, ValueRef lhs, ValueRef rhs,
2543
2540
r. bcx . build . RetVoid ( ) ;
2544
2541
}
2545
2542
2546
-
2547
- // Tag information
2548
-
2549
- type variant_info = rec ( vec[ ty:: t ] args , ty:: t ctor_ty , ast:: def_id id) ;
2550
-
2551
- // Returns information about the variants in a tag.
2552
- fn tag_variants( & @crate_ctxt cx , & ast:: def_id id) -> vec[ variant_info ] {
2553
- if ( cx. sess . get_targ_crate_num ( ) != id. _0 ) {
2554
- ret creader:: get_tag_variants ( cx. sess , cx. tcx , id) ;
2555
- }
2556
-
2557
- assert ( cx. items . contains_key ( id) ) ;
2558
- alt ( cx. items . get ( id) . node ) {
2559
- case ( ast:: item_tag ( _, ?variants, _, _, _) ) {
2560
- let vec[ variant_info] result = [ ] ;
2561
- for ( ast:: variant variant in variants) {
2562
- auto ctor_ty = node_ann_type( cx, variant. node. ann) ;
2563
- let vec[ ty:: t] arg_tys = [ ] ;
2564
- if ( vec:: len[ ast:: variant_arg] ( variant. node. args) > 0 u) {
2565
- for ( ty:: arg a in ty:: ty_fn_args( cx. tcx, ctor_ty) ) {
2566
- arg_tys += [ a. ty] ;
2567
- }
2568
- }
2569
- auto did = variant. node. id;
2570
- result += [ rec( args=arg_tys, ctor_ty=ctor_ty, id=did) ] ;
2571
- }
2572
- ret result;
2573
- }
2574
- }
2575
- fail; // not reached
2576
- }
2577
-
2578
- // Returns information about the tag variant with the given ID:
2579
- fn tag_variant_with_id( & @crate_ctxt cx,
2580
- & ast:: def_id tag_id,
2581
- & ast:: def_id variant_id) -> variant_info {
2582
- auto variants = tag_variants( cx, tag_id) ;
2583
-
2584
- auto i = 0 u;
2585
- while ( i < vec : : len[ variant_info] ( variants) ) {
2586
- auto variant = variants. ( i) ;
2587
- if ( common:: def_eq( variant. id, variant_id) ) {
2588
- ret variant;
2589
- }
2590
- i += 1 u;
2591
- }
2592
-
2593
- log_err "tag_variant_with_id(): no variant exists with that ID" ;
2594
- fail;
2595
- }
2596
-
2597
-
2598
2543
type val_pair_fn = fn ( & @block_ctxt cx , ValueRef dst, ValueRef src) -> result ;
2599
2544
2600
2545
type val_and_ty_fn = fn ( & @block_ctxt cx , ValueRef v, ty:: t t) -> result ;
@@ -2677,8 +2622,8 @@ fn iter_structural_ty_full(&@block_ctxt cx,
2677
2622
}
2678
2623
}
2679
2624
case ( ty:: ty_tag ( ?tid, ?tps) ) {
2680
- auto variants = tag_variants( cx. fcx. lcx. ccx, tid) ;
2681
- auto n_variants = vec:: len[ variant_info] ( variants) ;
2625
+ auto variants = ty :: tag_variants ( cx. fcx . lcx . ccx . tcx , tid) ;
2626
+ auto n_variants = vec:: len[ ty :: variant_info] ( variants) ;
2682
2627
2683
2628
// Cast the tags to types we can GEP into.
2684
2629
auto lltagty = T_opaque_tag_ptr ( cx. fcx . lcx . ccx . tn ) ;
@@ -2712,7 +2657,7 @@ fn iter_structural_ty_full(&@block_ctxt cx,
2712
2657
auto next_cx = new_sub_block_ctxt ( bcx, "tag-iter-next" ) ;
2713
2658
2714
2659
auto i = 0 u;
2715
- for ( variant_info variant in variants) {
2660
+ for ( ty :: variant_info variant in variants) {
2716
2661
auto variant_cx = new_sub_block_ctxt( bcx,
2717
2662
"tag-iter-variant-" +
2718
2663
uint:: to_str( i, 10 u) ) ;
@@ -3167,7 +3112,7 @@ fn drop_ty(&@block_ctxt cx,
3167
3112
ValueRef v,
3168
3113
ty:: t t) -> result {
3169
3114
3170
- if ( ! ty:: type_is_scalar ( cx. fcx. lcx. ccx. tcx, t) ) {
3115
+ if ( ty:: type_contains_pointers ( cx. fcx. lcx. ccx. tcx, t) ) {
3171
3116
ret call_tydesc_glue( cx, v, t, false, abi:: tydesc_field_drop_glue) ;
3172
3117
}
3173
3118
ret res( cx, C_nil ( ) ) ;
@@ -3177,7 +3122,7 @@ fn free_ty(&@block_ctxt cx,
3177
3122
ValueRef v,
3178
3123
ty:: t t) -> result {
3179
3124
3180
- if ( ! ty:: type_is_scalar ( cx. fcx. lcx. ccx. tcx, t) ) {
3125
+ if ( ty:: type_contains_pointers ( cx. fcx. lcx. ccx. tcx, t) ) {
3181
3126
ret call_tydesc_glue( cx, v, t, false, abi:: tydesc_field_free_glue) ;
3182
3127
}
3183
3128
ret res( cx, C_nil ( ) ) ;
@@ -3335,27 +3280,9 @@ fn trans_lit(&@crate_ctxt cx, &ast::lit lit, &ast::ann ann) -> ValueRef {
3335
3280
}
3336
3281
}
3337
3282
3338
- fn target_type( & @crate_ctxt cx, & ty:: t t) -> ty:: t {
3339
- alt ( ty:: struct ( cx. tcx, t) ) {
3340
- case ( ty:: ty_int) {
3341
- auto struct_ty = ty:: mk_mach( cx. tcx,
3342
- cx. sess. get_targ_cfg( ) . int_type) ;
3343
- ret ty:: copy_cname( cx. tcx, struct_ty, t) ;
3344
- }
3345
- case ( ty:: ty_uint) {
3346
- auto struct_ty = ty:: mk_mach( cx. tcx,
3347
- cx. sess. get_targ_cfg( ) . uint_type) ;
3348
- ret ty:: copy_cname( cx. tcx, struct_ty, t) ;
3349
- }
3350
- case ( _) { /* fall through */ }
3351
- }
3352
- ret t;
3353
- }
3354
-
3355
-
3356
3283
// Converts an annotation to a type
3357
3284
fn node_ann_type( & @crate_ctxt cx, & ast:: ann a) -> ty:: t {
3358
- ret target_type ( cx , ty:: ann_to_monotype( cx. tcx, a) ) ;
3285
+ ret ty:: ann_to_monotype( cx. tcx, a) ;
3359
3286
}
3360
3287
3361
3288
fn node_type( & @crate_ctxt cx, & ast:: span sp, & ast:: ann a) -> TypeRef {
@@ -4197,9 +4124,9 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
4197
4124
( cx. fcx . lcx . ccx . tcx . def_map . get ( ann. id ) ) ;
4198
4125
auto variant_tag = 0 ;
4199
4126
4200
- auto variants = tag_variants ( cx. fcx . lcx . ccx , vdef. _0 ) ;
4127
+ auto variants = ty :: tag_variants ( cx. fcx . lcx . ccx . tcx , vdef. _0 ) ;
4201
4128
auto i = 0 ;
4202
- for ( variant_info v in variants) {
4129
+ for ( ty :: variant_info v in variants) {
4203
4130
auto this_variant_id = v. id;
4204
4131
if ( vdef. _1. _0 == this_variant_id. _0 &&
4205
4132
vdef. _1. _1 == this_variant_id. _1) {
@@ -4467,18 +4394,15 @@ fn trans_path(&@block_ctxt cx, &ast::path p, &ast::ann ann) -> lval_result {
4467
4394
ret lval_mem( cx, cx. fcx. llobjfields. get( did) ) ;
4468
4395
}
4469
4396
case ( ast:: def_fn( ?did) ) {
4470
- auto tyt = ty:: lookup_item_type( cx. fcx. lcx. ccx. sess,
4471
- cx. fcx. lcx. ccx. tcx, did) ;
4397
+ auto tyt = ty:: lookup_item_type( cx. fcx. lcx. ccx. tcx, did) ;
4472
4398
ret lval_generic_fn( cx, tyt, did, ann) ;
4473
4399
}
4474
4400
case ( ast:: def_obj( ?did) ) {
4475
- auto tyt = ty:: lookup_item_type( cx. fcx. lcx. ccx. sess,
4476
- cx. fcx. lcx. ccx. tcx, did) ;
4401
+ auto tyt = ty:: lookup_item_type( cx. fcx. lcx. ccx. tcx, did) ;
4477
4402
ret lval_generic_fn( cx, tyt, did, ann) ;
4478
4403
}
4479
4404
case ( ast:: def_variant( ?tid, ?vid) ) {
4480
- auto v_tyt = ty:: lookup_item_type( cx. fcx. lcx. ccx. sess,
4481
- cx. fcx. lcx. ccx. tcx, vid) ;
4405
+ auto v_tyt = ty:: lookup_item_type( cx. fcx. lcx. ccx. tcx, vid) ;
4482
4406
alt ( ty:: struct( cx. fcx. lcx. ccx. tcx, v_tyt. _1) ) {
4483
4407
case ( ty:: ty_fn( _, _, _) ) {
4484
4408
// N-ary variant.
@@ -4519,8 +4443,7 @@ fn trans_path(&@block_ctxt cx, &ast::path p, &ast::ann ann) -> lval_result {
4519
4443
ret lval_mem( cx, cx. fcx. lcx. ccx. consts. get( did) ) ;
4520
4444
}
4521
4445
case ( ast:: def_native_fn( ?did) ) {
4522
- auto tyt = ty:: lookup_item_type( cx. fcx. lcx. ccx. sess,
4523
- cx. fcx. lcx. ccx. tcx, did) ;
4446
+ auto tyt = ty:: lookup_item_type( cx. fcx. lcx. ccx. tcx, did) ;
4524
4447
ret lval_generic_fn( cx, tyt, did, ann) ;
4525
4448
}
4526
4449
case ( _) {
0 commit comments