Skip to content

Commit 786fbe0

Browse files
committed
---
yaml --- r: 3499 b: refs/heads/master c: fd0d1cb h: refs/heads/master i: 3497: ffcf18d 3495: 0c9e06d v: v3
1 parent d7fdbea commit 786fbe0

File tree

3 files changed

+66
-49
lines changed

3 files changed

+66
-49
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: b841152a4007d9251803bbbb7e4f9d7633f3c51d
2+
refs/heads/master: fd0d1cb7d8e56d2fc8f2e8128e534bee0dde7d1e

trunk/src/comp/middle/trans.rs

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,22 +1209,22 @@ fn simplify_type(&@crate_ctxt ccx, &ty::t typ) -> ty::t {
12091209
}
12101210
case (ty::ty_fn(_, _, _, _, _)) {
12111211
ret ty::mk_imm_tup(ccx.tcx,
1212-
[ty::mk_imm_box(ccx.tcx,
1213-
ty::mk_nil(ccx.tcx)),
1214-
ty::mk_imm_box(ccx.tcx,
1215-
ty::mk_nil(ccx.tcx))]);
1212+
~[ty::mk_imm_box(ccx.tcx,
1213+
ty::mk_nil(ccx.tcx)),
1214+
ty::mk_imm_box(ccx.tcx,
1215+
ty::mk_nil(ccx.tcx))]);
12161216
}
12171217
case (ty::ty_obj(_)) {
12181218
ret ty::mk_imm_tup(ccx.tcx,
1219-
[ty::mk_imm_box(ccx.tcx,
1220-
ty::mk_nil(ccx.tcx)),
1221-
ty::mk_imm_box(ccx.tcx,
1222-
ty::mk_nil(ccx.tcx))]);
1219+
~[ty::mk_imm_box(ccx.tcx,
1220+
ty::mk_nil(ccx.tcx)),
1221+
ty::mk_imm_box(ccx.tcx,
1222+
ty::mk_nil(ccx.tcx))]);
12231223
}
12241224
case (ty::ty_res(_, ?sub, ?tps)) {
12251225
auto sub1 = ty::substitute_type_params(ccx.tcx, tps, sub);
1226-
ret ty::mk_imm_tup(ccx.tcx, [ty::mk_int(ccx.tcx),
1227-
simplify_type(ccx, sub1)]);
1226+
ret ty::mk_imm_tup(ccx.tcx, ~[ty::mk_int(ccx.tcx),
1227+
simplify_type(ccx, sub1)]);
12281228
}
12291229
case (_) { ret typ; }
12301230
}
@@ -1256,7 +1256,11 @@ fn static_size_of_tag(&@crate_ctxt cx, &span sp, &ty::t t) -> uint {
12561256
auto max_size = 0u;
12571257
auto variants = ty::tag_variants(cx.tcx, tid);
12581258
for (ty::variant_info variant in variants) {
1259-
auto tup_ty = simplify_type(cx, ty::mk_imm_tup(cx.tcx, variant.args));
1259+
// TODO: Remove this vec->ivec conversion.
1260+
auto args = ~[];
1261+
for (ty::t typ in variant.args) { args += ~[typ]; }
1262+
1263+
auto tup_ty = simplify_type(cx, ty::mk_imm_tup(cx.tcx, args));
12601264
// Perform any type parameter substitutions.
12611265

12621266
tup_ty = ty::substitute_type_params(cx.tcx, subtys, tup_ty);
@@ -1469,7 +1473,11 @@ fn GEP_tup_like(&@block_ctxt cx, &ty::t t, ValueRef base, &vec[int] ixs) ->
14691473
// flattened the incoming structure.
14701474

14711475
auto s = split_type(cx.fcx.lcx.ccx, t, ixs, 0u);
1472-
auto prefix_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, s.prefix);
1476+
1477+
auto args = ~[];
1478+
for (ty::t typ in s.prefix) { args += ~[typ]; }
1479+
auto prefix_ty = ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, args);
1480+
14731481
auto bcx = cx;
14741482
auto sz = size_of(bcx, prefix_ty);
14751483
bcx = sz.bcx;
@@ -1498,11 +1506,11 @@ fn GEP_tag(@block_ctxt cx, ValueRef llblobptr, &ast::def_id tag_id,
14981506
auto elem_ty = ty::mk_nil(cx.fcx.lcx.ccx.tcx); // typestate infelicity
14991507

15001508
auto i = 0;
1501-
let vec[ty::t] true_arg_tys = [];
1509+
let ty::t[] true_arg_tys = ~[];
15021510
for (ty::t aty in arg_tys) {
15031511
auto arg_ty =
15041512
ty::substitute_type_params(cx.fcx.lcx.ccx.tcx, ty_substs, aty);
1505-
true_arg_tys += [arg_ty];
1513+
true_arg_tys += ~[arg_ty];
15061514
if (i == ix) { elem_ty = arg_ty; }
15071515
i += 1;
15081516
}
@@ -1559,7 +1567,7 @@ fn trans_malloc_boxed(&@block_ctxt cx, ty::t t) -> result {
15591567
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
15601568
// The mk_int here is the space being
15611569
// reserved for the refcount.
1562-
[ty::mk_int(cx.fcx.lcx.ccx.tcx), t]);
1570+
~[ty::mk_int(cx.fcx.lcx.ccx.tcx), t]);
15631571
auto box_ptr = ty::mk_imm_box(cx.fcx.lcx.ccx.tcx, t);
15641572
auto sz = size_of(cx, boxed_body);
15651573
// Grab the TypeRef type of box_ptr, because that's what trans_raw_malloc
@@ -2111,9 +2119,8 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
21112119
fn trans_res_drop(@block_ctxt cx, ValueRef rs, &ast::def_id did,
21122120
ty::t inner_t, &vec[ty::t] tps) -> result {
21132121
auto ccx = cx.fcx.lcx.ccx;
2114-
21152122
auto inner_t_s = ty::substitute_type_params(ccx.tcx, tps, inner_t);
2116-
auto tup_ty = ty::mk_imm_tup(ccx.tcx, [ty::mk_int(ccx.tcx), inner_t_s]);
2123+
auto tup_ty = ty::mk_imm_tup(ccx.tcx, ~[ty::mk_int(ccx.tcx), inner_t_s]);
21172124
auto drop_cx = new_sub_block_ctxt(cx, "drop res");
21182125
auto next_cx = new_sub_block_ctxt(cx, "next");
21192126

@@ -5343,17 +5350,21 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
53435350
auto arg = trans_expr(bcx, e);
53445351
bcx = arg.bcx;
53455352
vec::push[ValueRef](bound_vals, arg.val);
5346-
vec::push[ty::t](bound_tys,
5347-
ty::expr_ty(cx.fcx.lcx.ccx.tcx, e));
5353+
bound_tys += [ty::expr_ty(cx.fcx.lcx.ccx.tcx, e)];
53485354
}
53495355

53505356
// Synthesize a closure type.
53515357

53525358
// First, synthesize a tuple type containing the types of all the
53535359
// bound expressions.
53545360
// bindings_ty = [bound_ty1, bound_ty2, ...]
5361+
5362+
// TODO: Remove this vec->ivec conversion.
5363+
auto bound_tys_ivec = ~[];
5364+
for (ty::t typ in bound_tys) { bound_tys_ivec += ~[typ]; }
5365+
53555366
let ty::t bindings_ty =
5356-
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, bound_tys);
5367+
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, bound_tys_ivec);
53575368

53585369
// NB: keep this in sync with T_closure_ptr; we're making
53595370
// a ty::t structure that has the same "shape" as the LLVM type
@@ -5362,18 +5373,18 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
53625373
// Make a vector that contains ty_param_count copies of tydesc_ty.
53635374
// (We'll need room for that many tydescs in the closure.)
53645375
let ty::t tydesc_ty = ty::mk_type(cx.fcx.lcx.ccx.tcx);
5365-
let vec[ty::t] captured_tys =
5366-
vec::init_elt[ty::t](tydesc_ty, ty_param_count);
5376+
let ty::t[] captured_tys =
5377+
std::ivec::init_elt[ty::t](tydesc_ty, ty_param_count);
53675378

53685379
// Get all the types we've got (some of which we synthesized
53695380
// ourselves) into a vector. The whole things ends up looking
53705381
// like:
53715382

53725383
// closure_tys = [tydesc_ty, outgoing_fty, [bound_ty1, bound_ty2,
53735384
// ...], [tydesc_ty, tydesc_ty, ...]]
5374-
let vec[ty::t] closure_tys =
5375-
[tydesc_ty, outgoing_fty, bindings_ty,
5376-
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, captured_tys)];
5385+
let ty::t[] closure_tys =
5386+
~[tydesc_ty, outgoing_fty, bindings_ty,
5387+
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx, captured_tys)];
53775388

53785389
// Finally, synthesize a type for that whole vector.
53795390
let ty::t closure_ty =
@@ -5745,8 +5756,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args, ast::node_id id) ->
57455756
auto body = bcx.build.GEP(vec_val, [C_int(0), C_int(abi::vec_elt_data)]);
57465757
auto pseudo_tup_ty =
57475758
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
5748-
vec::init_elt[ty::t](unit_ty,
5749-
vec::len[@ast::expr](args)));
5759+
std::ivec::init_elt[ty::t](unit_ty, vec::len(args)));
57505760
let int i = 0;
57515761
for (@ast::expr e in args) {
57525762
auto src_res = trans_expr(bcx, e);
@@ -6524,7 +6534,7 @@ fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
65246534
// Translate the arguments, remembering their types and where the values
65256535
// ended up.
65266536

6527-
let vec[ty::t] arg_tys = [];
6537+
let ty::t[] arg_tys = ~[];
65286538
let vec[ValueRef] arg_vals = [];
65296539
for (@ast::expr e in args) {
65306540
auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, e);
@@ -6535,7 +6545,7 @@ fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
65356545
bcx = arg.bcx;
65366546

65376547
vec::push[ValueRef](arg_vals, arg.val);
6538-
vec::push[ty::t](arg_tys, e_ty);
6548+
arg_tys += ~[e_ty];
65396549
}
65406550
// Make the tuple.
65416551

@@ -6785,13 +6795,13 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
67856795
// the outer object?
67866796
let vec[ast::anon_obj_field] additional_fields = [];
67876797
let vec[result] additional_field_vals = [];
6788-
let vec[ty::t] additional_field_tys = [];
6798+
let ty::t[] additional_field_tys = ~[];
67896799
alt (anon_obj.fields) {
67906800
case (none) { }
67916801
case (some(?fields)) {
67926802
additional_fields = fields;
67936803
for (ast::anon_obj_field f in fields) {
6794-
additional_field_tys += [node_id_type(ccx, f.id)];
6804+
additional_field_tys += ~[node_id_type(ccx, f.id)];
67956805
additional_field_vals += [trans_expr(bcx, f.expr)];
67966806
}
67976807
}
@@ -6895,18 +6905,18 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
68956905
// actually supporting typarams for anon objs yet, but let's
68966906
// create space for them in case we ever want them.
68976907
let ty::t tydesc_ty = ty::mk_type(ccx.tcx);
6898-
let vec[ty::t] tps = [];
6908+
let ty::t[] tps = ~[];
68996909
for (ast::ty_param tp in ty_params) {
6900-
vec::push[ty::t](tps, tydesc_ty);
6910+
tps += ~[tydesc_ty];
69016911
}
69026912
// Synthesize a tuple type for typarams: [typaram, ...]
69036913
let ty::t typarams_ty = ty::mk_imm_tup(ccx.tcx, tps);
69046914

69056915
// Tuple type for body:
69066916
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
69076917
let ty::t body_ty =
6908-
ty::mk_imm_tup(ccx.tcx, [tydesc_ty, typarams_ty,
6909-
fields_ty, with_obj_ty]);
6918+
ty::mk_imm_tup(ccx.tcx, ~[tydesc_ty, typarams_ty,
6919+
fields_ty, with_obj_ty]);
69106920

69116921
// Hand this type we've synthesized off to trans_malloc_boxed, which
69126922
// allocates a box, including space for a refcount.
@@ -7498,9 +7508,9 @@ fn arg_tys_of_fn(&@crate_ctxt ccx,ast::node_id id) -> vec[ty::arg] {
74987508

74997509
fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, val_self_pair llself) {
75007510
auto bcx = llstaticallocas_block_ctxt(fcx);
7501-
let vec[ty::t] field_tys = [];
7511+
let ty::t[] field_tys = ~[];
75027512
for (ast::obj_field f in bcx.fcx.lcx.obj_fields) {
7503-
field_tys += [node_id_type(bcx.fcx.lcx.ccx, f.id)];
7513+
field_tys += ~[node_id_type(bcx.fcx.lcx.ccx, f.id)];
75047514
}
75057515
// Synthesize a tuple type for the fields so that GEP_tup_like() can work
75067516
// its magic.
@@ -7761,24 +7771,22 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
77617771
} else {
77627772
// Otherwise, we have to synthesize a big structural type for the
77637773
// object body.
7764-
let vec[ty::t] obj_fields = [];
7765-
for (ty::arg a in arg_tys) { vec::push[ty::t](obj_fields, a.ty); }
7774+
let ty::t[] obj_fields = ~[];
7775+
for (ty::arg a in arg_tys) { obj_fields += ~[a.ty]; }
77667776

77677777
// Tuple type for fields: [field, ...]
77687778
let ty::t fields_ty = ty::mk_imm_tup(ccx.tcx, obj_fields);
77697779

77707780
auto tydesc_ty = ty::mk_type(ccx.tcx);
7771-
let vec[ty::t] tps = [];
7772-
for (ast::ty_param tp in ty_params) {
7773-
vec::push[ty::t](tps, tydesc_ty);
7774-
}
7781+
let ty::t[] tps = ~[];
7782+
for (ast::ty_param tp in ty_params) { tps += ~[tydesc_ty]; }
77757783

77767784
// Tuple type for typarams: [typaram, ...]
77777785
let ty::t typarams_ty = ty::mk_imm_tup(ccx.tcx, tps);
77787786

77797787
// Tuple type for body: [tydesc_ty, [typaram, ...], [field, ...]]
77807788
let ty::t body_ty =
7781-
ty::mk_imm_tup(ccx.tcx, [tydesc_ty, typarams_ty, fields_ty]);
7789+
ty::mk_imm_tup(ccx.tcx, ~[tydesc_ty, typarams_ty, fields_ty]);
77827790

77837791
// Hand this type we've synthesized off to trans_malloc_boxed, which
77847792
// allocates a box, including space for a refcount.
@@ -7879,7 +7887,7 @@ fn trans_res_ctor(@local_ctxt cx, &span sp, &ast::_fn dtor,
78797887
auto bcx = new_top_block_ctxt(fcx);
78807888
auto lltop = bcx.llbb;
78817889
auto arg_t = arg_tys_of_fn(cx.ccx, ctor_id).(0).ty;
7882-
auto tup_t = ty::mk_imm_tup(cx.ccx.tcx, [ty::mk_int(cx.ccx.tcx), arg_t]);
7890+
auto tup_t = ty::mk_imm_tup(cx.ccx.tcx, ~[ty::mk_int(cx.ccx.tcx), arg_t]);
78837891
auto arg = load_if_immediate
78847892
(bcx, fcx.llargs.get(dtor.decl.inputs.(0).id), arg_t);
78857893

trunk/src/comp/middle/ty.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ fn mk_task(&ctxt cx) -> t { ret gen_ty(cx, ty_task); }
587587

588588
fn mk_tup(&ctxt cx, &mt[] tms) -> t { ret gen_ty(cx, ty_tup(tms)); }
589589

590-
fn mk_imm_tup(&ctxt cx, &vec[t] tys) -> t {
590+
fn mk_imm_tup(&ctxt cx, &t[] tys) -> t {
591591
// TODO: map
592592

593593
let ty::mt[] mts = ~[];
@@ -1055,7 +1055,11 @@ fn type_has_pointers(&ctxt cx, &t ty) -> bool {
10551055
case (ty_tag(?did, ?tps)) {
10561056
auto variants = tag_variants(cx, did);
10571057
for (variant_info variant in variants) {
1058-
auto tup_ty = mk_imm_tup(cx, variant.args);
1058+
// TODO: Remove this vec->ivec conversion.
1059+
auto args = ~[];
1060+
for (ty::t arg in variant.args) { args += ~[arg]; }
1061+
1062+
auto tup_ty = mk_imm_tup(cx, args);
10591063
// Perform any type parameter substitutions.
10601064

10611065
tup_ty = substitute_type_params(cx, tps, tup_ty);
@@ -1229,7 +1233,12 @@ fn type_owns_heap_mem(&ctxt cx, &t ty) -> bool {
12291233
case (ty_tag(?did, ?tps)) {
12301234
auto variants = tag_variants(cx, did);
12311235
for (variant_info variant in variants) {
1232-
auto tup_ty = mk_imm_tup(cx, variant.args);
1236+
// TODO: Remove this vec->ivec conversion.
1237+
auto args = ~[];
1238+
for (ty::t arg in variant.args) { args += ~[arg]; }
1239+
1240+
auto tup_ty = mk_imm_tup(cx, args);
1241+
12331242
// Perform any type parameter substitutions.
12341243
tup_ty = substitute_type_params(cx, tps, tup_ty);
12351244
if (type_owns_heap_mem(cx, tup_ty)) { result = true; }

0 commit comments

Comments
 (0)