Skip to content

Commit b7eedc7

Browse files
committed
---
yaml --- r: 2659 b: refs/heads/master c: 494c0c3 h: refs/heads/master i: 2657: 5375962 2655: c13f008 v: v3
1 parent c54f3cb commit b7eedc7

File tree

3 files changed

+65
-60
lines changed

3 files changed

+65
-60
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 5d09e12e15b8b37739cb2935ae3e8e13c693bd8f
2+
refs/heads/master: 494c0c3b61bdcd3389789495fc91c74d6fcf4a10

trunk/src/comp/middle/trans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
22142214
}
22152215

22162216
case (_) {
2217-
if (ty::type_contains_pointers(cx.fcx.lcx.ccx.tcx, t) &&
2217+
if (ty::type_has_pointers(cx.fcx.lcx.ccx.tcx, t) &&
22182218
ty::type_is_structural(cx.fcx.lcx.ccx.tcx, t)) {
22192219
rslt = iter_structural_ty(cx, v0, t,
22202220
bind drop_ty(_, _, _));
@@ -3112,7 +3112,7 @@ fn drop_ty(&@block_ctxt cx,
31123112
ValueRef v,
31133113
ty::t t) -> result {
31143114

3115-
if (ty::type_contains_pointers(cx.fcx.lcx.ccx.tcx, t)) {
3115+
if (ty::type_has_pointers(cx.fcx.lcx.ccx.tcx, t)) {
31163116
ret call_tydesc_glue(cx, v, t, false, abi::tydesc_field_drop_glue);
31173117
}
31183118
ret res(cx, C_nil());
@@ -3122,7 +3122,7 @@ fn free_ty(&@block_ctxt cx,
31223122
ValueRef v,
31233123
ty::t t) -> result {
31243124

3125-
if (ty::type_contains_pointers(cx.fcx.lcx.ccx.tcx, t)) {
3125+
if (ty::type_has_pointers(cx.fcx.lcx.ccx.tcx, t)) {
31263126
ret call_tydesc_glue(cx, v, t, false, abi::tydesc_field_free_glue);
31273127
}
31283128
ret res(cx, C_nil());

trunk/src/comp/middle/ty.rs

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ type raw_t = rec(sty struct,
8989
bool has_params,
9090
bool has_bound_params,
9191
bool has_vars,
92-
bool has_locals,
93-
bool has_pointers);
92+
bool has_locals);
9493

9594
type t = uint;
9695

@@ -260,32 +259,28 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t {
260259
let bool has_bound_params = false;
261260
let bool has_vars = false;
262261
let bool has_locals = false;
263-
let bool has_pointers = false;
264262

265263
fn derive_flags_t(&ctxt cx,
266264
&mutable bool has_params,
267265
&mutable bool has_bound_params,
268266
&mutable bool has_vars,
269267
&mutable bool has_locals,
270-
&mutable bool has_pointers,
271268
&t tt) {
272269
auto rt = interner::get[raw_t](*cx.ts, tt);
273270
has_params = has_params || rt.has_params;
274271
has_bound_params = has_bound_params || rt.has_bound_params;
275272
has_vars = has_vars || rt.has_vars;
276273
has_locals = has_locals || rt.has_locals;
277-
has_pointers = has_pointers || rt.has_pointers;
278274
}
279275

280276
fn derive_flags_mt(&ctxt cx,
281277
&mutable bool has_params,
282278
&mutable bool has_bound_params,
283279
&mutable bool has_vars,
284280
&mutable bool has_locals,
285-
&mutable bool has_pointers,
286281
&mt m) {
287282
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);
289284
}
290285

291286

@@ -294,101 +289,89 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t {
294289
&mutable bool has_bound_params,
295290
&mutable bool has_vars,
296291
&mutable bool has_locals,
297-
&mutable bool has_pointers,
298292
&arg a) {
299293
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);
301295
}
302296

303297
fn derive_flags_sig(&ctxt cx,
304298
&mutable bool has_params,
305299
&mutable bool has_bound_params,
306300
&mutable bool has_vars,
307301
&mutable bool has_locals,
308-
&mutable bool has_pointers,
309302
&vec[arg] args,
310303
&t tt) {
311304
for (arg a in args) {
312305
derive_flags_arg(cx, has_params, has_bound_params,
313-
has_vars, has_locals, has_pointers, a);
306+
has_vars, has_locals, a);
314307
}
315308
derive_flags_t(cx, has_params, has_bound_params,
316-
has_vars, has_locals, has_pointers, tt);
309+
has_vars, has_locals, tt);
317310
}
318311

319312
alt (st) {
320313
case (ty_param(_)) {
321314
has_params = true;
322-
has_pointers = true;
323315
}
324316
case (ty_bound_param(_)) {
325317
has_bound_params = true;
326-
has_pointers = true;
327318
}
328319
case (ty_var(_)) { has_vars = true; }
329320
case (ty_local(_)) { has_locals = true; }
330-
case (ty_tag(?did, ?tys)) {
321+
case (ty_tag(_, ?tys)) {
331322
for (t tt in tys) {
332323
derive_flags_t(cx, has_params, has_bound_params,
333-
has_vars, has_locals, has_pointers, tt);
324+
has_vars, has_locals, tt);
334325
}
335326
}
336327
case (ty_box(?m)) {
337-
has_pointers = true;
338328
derive_flags_mt(cx, has_params, has_bound_params,
339-
has_vars, has_locals, has_pointers, m);
329+
has_vars, has_locals, m);
340330
}
341331

342332
case (ty_vec(?m)) {
343-
has_pointers = true;
344333
derive_flags_mt(cx, has_params, has_bound_params,
345-
has_vars, has_locals, has_pointers, m);
334+
has_vars, has_locals, m);
346335
}
347336

348337
case (ty_port(?tt)) {
349-
has_pointers = true;
350338
derive_flags_t(cx, has_params, has_bound_params,
351-
has_vars, has_locals, has_pointers, tt);
339+
has_vars, has_locals, tt);
352340
}
353341

354342
case (ty_chan(?tt)) {
355-
has_pointers = true;
356343
derive_flags_t(cx, has_params, has_bound_params,
357-
has_vars, has_locals, has_pointers, tt);
344+
has_vars, has_locals, tt);
358345
}
359346

360347
case (ty_tup(?mts)) {
361348
for (mt m in mts) {
362349
derive_flags_mt(cx, has_params, has_bound_params,
363-
has_vars, has_locals, has_pointers, m);
350+
has_vars, has_locals, m);
364351
}
365352
}
366353

367354
case (ty_rec(?flds)) {
368355
for (field f in flds) {
369356
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);
371358
}
372359
}
373360

374361
case (ty_fn(_, ?args, ?tt)) {
375-
has_pointers = true;
376362
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);
378364
}
379365

380366
case (ty_native_fn(_, ?args, ?tt)) {
381-
has_pointers = true;
382367
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);
384369
}
385370

386371
case (ty_obj(?meths)) {
387-
has_pointers = true;
388372
for (method m in meths) {
389373
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);
392375
}
393376
}
394377
case (_) { }
@@ -398,8 +381,7 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t {
398381
has_params = has_params,
399382
has_bound_params = has_bound_params,
400383
has_vars = has_vars,
401-
has_locals = has_locals,
402-
has_pointers = has_pointers);
384+
has_locals = has_locals);
403385
}
404386

405387
fn intern(&ctxt cx, &sty st, &option::t[str] cname) {
@@ -408,16 +390,7 @@ fn intern(&ctxt cx, &sty st, &option::t[str] cname) {
408390

409391
fn gen_ty_full(&ctxt cx, &sty st, &option::t[str] cname) -> t {
410392
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);
421394
}
422395

423396
// These are private constructors to this module. External users should always
@@ -936,7 +909,6 @@ fn sequence_element_type(&ctxt cx, &t ty) -> t {
936909
fail;
937910
}
938911

939-
940912
fn type_is_tup_like(&ctxt cx, &t ty) -> bool {
941913
alt (struct(cx, ty)) {
942914
case (ty_box(_)) { ret true; }
@@ -998,6 +970,49 @@ fn type_is_scalar(&ctxt cx, &t ty) -> bool {
998970
}
999971

1000972

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+
10011016
// FIXME: should we just return true for native types in
10021017
// type_is_scalar?
10031018
fn type_is_native(&ctxt cx, &t ty) -> bool {
@@ -1616,15 +1631,6 @@ fn type_contains_bound_params(&ctxt cx, &t typ) -> bool {
16161631
ret interner::get[raw_t](*cx.ts, typ).has_bound_params;
16171632
}
16181633

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-
16281634
// Type accessors for substructures of types
16291635

16301636
fn ty_fn_args(&ctxt cx, &t fty) -> vec[arg] {
@@ -2832,7 +2838,6 @@ fn def_has_ty_params(&ast::def def) -> bool {
28322838

28332839
type variant_info = rec(vec[ty::t] args, ty::t ctor_ty, ast::def_id id);
28342840

2835-
// Returns information about the variants in a tag.
28362841
fn tag_variants(&ctxt cx, &ast::def_id id) -> vec[variant_info] {
28372842
if (cx.sess.get_targ_crate_num() != id._0) {
28382843
ret creader::get_tag_variants(cx, id);

0 commit comments

Comments
 (0)