@@ -100,7 +100,8 @@ export ty_uniq, mk_uniq, mk_imm_uniq, type_is_unique_box;
100
100
export ty_var, mk_var;
101
101
export ty_self, mk_self;
102
102
export region, bound_region;
103
- export get, type_has_params, type_has_vars, type_has_regions, type_id;
103
+ export get, type_has_params, type_has_vars, type_has_regions;
104
+ export type_has_resources, type_id;
104
105
export ty_var_id;
105
106
export ty_to_def_id;
106
107
export ty_fn_args;
@@ -235,6 +236,7 @@ type t_box = @{struct: sty,
235
236
has_params : bool ,
236
237
has_vars : bool ,
237
238
has_regions : bool ,
239
+ has_resources : bool ,
238
240
o_def_id : option < ast:: def_id > } ;
239
241
240
242
// To reduce refcounting cost, we're representing types as unsafe pointers
@@ -255,6 +257,7 @@ pure fn get(t: t) -> t_box unsafe {
255
257
fn type_has_params ( t : t ) -> bool { get ( t) . has_params }
256
258
fn type_has_vars ( t : t ) -> bool { get ( t) . has_vars }
257
259
fn type_has_regions ( t : t ) -> bool { get ( t) . has_regions }
260
+ fn type_has_resources ( t : t ) -> bool { get ( t) . has_resources }
258
261
fn type_def_id ( t : t ) -> option < ast:: def_id > { get ( t) . o_def_id }
259
262
fn type_id ( t : t ) -> uint { get ( t) . id }
260
263
@@ -478,13 +481,15 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
478
481
some ( t) { unsafe { ret unsafe:: reinterpret_cast ( t) ; } }
479
482
_ { }
480
483
}
481
- let mut has_params = false , has_vars = false , has_regions = false ;
484
+ let mut has_params = false , has_vars = false , has_regions = false ,
485
+ has_resources = false ;
482
486
fn derive_flags ( & has_params: bool , & has_vars: bool , & has_regions: bool ,
483
- tt : t ) {
487
+ & has_resources : bool , tt : t ) {
484
488
let t = get ( tt) ;
485
489
has_params |= t. has_params ;
486
490
has_vars |= t. has_vars ;
487
491
has_regions |= t. has_regions ;
492
+ has_resources |= t. has_resources ;
488
493
}
489
494
fn derive_rflags ( & has_vars: bool , & has_regions: bool , r : region ) {
490
495
has_regions = true ;
@@ -494,9 +499,10 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
494
499
}
495
500
}
496
501
fn derive_sflags ( & has_params: bool , & has_vars: bool , & has_regions: bool ,
497
- substs : substs ) {
502
+ & has_resources : bool , substs : substs ) {
498
503
for substs. tps. each { |tt|
499
- derive_flags( has_params, has_vars, has_regions, tt) ;
504
+ derive_flags( has_params, has_vars, has_regions,
505
+ has_resources, tt) ;
500
506
}
501
507
substs. self_r . iter { |r| derive_rflags ( has_vars, has_regions, r) }
502
508
}
@@ -506,56 +512,69 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
506
512
}
507
513
ty_evec ( mt, vstore_slice ( r) ) {
508
514
derive_rflags ( has_vars, has_regions, r) ;
509
- derive_flags ( has_params, has_vars, has_regions, mt. ty ) ;
515
+ derive_flags ( has_params, has_vars, has_regions,
516
+ has_resources, mt. ty ) ;
510
517
}
511
518
ty_nil | ty_bot | ty_bool | ty_int ( _) | ty_float ( _) | ty_uint ( _) |
512
519
ty_str | ty_estr ( _) | ty_type | ty_opaque_closure_ptr ( _) |
513
520
ty_opaque_box { }
514
521
ty_param( _, _) { has_params = true ; }
515
522
ty_var ( _) | ty_self ( _) { has_vars = true ; }
516
523
ty_enum ( _, substs) | ty_class ( _, substs) {
517
- derive_sflags ( has_params, has_vars, has_regions, substs) ;
524
+ derive_sflags ( has_params, has_vars, has_regions,
525
+ has_resources, substs) ;
518
526
}
519
527
ty_iface ( _, tys) {
520
528
for tys. each { |tt|
521
- derive_flags( has_params, has_vars, has_regions, tt) ;
529
+ derive_flags( has_params, has_vars, has_regions,
530
+ has_resources, tt) ;
522
531
}
523
532
}
524
533
ty_box( m) | ty_uniq( m) | ty_vec( m) | ty_evec( m, _) | ty_ptr( m) {
525
- derive_flags ( has_params, has_vars, has_regions, m. ty ) ;
534
+ derive_flags( has_params, has_vars, has_regions,
535
+ has_resources, m. ty) ;
526
536
}
527
537
ty_rptr( r, m) {
528
538
derive_rflags( has_vars, has_regions, r) ;
529
- derive_flags ( has_params, has_vars, has_regions, m. ty ) ;
539
+ derive_flags( has_params, has_vars, has_regions,
540
+ has_resources, m. ty) ;
530
541
}
531
542
ty_rec( flds) {
532
543
for flds. each { |f|
533
- derive_flags( has_params, has_vars, has_regions, f. mt. ty) ;
544
+ derive_flags( has_params, has_vars, has_regions,
545
+ has_resources, f. mt. ty) ;
534
546
}
535
547
}
536
548
ty_tup( ts) {
537
549
for ts. each { |tt| derive_flags( has_params, has_vars,
538
- has_regions, tt) ; }
550
+ has_regions, has_resources , tt) ; }
539
551
}
540
552
ty_fn( f) {
541
553
for f. inputs. each { |a|
542
- derive_flags( has_params, has_vars, has_regions, a. ty) ;
554
+ derive_flags( has_params, has_vars, has_regions,
555
+ has_resources, a. ty) ;
543
556
}
544
- derive_flags ( has_params, has_vars, has_regions, f. output ) ;
557
+ derive_flags( has_params, has_vars, has_regions,
558
+ has_resources, f. output) ;
545
559
}
546
560
ty_res( _, tt, substs) {
547
- derive_flags ( has_params, has_vars, has_regions, tt) ;
548
- derive_sflags ( has_params, has_vars, has_regions, substs) ;
561
+ has_resources = true ;
562
+ derive_flags( has_params, has_vars, has_regions,
563
+ has_resources, tt) ;
564
+ derive_sflags( has_params, has_vars, has_regions,
565
+ has_resources, substs) ;
549
566
}
550
567
ty_constr( tt, _) {
551
- derive_flags ( has_params, has_vars, has_regions, tt) ;
568
+ derive_flags( has_params, has_vars, has_regions,
569
+ has_resources, tt) ;
552
570
}
553
571
}
554
572
let t = @{ struct : st,
555
573
id: cx. next_id,
556
574
has_params: has_params,
557
575
has_vars: has_vars,
558
576
has_regions: has_regions,
577
+ has_resources: has_resources,
559
578
o_def_id: o_def_id} ;
560
579
cx. interner. insert( key, t) ;
561
580
cx. next_id += 1 u;
0 commit comments