Skip to content

Commit 108cc4e

Browse files
committed
rustc: Change function argument types to interior vectors
1 parent 50b1953 commit 108cc4e

File tree

7 files changed

+97
-75
lines changed

7 files changed

+97
-75
lines changed

src/comp/metadata/tydecode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,9 @@ fn parse_hex(@pstate st) -> uint {
334334
}
335335

336336
fn parse_ty_fn(@pstate st, str_def sd) ->
337-
tup(vec[ty::arg], ty::t, ast::controlflow, vec[@ty::constr_def]) {
337+
tup(ty::arg[], ty::t, ast::controlflow, vec[@ty::constr_def]) {
338338
assert (next(st) as char == '[');
339-
let vec[ty::arg] inputs = [];
339+
let ty::arg[] inputs = ~[];
340340
while (peek(st) as char != ']') {
341341
auto mode = ty::mo_val;
342342
if (peek(st) as char == '&') {
@@ -347,7 +347,7 @@ fn parse_ty_fn(@pstate st, str_def sd) ->
347347
st.pos += 1u;
348348
}
349349
}
350-
inputs += [rec(mode=mode, ty=parse_ty(st, sd))];
350+
inputs += ~[rec(mode=mode, ty=parse_ty(st, sd))];
351351
}
352352
st.pos += 1u; // eat the ']'
353353
auto cs = parse_constrs(st, sd);

src/comp/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn enc_proto(&io::writer w, proto proto) {
199199
case (proto_fn) { w.write_char('F'); }
200200
}
201201
}
202-
fn enc_ty_fn(&io::writer w, &@ctxt cx, &vec[ty::arg] args, &ty::t out,
202+
fn enc_ty_fn(&io::writer w, &@ctxt cx, &ty::arg[] args, &ty::t out,
203203
&controlflow cf, &vec[@ty::constr_def] constrs) {
204204
w.write_char('[');
205205
for (ty::arg arg in args) {

src/comp/middle/alias.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ fn def_is_local(&ast::def d, bool objfields_count) -> bool {
662662
};
663663
}
664664

665-
fn fty_args(&ctx cx, ty::t fty) -> vec[ty::arg] {
665+
fn fty_args(&ctx cx, ty::t fty) -> ty::arg[] {
666666
ret alt (ty::struct(*cx.tcx, fty)) {
667667
case (ty::ty_fn(_, ?args, _, _, _)) { args }
668668
case (ty::ty_native_fn(_, ?args, _)) { args }

src/comp/middle/trans.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn T_glue_fn(&type_names tn) -> TypeRef {
472472

473473
fn T_dtor(&@crate_ctxt ccx, &span sp, TypeRef llself_ty) -> TypeRef {
474474
ret type_of_fn_full(ccx, sp, ast::proto_fn, some[TypeRef](llself_ty),
475-
vec::empty[ty::arg](), ty::mk_nil(ccx.tcx), 0u);
475+
~[], ty::mk_nil(ccx.tcx), 0u);
476476
}
477477

478478
fn T_cmp_glue_fn(&type_names tn) -> TypeRef {
@@ -681,7 +681,7 @@ fn type_of(&@crate_ctxt cx, &span sp, &ty::t t) -> TypeRef {
681681
ret type_of_inner(cx, sp, t);
682682
}
683683

684-
fn type_of_explicit_args(&@crate_ctxt cx, &span sp, &vec[ty::arg] inputs) ->
684+
fn type_of_explicit_args(&@crate_ctxt cx, &span sp, &ty::arg[] inputs) ->
685685
vec[TypeRef] {
686686
let vec[TypeRef] atys = [];
687687
for (ty::arg arg in inputs) {
@@ -710,7 +710,7 @@ fn type_of_explicit_args(&@crate_ctxt cx, &span sp, &vec[ty::arg] inputs) ->
710710
// - new_fn_ctxt
711711
// - trans_args
712712
fn type_of_fn_full(&@crate_ctxt cx, &span sp, ast::proto proto,
713-
&option::t[TypeRef] obj_self, &vec[ty::arg] inputs,
713+
&option::t[TypeRef] obj_self, &ty::arg[] inputs,
714714
&ty::t output, uint ty_param_count) -> TypeRef {
715715
let vec[TypeRef] atys = [];
716716

@@ -743,7 +743,7 @@ fn type_of_fn_full(&@crate_ctxt cx, &span sp, ast::proto proto,
743743
atys +=
744744
[T_fn_pair(cx.tn,
745745
type_of_fn_full(cx, sp, ast::proto_fn, none[TypeRef],
746-
[rec(mode=ty::mo_alias(false),
746+
~[rec(mode=ty::mo_alias(false),
747747
ty=output)], ty::mk_nil(cx.tcx),
748748
0u))];
749749
}
@@ -754,14 +754,14 @@ fn type_of_fn_full(&@crate_ctxt cx, &span sp, ast::proto proto,
754754
}
755755

756756
fn type_of_fn(&@crate_ctxt cx, &span sp, ast::proto proto,
757-
&vec[ty::arg] inputs, &ty::t output, uint ty_param_count) ->
757+
&ty::arg[] inputs, &ty::t output, uint ty_param_count) ->
758758
TypeRef {
759759
ret type_of_fn_full(cx, sp, proto, none[TypeRef], inputs, output,
760760
ty_param_count);
761761
}
762762

763763
fn type_of_native_fn(&@crate_ctxt cx, &span sp, ast::native_abi abi,
764-
&vec[ty::arg] inputs, &ty::t output, uint ty_param_count)
764+
&ty::arg[] inputs, &ty::t output, uint ty_param_count)
765765
-> TypeRef {
766766
let vec[TypeRef] atys = [];
767767
if (abi == ast::native_abi_rust) {
@@ -2137,7 +2137,7 @@ fn trans_res_drop(@block_ctxt cx, ValueRef rs, &ast::def_id did,
21372137
} else {
21382138
auto params = decoder::get_type_param_count(ccx.tcx, did);
21392139
auto f_t = type_of_fn(ccx, cx.sp, ast::proto_fn,
2140-
[rec(mode=ty::mo_alias(false), ty=inner_t)],
2140+
~[rec(mode=ty::mo_alias(false), ty=inner_t)],
21412141
ty::mk_nil(ccx.tcx), params);
21422142
get_extern_const(ccx.externs, ccx.llmod,
21432143
decoder::get_symbol(ccx.sess, did),
@@ -4526,7 +4526,7 @@ fn trans_for_each(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
45264526
// and pass it in as a first class fn-arg to the iterator.
45274527
auto iter_body_llty =
45284528
type_of_fn_full(lcx.ccx, cx.sp, ast::proto_fn, none[TypeRef],
4529-
[rec(mode=ty::mo_alias(false), ty=decl_ty)],
4529+
~[rec(mode=ty::mo_alias(false), ty=decl_ty)],
45304530
ty::mk_nil(lcx.ccx.tcx), 0u);
45314531
let ValueRef lliterbody =
45324532
decl_internal_fastcall_fn(lcx.ccx.llmod, s, iter_body_llty);
@@ -5551,7 +5551,7 @@ fn trans_args(&@block_ctxt cx, ValueRef llenv, &option::t[ValueRef] llobj,
55515551
&option::t[generic_info] gen, &option::t[ValueRef] lliterbody,
55525552
&vec[@ast::expr] es, &ty::t fn_ty) ->
55535553
tup(@block_ctxt, vec[ValueRef], ValueRef) {
5554-
let vec[ty::arg] args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
5554+
let ty::arg[] args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
55555555
let vec[ValueRef] llargs = [];
55565556
let vec[ValueRef] lltydescs = [];
55575557
let @block_ctxt bcx = cx;
@@ -6342,7 +6342,7 @@ fn trans_put(&@block_ctxt cx, &option::t[@ast::expr] e) -> result {
63426342
auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, x);
63436343
auto arg = rec(mode=ty::mo_alias(false), ty=e_ty);
63446344
auto arg_tys =
6345-
type_of_explicit_args(cx.fcx.lcx.ccx, x.span, [arg]);
6345+
type_of_explicit_args(cx.fcx.lcx.ccx, x.span, ~[arg]);
63466346
auto r = trans_arg_expr(bcx, arg, arg_tys.(0), x);
63476347
bcx = r.bcx;
63486348
llargs += [r.val];
@@ -6578,7 +6578,7 @@ fn mk_spawn_wrapper(&@block_ctxt cx, &@ast::expr func, &ty::t args_ty) ->
65786578
auto llmod = cx.fcx.lcx.ccx.llmod;
65796579
let TypeRef wrapper_fn_type =
65806580
type_of_fn(cx.fcx.lcx.ccx, cx.sp, ast::proto_fn,
6581-
[rec(mode=ty::mo_alias(false), ty=args_ty)], ty::idx_nil,
6581+
~[rec(mode=ty::mo_alias(false), ty=args_ty)], ty::idx_nil,
65826582
0u);
65836583
// TODO: construct a name based on tname
65846584

@@ -7450,7 +7450,7 @@ fn copy_any_self_to_alloca(@fn_ctxt fcx, option::t[ty_self_pair] ty_self) {
74507450
}
74517451

74527452
fn copy_args_to_allocas(@fn_ctxt fcx, vec[ast::arg] args,
7453-
vec[ty::arg] arg_tys) {
7453+
&ty::arg[] arg_tys) {
74547454
auto bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
74557455
let uint arg_n = 0u;
74567456
for (ast::arg aarg in args) {
@@ -7468,7 +7468,7 @@ fn copy_args_to_allocas(@fn_ctxt fcx, vec[ast::arg] args,
74687468
}
74697469

74707470
fn add_cleanups_for_args(&@block_ctxt bcx, vec[ast::arg] args,
7471-
vec[ty::arg] arg_tys) {
7471+
&ty::arg[] arg_tys) {
74727472
let uint arg_n = 0u;
74737473
for (ast::arg aarg in args) {
74747474
if (aarg.mode == ast::val) {
@@ -7485,7 +7485,7 @@ fn is_terminated(&@block_ctxt cx) -> bool {
74857485
ret llvm::LLVMIsATerminatorInst(inst) as int != 0;
74867486
}
74877487

7488-
fn arg_tys_of_fn(&@crate_ctxt ccx,ast::node_id id) -> vec[ty::arg] {
7488+
fn arg_tys_of_fn(&@crate_ctxt ccx,ast::node_id id) -> ty::arg[] {
74897489
alt (ty::struct(ccx.tcx, ty::node_id_to_type(ccx.tcx, id))) {
74907490
case (ty::ty_fn(_, ?arg_tys, _, _, _)) { ret arg_tys; }
74917491
}
@@ -7699,7 +7699,7 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
76997699
create_llargs_for_fn_args(fcx, ast::proto_fn, none[ty_self_pair],
77007700
ty::ret_ty_of_fn(ccx.tcx, ctor_id),
77017701
fn_args, ty_params);
7702-
let vec[ty::arg] arg_tys = arg_tys_of_fn(ccx, ctor_id);
7702+
let ty::arg[] arg_tys = arg_tys_of_fn(ccx, ctor_id);
77037703
copy_args_to_allocas(fcx, fn_args, arg_tys);
77047704

77057705
// Create the first block context in the function and keep a handle on it
@@ -7747,7 +7747,7 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
77477747
// a dtor, since otherwise they are never dropped, and the dtor never
77487748
// runs.
77497749
if (vec::len[ast::ty_param](ty_params) == 0u &&
7750-
vec::len[ty::arg](arg_tys) == 0u) {
7750+
std::ivec::len[ty::arg](arg_tys) == 0u) {
77517751
// If the object we're translating has no fields or type parameters,
77527752
// there's not much to do.
77537753

src/comp/middle/ty.rs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ type field = rec(ast::ident ident, mt mt);
192192
type method =
193193
rec(ast::proto proto,
194194
ast::ident ident,
195-
vec[arg] inputs,
195+
arg[] inputs,
196196
t output,
197197
controlflow cf,
198198
vec[@constr_def] constrs);
@@ -266,8 +266,8 @@ tag sty {
266266
ty_task;
267267
ty_tup(mt[]);
268268
ty_rec(field[]);
269-
ty_fn(ast::proto, vec[arg], t, controlflow, vec[@constr_def]);
270-
ty_native_fn(ast::native_abi, vec[arg], t);
269+
ty_fn(ast::proto, arg[], t, controlflow, vec[@constr_def]);
270+
ty_native_fn(ast::native_abi, arg[], t);
271271
ty_obj(vec[method]);
272272
ty_res(def_id, t, vec[t]);
273273
ty_var(int); // type variable
@@ -445,7 +445,7 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t {
445445
derive_flags_t(cx, has_params, has_vars, a.ty);
446446
}
447447
fn derive_flags_sig(&ctxt cx, &mutable bool has_params,
448-
&mutable bool has_vars, &vec[arg] args, &t tt) {
448+
&mutable bool has_vars, &arg[] args, &t tt) {
449449
for (arg a in args) { derive_flags_arg(cx, has_params, has_vars, a); }
450450
derive_flags_t(cx, has_params, has_vars, tt);
451451
}
@@ -597,12 +597,12 @@ fn mk_imm_tup(&ctxt cx, &t[] tys) -> t {
597597

598598
fn mk_rec(&ctxt cx, &field[] fs) -> t { ret gen_ty(cx, ty_rec(fs)); }
599599

600-
fn mk_fn(&ctxt cx, &ast::proto proto, &vec[arg] args, &t ty, &controlflow cf,
600+
fn mk_fn(&ctxt cx, &ast::proto proto, &arg[] args, &t ty, &controlflow cf,
601601
&vec[@constr_def] constrs) -> t {
602602
ret gen_ty(cx, ty_fn(proto, args, ty, cf, constrs));
603603
}
604604

605-
fn mk_native_fn(&ctxt cx, &ast::native_abi abi, &vec[arg] args, &t ty) -> t {
605+
fn mk_native_fn(&ctxt cx, &ast::native_abi abi, &arg[] args, &t ty) -> t {
606606
ret gen_ty(cx, ty_native_fn(abi, args, ty));
607607
}
608608

@@ -792,21 +792,21 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
792792
ty = copy_cname(cx, mk_rec(cx, new_fields), ty);
793793
}
794794
case (ty_fn(?proto, ?args, ?ret_ty, ?cf, ?constrs)) {
795-
let vec[arg] new_args = [];
795+
let arg[] new_args = ~[];
796796
for (arg a in args) {
797797
auto new_ty = fold_ty(cx, fld, a.ty);
798-
new_args += [rec(mode=a.mode, ty=new_ty)];
798+
new_args += ~[rec(mode=a.mode, ty=new_ty)];
799799
}
800800
ty =
801801
copy_cname(cx,
802802
mk_fn(cx, proto, new_args,
803803
fold_ty(cx, fld, ret_ty), cf, constrs), ty);
804804
}
805805
case (ty_native_fn(?abi, ?args, ?ret_ty)) {
806-
let vec[arg] new_args = [];
806+
let arg[] new_args = ~[];
807807
for (arg a in args) {
808808
auto new_ty = fold_ty(cx, fld, a.ty);
809-
new_args += [rec(mode=a.mode, ty=new_ty)];
809+
new_args += ~[rec(mode=a.mode, ty=new_ty)];
810810
}
811811
ty =
812812
copy_cname(cx,
@@ -816,9 +816,10 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
816816
case (ty_obj(?methods)) {
817817
let vec[method] new_methods = [];
818818
for (method m in methods) {
819-
let vec[arg] new_args = [];
819+
let arg[] new_args = ~[];
820820
for (arg a in m.inputs) {
821-
new_args += [rec(mode=a.mode, ty=fold_ty(cx, fld, a.ty))];
821+
new_args += ~[rec(mode=a.mode,
822+
ty=fold_ty(cx, fld, a.ty))];
822823
}
823824
new_methods +=
824825
[rec(proto=m.proto,
@@ -1302,7 +1303,7 @@ fn hash_type_structure(&sty st) -> uint {
13021303
h += h << 5u + hash_ty(subty);
13031304
ret h;
13041305
}
1305-
fn hash_fn(uint id, &vec[arg] args, &t rty) -> uint {
1306+
fn hash_fn(uint id, &arg[] args, &t rty) -> uint {
13061307
auto h = id;
13071308
for (arg a in args) { h += h << 5u + hash_ty(a.ty); }
13081309
h += h << 5u + hash_ty(rty);
@@ -1448,11 +1449,11 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
14481449
fn equal_mt(&mt a, &mt b) -> bool {
14491450
ret a.mut == b.mut && eq_ty(a.ty, b.ty);
14501451
}
1451-
fn equal_fn(&vec[arg] args_a, &t rty_a, &vec[arg] args_b, &t rty_b) ->
1452+
fn equal_fn(&arg[] args_a, &t rty_a, &arg[] args_b, &t rty_b) ->
14521453
bool {
14531454
if (!eq_ty(rty_a, rty_b)) { ret false; }
1454-
auto len = vec::len[arg](args_a);
1455-
if (len != vec::len[arg](args_b)) { ret false; }
1455+
auto len = ivec::len[arg](args_a);
1456+
if (len != ivec::len[arg](args_b)) { ret false; }
14561457
auto i = 0u;
14571458
while (i < len) {
14581459
auto arg_a = args_a.(i);
@@ -1788,7 +1789,7 @@ fn type_contains_params(&ctxt cx, &t typ) -> bool {
17881789

17891790

17901791
// Type accessors for substructures of types
1791-
fn ty_fn_args(&ctxt cx, &t fty) -> vec[arg] {
1792+
fn ty_fn_args(&ctxt cx, &t fty) -> arg[] {
17921793
alt (struct(cx, fty)) {
17931794
case (ty::ty_fn(_, ?a, _, _, _)) { ret a; }
17941795
case (ty::ty_native_fn(_, ?a, _)) { ret a; }
@@ -2073,20 +2074,20 @@ mod unify {
20732074
}
20742075
tag fn_common_res {
20752076
fn_common_res_err(result);
2076-
fn_common_res_ok(vec[arg], t);
2077+
fn_common_res_ok(arg[], t);
20772078
}
20782079
fn unify_fn_common(&@ctxt cx, &t expected, &t actual,
2079-
&vec[arg] expected_inputs, &t expected_output,
2080-
&vec[arg] actual_inputs, &t actual_output) ->
2080+
&arg[] expected_inputs, &t expected_output,
2081+
&arg[] actual_inputs, &t actual_output) ->
20812082
fn_common_res {
2082-
auto expected_len = vec::len[arg](expected_inputs);
2083-
auto actual_len = vec::len[arg](actual_inputs);
2083+
auto expected_len = ivec::len[arg](expected_inputs);
2084+
auto actual_len = ivec::len[arg](actual_inputs);
20842085
if (expected_len != actual_len) {
20852086
ret fn_common_res_err(ures_err(terr_arg_count));
20862087
}
20872088
// TODO: as above, we should have an iter2 iterator.
20882089

2089-
let vec[arg] result_ins = [];
2090+
let arg[] result_ins = ~[];
20902091
auto i = 0u;
20912092
while (i < expected_len) {
20922093
auto expected_input = expected_inputs.(i);
@@ -2101,7 +2102,7 @@ mod unify {
21012102
auto result = unify_step(cx, expected_input.ty, actual_input.ty);
21022103
alt (result) {
21032104
case (ures_ok(?rty)) {
2104-
result_ins += [rec(mode=result_mode, ty=rty)];
2105+
result_ins += ~[rec(mode=result_mode, ty=rty)];
21052106
}
21062107
case (_) { ret fn_common_res_err(result); }
21072108
}
@@ -2116,8 +2117,8 @@ mod unify {
21162117
}
21172118
}
21182119
fn unify_fn(&@ctxt cx, &ast::proto e_proto, &ast::proto a_proto,
2119-
&t expected, &t actual, &vec[arg] expected_inputs,
2120-
&t expected_output, &vec[arg] actual_inputs, &t actual_output,
2120+
&t expected, &t actual, &arg[] expected_inputs,
2121+
&t expected_output, &arg[] actual_inputs, &t actual_output,
21212122
&controlflow expected_cf, &controlflow actual_cf,
21222123
&vec[@constr_def] expected_constrs,
21232124
&vec[@constr_def] actual_constrs) -> result {
@@ -2158,8 +2159,8 @@ mod unify {
21582159
}
21592160
fn unify_native_fn(&@ctxt cx, &ast::native_abi e_abi,
21602161
&ast::native_abi a_abi, &t expected, &t actual,
2161-
&vec[arg] expected_inputs, &t expected_output,
2162-
&vec[arg] actual_inputs, &t actual_output) -> result {
2162+
&arg[] expected_inputs, &t expected_output,
2163+
&arg[] actual_inputs, &t actual_output) -> result {
21632164
if (e_abi != a_abi) { ret ures_err(terr_mismatch); }
21642165
auto t =
21652166
unify_fn_common(cx, expected, actual, expected_inputs,

0 commit comments

Comments
 (0)