@@ -89,8 +89,7 @@ type raw_t = rec(sty struct,
89
89
bool has_params ,
90
90
bool has_bound_params ,
91
91
bool has_vars ,
92
- bool has_locals ,
93
- bool has_pointers ) ;
92
+ bool has_locals ) ;
94
93
95
94
type t = uint ;
96
95
@@ -260,32 +259,28 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t {
260
259
let bool has_bound_params = false ;
261
260
let bool has_vars = false ;
262
261
let bool has_locals = false ;
263
- let bool has_pointers = false ;
264
262
265
263
fn derive_flags_t ( & ctxt cx,
266
264
& mutable bool has_params ,
267
265
& mutable bool has_bound_params ,
268
266
& mutable bool has_vars ,
269
267
& mutable bool has_locals ,
270
- & mutable bool has_pointers ,
271
268
& t tt ) {
272
269
auto rt = interner:: get[ raw_t] ( * cx. ts , tt) ;
273
270
has_params = has_params || rt. has_params ;
274
271
has_bound_params = has_bound_params || rt. has_bound_params ;
275
272
has_vars = has_vars || rt. has_vars ;
276
273
has_locals = has_locals || rt. has_locals ;
277
- has_pointers = has_pointers || rt. has_pointers ;
278
274
}
279
275
280
276
fn derive_flags_mt ( & ctxt cx,
281
277
& mutable bool has_params ,
282
278
& mutable bool has_bound_params ,
283
279
& mutable bool has_vars ,
284
280
& mutable bool has_locals ,
285
- & mutable bool has_pointers ,
286
281
& mt m) {
287
282
derive_flags_t ( cx, has_params, has_bound_params,
288
- has_vars, has_locals, has_pointers , m. ty ) ;
283
+ has_vars, has_locals, m. ty ) ;
289
284
}
290
285
291
286
@@ -294,101 +289,89 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t {
294
289
& mutable bool has_bound_params ,
295
290
& mutable bool has_vars ,
296
291
& mutable bool has_locals ,
297
- & mutable bool has_pointers ,
298
292
& arg a) {
299
293
derive_flags_t ( cx, has_params, has_bound_params,
300
- has_vars, has_locals, has_pointers , a. ty ) ;
294
+ has_vars, has_locals, a. ty ) ;
301
295
}
302
296
303
297
fn derive_flags_sig ( & ctxt cx,
304
298
& mutable bool has_params ,
305
299
& mutable bool has_bound_params ,
306
300
& mutable bool has_vars ,
307
301
& mutable bool has_locals ,
308
- & mutable bool has_pointers ,
309
302
& vec[ arg] args ,
310
303
& t tt ) {
311
304
for ( arg a in args) {
312
305
derive_flags_arg ( cx, has_params, has_bound_params,
313
- has_vars, has_locals, has_pointers , a) ;
306
+ has_vars, has_locals, a) ;
314
307
}
315
308
derive_flags_t ( cx, has_params, has_bound_params,
316
- has_vars, has_locals, has_pointers , tt) ;
309
+ has_vars, has_locals, tt) ;
317
310
}
318
311
319
312
alt ( st) {
320
313
case ( ty_param ( _) ) {
321
314
has_params = true ;
322
- has_pointers = true ;
323
315
}
324
316
case ( ty_bound_param ( _) ) {
325
317
has_bound_params = true ;
326
- has_pointers = true ;
327
318
}
328
319
case ( ty_var ( _) ) { has_vars = true ; }
329
320
case ( ty_local ( _) ) { has_locals = true ; }
330
- case ( ty_tag ( ?did , ?tys) ) {
321
+ case ( ty_tag ( _ , ?tys) ) {
331
322
for ( t tt in tys) {
332
323
derive_flags_t ( cx, has_params, has_bound_params,
333
- has_vars, has_locals, has_pointers , tt) ;
324
+ has_vars, has_locals, tt) ;
334
325
}
335
326
}
336
327
case ( ty_box ( ?m) ) {
337
- has_pointers = true ;
338
328
derive_flags_mt ( cx, has_params, has_bound_params,
339
- has_vars, has_locals, has_pointers , m) ;
329
+ has_vars, has_locals, m) ;
340
330
}
341
331
342
332
case ( ty_vec ( ?m) ) {
343
- has_pointers = true ;
344
333
derive_flags_mt ( cx, has_params, has_bound_params,
345
- has_vars, has_locals, has_pointers , m) ;
334
+ has_vars, has_locals, m) ;
346
335
}
347
336
348
337
case ( ty_port ( ?tt) ) {
349
- has_pointers = true ;
350
338
derive_flags_t ( cx, has_params, has_bound_params,
351
- has_vars, has_locals, has_pointers , tt) ;
339
+ has_vars, has_locals, tt) ;
352
340
}
353
341
354
342
case ( ty_chan ( ?tt) ) {
355
- has_pointers = true ;
356
343
derive_flags_t ( cx, has_params, has_bound_params,
357
- has_vars, has_locals, has_pointers , tt) ;
344
+ has_vars, has_locals, tt) ;
358
345
}
359
346
360
347
case ( ty_tup ( ?mts) ) {
361
348
for ( mt m in mts) {
362
349
derive_flags_mt ( cx, has_params, has_bound_params,
363
- has_vars, has_locals, has_pointers , m) ;
350
+ has_vars, has_locals, m) ;
364
351
}
365
352
}
366
353
367
354
case ( ty_rec ( ?flds) ) {
368
355
for ( field f in flds) {
369
356
derive_flags_mt ( cx, has_params, has_bound_params,
370
- has_vars, has_locals, has_pointers , f. mt ) ;
357
+ has_vars, has_locals, f. mt ) ;
371
358
}
372
359
}
373
360
374
361
case ( ty_fn ( _, ?args, ?tt) ) {
375
- has_pointers = true ;
376
362
derive_flags_sig ( cx, has_params, has_bound_params,
377
- has_vars, has_locals, has_pointers , args, tt) ;
363
+ has_vars, has_locals, args, tt) ;
378
364
}
379
365
380
366
case ( ty_native_fn ( _, ?args, ?tt) ) {
381
- has_pointers = true ;
382
367
derive_flags_sig ( cx, has_params, has_bound_params,
383
- has_vars, has_locals, has_pointers , args, tt) ;
368
+ has_vars, has_locals, args, tt) ;
384
369
}
385
370
386
371
case ( ty_obj ( ?meths) ) {
387
- has_pointers = true ;
388
372
for ( method m in meths) {
389
373
derive_flags_sig ( cx, has_params, has_bound_params,
390
- has_vars, has_locals, has_pointers,
391
- m. inputs , m. output ) ;
374
+ has_vars, has_locals, m. inputs , m. output ) ;
392
375
}
393
376
}
394
377
case ( _) { }
@@ -398,8 +381,7 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t {
398
381
has_params = has_params,
399
382
has_bound_params = has_bound_params,
400
383
has_vars = has_vars,
401
- has_locals = has_locals,
402
- has_pointers = has_pointers) ;
384
+ has_locals = has_locals) ;
403
385
}
404
386
405
387
fn intern ( & ctxt cx, & sty st, & option:: t[ str] cname ) {
@@ -408,16 +390,7 @@ fn intern(&ctxt cx, &sty st, &option::t[str] cname) {
408
390
409
391
fn gen_ty_full ( & ctxt cx, & sty st, & option:: t[ str] cname ) -> t {
410
392
auto raw_type = mk_raw_ty ( cx, st, cname) ;
411
- auto t = interner:: intern[ raw_t] ( * cx. ts , raw_type) ;
412
-
413
- /*
414
- if (raw_type.has_pointers) {
415
- log_err "type has pointers: " + ty_to_str(cx, t);
416
- } else {
417
- log_err "type has no pointers: " + ty_to_str(cx, t);
418
- }
419
- */
420
- ret t;
393
+ ret interner:: intern[ raw_t] ( * cx. ts , raw_type) ;
421
394
}
422
395
423
396
// These are private constructors to this module. External users should always
@@ -936,7 +909,6 @@ fn sequence_element_type(&ctxt cx, &t ty) -> t {
936
909
fail;
937
910
}
938
911
939
-
940
912
fn type_is_tup_like( & ctxt cx, & t ty) -> bool {
941
913
alt ( struct ( cx, ty) ) {
942
914
case ( ty_box( _) ) { ret true; }
@@ -998,6 +970,49 @@ fn type_is_scalar(&ctxt cx, &t ty) -> bool {
998
970
}
999
971
1000
972
973
+ fn type_has_pointers( & ctxt cx, & t ty) -> bool {
974
+ alt ( struct ( cx, ty) ) {
975
+ // scalar types
976
+ case ( ty_nil) { ret false; }
977
+ case ( ty_bool) { ret false; }
978
+ case ( ty_int) { ret false; }
979
+ case ( ty_float) { ret false; }
980
+ case ( ty_uint) { ret false; }
981
+ case ( ty_machine( _) ) { ret false; }
982
+ case ( ty_char) { ret false; }
983
+ case ( ty_type) { ret false; }
984
+ case ( ty_native) { ret false; }
985
+
986
+ case ( ty_tup( ?elts) ) {
987
+ for ( mt m in elts) {
988
+ if ( type_has_pointers( cx, m. ty) ) { ret true; }
989
+ }
990
+ ret false;
991
+ }
992
+ case ( ty_rec( ?flds) ) {
993
+ for ( field f in flds) {
994
+ if ( type_has_pointers( cx, f. mt. ty) ) { ret true; }
995
+ }
996
+ ret false;
997
+ }
998
+
999
+ case ( ty_tag( ?did, ?tps) ) {
1000
+ auto variants = tag_variants( cx, did) ;
1001
+ for ( variant_info variant in variants) {
1002
+ auto tup_ty = mk_imm_tup( cx, variant. args) ;
1003
+ // Perform any type parameter substitutions.
1004
+ tup_ty = bind_params_in_type( cx, tup_ty) ;
1005
+ tup_ty = substitute_type_params( cx, tps, tup_ty) ;
1006
+ if ( type_has_pointers( cx, tup_ty) ) { ret true; }
1007
+ }
1008
+ ret false;
1009
+ }
1010
+ case ( _) { ret true; }
1011
+ }
1012
+ fail;
1013
+ }
1014
+
1015
+
1001
1016
// FIXME: should we just return true for native types in
1002
1017
// type_is_scalar?
1003
1018
fn type_is_native( & ctxt cx, & t ty) -> bool {
@@ -1616,15 +1631,6 @@ fn type_contains_bound_params(&ctxt cx, &t typ) -> bool {
1616
1631
ret interner:: get[ raw_t] ( * cx. ts , typ) . has_bound_params ;
1617
1632
}
1618
1633
1619
- fn type_contains_pointers ( & ctxt cx, & t typ ) -> bool {
1620
- // FIXME: this is currently incorrect, pending an improved
1621
- // version of the "contains pointers" derived property.
1622
- //
1623
- // ret interner::get[raw_t](*cx.ts, typ).has_pointers;
1624
-
1625
- ret ( !type_is_scalar ( cx, typ) ) ;
1626
- }
1627
-
1628
1634
// Type accessors for substructures of types
1629
1635
1630
1636
fn ty_fn_args ( & ctxt cx, & t fty ) -> vec[ arg ] {
@@ -2832,7 +2838,6 @@ fn def_has_ty_params(&ast::def def) -> bool {
2832
2838
2833
2839
type variant_info = rec ( vec[ ty:: t ] args , ty:: t ctor_ty , ast:: def_id id) ;
2834
2840
2835
- // Returns information about the variants in a tag.
2836
2841
fn tag_variants( & ctxt cx, & ast:: def_id id) -> vec[ variant_info ] {
2837
2842
if ( cx. sess . get_targ_crate_num ( ) != id. _0 ) {
2838
2843
ret creader:: get_tag_variants ( cx, id) ;
0 commit comments