@@ -89,7 +89,7 @@ export ty_uniq, mk_uniq, mk_imm_uniq, type_is_unique_box;
89
89
export ty_var, mk_var;
90
90
export ty_self, mk_self;
91
91
export region, re_named, re_caller, re_block;
92
- export get, type_has_params, type_has_vars, type_id;
92
+ export get, type_has_params, type_has_vars, type_has_rptrs , type_id;
93
93
export same_type;
94
94
export ty_var_id;
95
95
export ty_fn_args;
@@ -187,6 +187,7 @@ type t_box = @{struct: sty,
187
187
id : uint ,
188
188
has_params : bool ,
189
189
has_vars : bool ,
190
+ has_rptrs : bool ,
190
191
o_def_id : option < ast:: def_id > } ;
191
192
192
193
// To reduce refcounting cost, we're representing types as unsafe pointers
@@ -206,6 +207,7 @@ pure fn get(t: t) -> t_box unsafe {
206
207
207
208
fn type_has_params ( t : t ) -> bool { get ( t) . has_params }
208
209
fn type_has_vars ( t : t ) -> bool { get ( t) . has_vars }
210
+ fn type_has_rptrs ( t : t ) -> bool { get ( t) . has_rptrs }
209
211
fn type_def_id ( t : t ) -> option < ast:: def_id > { get ( t) . o_def_id }
210
212
fn type_id ( t : t ) -> uint { get ( t) . id }
211
213
@@ -368,11 +370,13 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
368
370
some ( t) { unsafe { ret unsafe:: reinterpret_cast ( t) ; } }
369
371
_ { }
370
372
}
371
- let has_params = false , has_vars = false ;
372
- fn derive_flags ( & has_params: bool , & has_vars: bool , tt : t ) {
373
+ let has_params = false , has_vars = false , has_rptrs = false ;
374
+ fn derive_flags ( & has_params: bool , & has_vars: bool , & has_rptrs: bool ,
375
+ tt : t ) {
373
376
let t = get ( tt) ;
374
377
has_params |= t. has_params ;
375
378
has_vars |= t. has_vars ;
379
+ has_rptrs |= t. has_rptrs ;
376
380
}
377
381
alt st {
378
382
ty_nil | ty_bot | ty_bool | ty_int ( _) | ty_float ( _) | ty_uint ( _) |
@@ -381,33 +385,42 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
381
385
ty_param( _, _) { has_params = true ; }
382
386
ty_var ( _) | ty_self ( _) { has_vars = true ; }
383
387
ty_enum ( _, tys) | ty_iface ( _, tys) | ty_class ( _, tys) {
384
- for tt in tys { derive_flags ( has_params, has_vars, tt) ; }
388
+ for tt in tys { derive_flags ( has_params, has_vars, has_rptrs , tt) ; }
385
389
}
386
- ty_box ( m) | ty_uniq ( m) | ty_vec ( m) | ty_ptr ( m) | ty_rptr ( _, m) {
387
- derive_flags ( has_params, has_vars, m. ty ) ;
390
+ ty_box ( m) | ty_uniq ( m) | ty_vec ( m) | ty_ptr ( m) {
391
+ derive_flags ( has_params, has_vars, has_rptrs, m. ty ) ;
392
+ }
393
+ ty_rptr ( _, m) {
394
+ has_rptrs = true ;
395
+ derive_flags ( has_params, has_vars, has_rptrs, m. ty ) ;
388
396
}
389
397
ty_rec ( flds) {
390
- for f in flds { derive_flags ( has_params, has_vars, f. mt . ty ) ; }
398
+ for f in flds {
399
+ derive_flags ( has_params, has_vars, has_rptrs, f. mt . ty ) ;
400
+ }
391
401
}
392
402
ty_tup ( ts) {
393
- for tt in ts { derive_flags ( has_params, has_vars, tt) ; }
403
+ for tt in ts { derive_flags ( has_params, has_vars, has_rptrs , tt) ; }
394
404
}
395
405
ty_fn ( f) {
396
- for a in f. inputs { derive_flags ( has_params, has_vars, a. ty ) ; }
397
- derive_flags ( has_params, has_vars, f. output ) ;
406
+ for a in f. inputs {
407
+ derive_flags ( has_params, has_vars, has_rptrs, a. ty ) ;
408
+ }
409
+ derive_flags ( has_params, has_vars, has_rptrs, f. output ) ;
398
410
}
399
411
ty_res ( _, tt, tps) {
400
- derive_flags ( has_params, has_vars, tt) ;
401
- for tt in tps { derive_flags ( has_params, has_vars, tt) ; }
412
+ derive_flags ( has_params, has_vars, has_rptrs , tt) ;
413
+ for tt in tps { derive_flags ( has_params, has_vars, has_rptrs , tt) ; }
402
414
}
403
415
ty_constr ( tt, _) {
404
- derive_flags ( has_params, has_vars, tt) ;
416
+ derive_flags ( has_params, has_vars, has_rptrs , tt) ;
405
417
}
406
418
}
407
419
let t = @{ struct : st,
408
420
id: cx. next_id,
409
421
has_params: has_params,
410
422
has_vars: has_vars,
423
+ has_rptrs: has_rptrs,
411
424
o_def_id: o_def_id } ;
412
425
cx. interner . insert ( key, t) ;
413
426
cx. next_id += 1 u;
0 commit comments