rustc: Change function argument types to interior vectors
This commit is contained in:
parent
50b1953f9b
commit
108cc4e0ed
|
@ -334,9 +334,9 @@ fn parse_hex(@pstate st) -> uint {
|
|||
}
|
||||
|
||||
fn parse_ty_fn(@pstate st, str_def sd) ->
|
||||
tup(vec[ty::arg], ty::t, ast::controlflow, vec[@ty::constr_def]) {
|
||||
tup(ty::arg[], ty::t, ast::controlflow, vec[@ty::constr_def]) {
|
||||
assert (next(st) as char == '[');
|
||||
let vec[ty::arg] inputs = [];
|
||||
let ty::arg[] inputs = ~[];
|
||||
while (peek(st) as char != ']') {
|
||||
auto mode = ty::mo_val;
|
||||
if (peek(st) as char == '&') {
|
||||
|
@ -347,7 +347,7 @@ fn parse_ty_fn(@pstate st, str_def sd) ->
|
|||
st.pos += 1u;
|
||||
}
|
||||
}
|
||||
inputs += [rec(mode=mode, ty=parse_ty(st, sd))];
|
||||
inputs += ~[rec(mode=mode, ty=parse_ty(st, sd))];
|
||||
}
|
||||
st.pos += 1u; // eat the ']'
|
||||
auto cs = parse_constrs(st, sd);
|
||||
|
|
|
@ -199,7 +199,7 @@ fn enc_proto(&io::writer w, proto proto) {
|
|||
case (proto_fn) { w.write_char('F'); }
|
||||
}
|
||||
}
|
||||
fn enc_ty_fn(&io::writer w, &@ctxt cx, &vec[ty::arg] args, &ty::t out,
|
||||
fn enc_ty_fn(&io::writer w, &@ctxt cx, &ty::arg[] args, &ty::t out,
|
||||
&controlflow cf, &vec[@ty::constr_def] constrs) {
|
||||
w.write_char('[');
|
||||
for (ty::arg arg in args) {
|
||||
|
|
|
@ -662,7 +662,7 @@ fn def_is_local(&ast::def d, bool objfields_count) -> bool {
|
|||
};
|
||||
}
|
||||
|
||||
fn fty_args(&ctx cx, ty::t fty) -> vec[ty::arg] {
|
||||
fn fty_args(&ctx cx, ty::t fty) -> ty::arg[] {
|
||||
ret alt (ty::struct(*cx.tcx, fty)) {
|
||||
case (ty::ty_fn(_, ?args, _, _, _)) { args }
|
||||
case (ty::ty_native_fn(_, ?args, _)) { args }
|
||||
|
|
|
@ -472,7 +472,7 @@ fn T_glue_fn(&type_names tn) -> TypeRef {
|
|||
|
||||
fn T_dtor(&@crate_ctxt ccx, &span sp, TypeRef llself_ty) -> TypeRef {
|
||||
ret type_of_fn_full(ccx, sp, ast::proto_fn, some[TypeRef](llself_ty),
|
||||
vec::empty[ty::arg](), ty::mk_nil(ccx.tcx), 0u);
|
||||
~[], ty::mk_nil(ccx.tcx), 0u);
|
||||
}
|
||||
|
||||
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 {
|
|||
ret type_of_inner(cx, sp, t);
|
||||
}
|
||||
|
||||
fn type_of_explicit_args(&@crate_ctxt cx, &span sp, &vec[ty::arg] inputs) ->
|
||||
fn type_of_explicit_args(&@crate_ctxt cx, &span sp, &ty::arg[] inputs) ->
|
||||
vec[TypeRef] {
|
||||
let vec[TypeRef] atys = [];
|
||||
for (ty::arg arg in inputs) {
|
||||
|
@ -710,7 +710,7 @@ fn type_of_explicit_args(&@crate_ctxt cx, &span sp, &vec[ty::arg] inputs) ->
|
|||
// - new_fn_ctxt
|
||||
// - trans_args
|
||||
fn type_of_fn_full(&@crate_ctxt cx, &span sp, ast::proto proto,
|
||||
&option::t[TypeRef] obj_self, &vec[ty::arg] inputs,
|
||||
&option::t[TypeRef] obj_self, &ty::arg[] inputs,
|
||||
&ty::t output, uint ty_param_count) -> TypeRef {
|
||||
let vec[TypeRef] atys = [];
|
||||
|
||||
|
@ -743,7 +743,7 @@ fn type_of_fn_full(&@crate_ctxt cx, &span sp, ast::proto proto,
|
|||
atys +=
|
||||
[T_fn_pair(cx.tn,
|
||||
type_of_fn_full(cx, sp, ast::proto_fn, none[TypeRef],
|
||||
[rec(mode=ty::mo_alias(false),
|
||||
~[rec(mode=ty::mo_alias(false),
|
||||
ty=output)], ty::mk_nil(cx.tcx),
|
||||
0u))];
|
||||
}
|
||||
|
@ -754,14 +754,14 @@ fn type_of_fn_full(&@crate_ctxt cx, &span sp, ast::proto proto,
|
|||
}
|
||||
|
||||
fn type_of_fn(&@crate_ctxt cx, &span sp, ast::proto proto,
|
||||
&vec[ty::arg] inputs, &ty::t output, uint ty_param_count) ->
|
||||
&ty::arg[] inputs, &ty::t output, uint ty_param_count) ->
|
||||
TypeRef {
|
||||
ret type_of_fn_full(cx, sp, proto, none[TypeRef], inputs, output,
|
||||
ty_param_count);
|
||||
}
|
||||
|
||||
fn type_of_native_fn(&@crate_ctxt cx, &span sp, ast::native_abi abi,
|
||||
&vec[ty::arg] inputs, &ty::t output, uint ty_param_count)
|
||||
&ty::arg[] inputs, &ty::t output, uint ty_param_count)
|
||||
-> TypeRef {
|
||||
let vec[TypeRef] atys = [];
|
||||
if (abi == ast::native_abi_rust) {
|
||||
|
@ -2137,7 +2137,7 @@ fn trans_res_drop(@block_ctxt cx, ValueRef rs, &ast::def_id did,
|
|||
} else {
|
||||
auto params = decoder::get_type_param_count(ccx.tcx, did);
|
||||
auto f_t = type_of_fn(ccx, cx.sp, ast::proto_fn,
|
||||
[rec(mode=ty::mo_alias(false), ty=inner_t)],
|
||||
~[rec(mode=ty::mo_alias(false), ty=inner_t)],
|
||||
ty::mk_nil(ccx.tcx), params);
|
||||
get_extern_const(ccx.externs, ccx.llmod,
|
||||
decoder::get_symbol(ccx.sess, did),
|
||||
|
@ -4526,7 +4526,7 @@ fn trans_for_each(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
|
|||
// and pass it in as a first class fn-arg to the iterator.
|
||||
auto iter_body_llty =
|
||||
type_of_fn_full(lcx.ccx, cx.sp, ast::proto_fn, none[TypeRef],
|
||||
[rec(mode=ty::mo_alias(false), ty=decl_ty)],
|
||||
~[rec(mode=ty::mo_alias(false), ty=decl_ty)],
|
||||
ty::mk_nil(lcx.ccx.tcx), 0u);
|
||||
let ValueRef lliterbody =
|
||||
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,
|
|||
&option::t[generic_info] gen, &option::t[ValueRef] lliterbody,
|
||||
&vec[@ast::expr] es, &ty::t fn_ty) ->
|
||||
tup(@block_ctxt, vec[ValueRef], ValueRef) {
|
||||
let vec[ty::arg] args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
|
||||
let ty::arg[] args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
|
||||
let vec[ValueRef] llargs = [];
|
||||
let vec[ValueRef] lltydescs = [];
|
||||
let @block_ctxt bcx = cx;
|
||||
|
@ -6342,7 +6342,7 @@ fn trans_put(&@block_ctxt cx, &option::t[@ast::expr] e) -> result {
|
|||
auto e_ty = ty::expr_ty(cx.fcx.lcx.ccx.tcx, x);
|
||||
auto arg = rec(mode=ty::mo_alias(false), ty=e_ty);
|
||||
auto arg_tys =
|
||||
type_of_explicit_args(cx.fcx.lcx.ccx, x.span, [arg]);
|
||||
type_of_explicit_args(cx.fcx.lcx.ccx, x.span, ~[arg]);
|
||||
auto r = trans_arg_expr(bcx, arg, arg_tys.(0), x);
|
||||
bcx = r.bcx;
|
||||
llargs += [r.val];
|
||||
|
@ -6578,7 +6578,7 @@ fn mk_spawn_wrapper(&@block_ctxt cx, &@ast::expr func, &ty::t args_ty) ->
|
|||
auto llmod = cx.fcx.lcx.ccx.llmod;
|
||||
let TypeRef wrapper_fn_type =
|
||||
type_of_fn(cx.fcx.lcx.ccx, cx.sp, ast::proto_fn,
|
||||
[rec(mode=ty::mo_alias(false), ty=args_ty)], ty::idx_nil,
|
||||
~[rec(mode=ty::mo_alias(false), ty=args_ty)], ty::idx_nil,
|
||||
0u);
|
||||
// TODO: construct a name based on tname
|
||||
|
||||
|
@ -7450,7 +7450,7 @@ fn copy_any_self_to_alloca(@fn_ctxt fcx, option::t[ty_self_pair] ty_self) {
|
|||
}
|
||||
|
||||
fn copy_args_to_allocas(@fn_ctxt fcx, vec[ast::arg] args,
|
||||
vec[ty::arg] arg_tys) {
|
||||
&ty::arg[] arg_tys) {
|
||||
auto bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
|
||||
let uint arg_n = 0u;
|
||||
for (ast::arg aarg in args) {
|
||||
|
@ -7468,7 +7468,7 @@ fn copy_args_to_allocas(@fn_ctxt fcx, vec[ast::arg] args,
|
|||
}
|
||||
|
||||
fn add_cleanups_for_args(&@block_ctxt bcx, vec[ast::arg] args,
|
||||
vec[ty::arg] arg_tys) {
|
||||
&ty::arg[] arg_tys) {
|
||||
let uint arg_n = 0u;
|
||||
for (ast::arg aarg in args) {
|
||||
if (aarg.mode == ast::val) {
|
||||
|
@ -7485,7 +7485,7 @@ fn is_terminated(&@block_ctxt cx) -> bool {
|
|||
ret llvm::LLVMIsATerminatorInst(inst) as int != 0;
|
||||
}
|
||||
|
||||
fn arg_tys_of_fn(&@crate_ctxt ccx,ast::node_id id) -> vec[ty::arg] {
|
||||
fn arg_tys_of_fn(&@crate_ctxt ccx,ast::node_id id) -> ty::arg[] {
|
||||
alt (ty::struct(ccx.tcx, ty::node_id_to_type(ccx.tcx, id))) {
|
||||
case (ty::ty_fn(_, ?arg_tys, _, _, _)) { ret arg_tys; }
|
||||
}
|
||||
|
@ -7699,7 +7699,7 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
|
|||
create_llargs_for_fn_args(fcx, ast::proto_fn, none[ty_self_pair],
|
||||
ty::ret_ty_of_fn(ccx.tcx, ctor_id),
|
||||
fn_args, ty_params);
|
||||
let vec[ty::arg] arg_tys = arg_tys_of_fn(ccx, ctor_id);
|
||||
let ty::arg[] arg_tys = arg_tys_of_fn(ccx, ctor_id);
|
||||
copy_args_to_allocas(fcx, fn_args, arg_tys);
|
||||
|
||||
// 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,
|
|||
// a dtor, since otherwise they are never dropped, and the dtor never
|
||||
// runs.
|
||||
if (vec::len[ast::ty_param](ty_params) == 0u &&
|
||||
vec::len[ty::arg](arg_tys) == 0u) {
|
||||
std::ivec::len[ty::arg](arg_tys) == 0u) {
|
||||
// If the object we're translating has no fields or type parameters,
|
||||
// there's not much to do.
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ type field = rec(ast::ident ident, mt mt);
|
|||
type method =
|
||||
rec(ast::proto proto,
|
||||
ast::ident ident,
|
||||
vec[arg] inputs,
|
||||
arg[] inputs,
|
||||
t output,
|
||||
controlflow cf,
|
||||
vec[@constr_def] constrs);
|
||||
|
@ -266,8 +266,8 @@ tag sty {
|
|||
ty_task;
|
||||
ty_tup(mt[]);
|
||||
ty_rec(field[]);
|
||||
ty_fn(ast::proto, vec[arg], t, controlflow, vec[@constr_def]);
|
||||
ty_native_fn(ast::native_abi, vec[arg], t);
|
||||
ty_fn(ast::proto, arg[], t, controlflow, vec[@constr_def]);
|
||||
ty_native_fn(ast::native_abi, arg[], t);
|
||||
ty_obj(vec[method]);
|
||||
ty_res(def_id, t, vec[t]);
|
||||
ty_var(int); // type variable
|
||||
|
@ -445,7 +445,7 @@ fn mk_raw_ty(&ctxt cx, &sty st, &option::t[str] cname) -> raw_t {
|
|||
derive_flags_t(cx, has_params, has_vars, a.ty);
|
||||
}
|
||||
fn derive_flags_sig(&ctxt cx, &mutable bool has_params,
|
||||
&mutable bool has_vars, &vec[arg] args, &t tt) {
|
||||
&mutable bool has_vars, &arg[] args, &t tt) {
|
||||
for (arg a in args) { derive_flags_arg(cx, has_params, has_vars, a); }
|
||||
derive_flags_t(cx, has_params, has_vars, tt);
|
||||
}
|
||||
|
@ -597,12 +597,12 @@ fn mk_imm_tup(&ctxt cx, &t[] tys) -> t {
|
|||
|
||||
fn mk_rec(&ctxt cx, &field[] fs) -> t { ret gen_ty(cx, ty_rec(fs)); }
|
||||
|
||||
fn mk_fn(&ctxt cx, &ast::proto proto, &vec[arg] args, &t ty, &controlflow cf,
|
||||
fn mk_fn(&ctxt cx, &ast::proto proto, &arg[] args, &t ty, &controlflow cf,
|
||||
&vec[@constr_def] constrs) -> t {
|
||||
ret gen_ty(cx, ty_fn(proto, args, ty, cf, constrs));
|
||||
}
|
||||
|
||||
fn mk_native_fn(&ctxt cx, &ast::native_abi abi, &vec[arg] args, &t ty) -> t {
|
||||
fn mk_native_fn(&ctxt cx, &ast::native_abi abi, &arg[] args, &t ty) -> t {
|
||||
ret gen_ty(cx, ty_native_fn(abi, args, ty));
|
||||
}
|
||||
|
||||
|
@ -792,10 +792,10 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
|
|||
ty = copy_cname(cx, mk_rec(cx, new_fields), ty);
|
||||
}
|
||||
case (ty_fn(?proto, ?args, ?ret_ty, ?cf, ?constrs)) {
|
||||
let vec[arg] new_args = [];
|
||||
let arg[] new_args = ~[];
|
||||
for (arg a in args) {
|
||||
auto new_ty = fold_ty(cx, fld, a.ty);
|
||||
new_args += [rec(mode=a.mode, ty=new_ty)];
|
||||
new_args += ~[rec(mode=a.mode, ty=new_ty)];
|
||||
}
|
||||
ty =
|
||||
copy_cname(cx,
|
||||
|
@ -803,10 +803,10 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
|
|||
fold_ty(cx, fld, ret_ty), cf, constrs), ty);
|
||||
}
|
||||
case (ty_native_fn(?abi, ?args, ?ret_ty)) {
|
||||
let vec[arg] new_args = [];
|
||||
let arg[] new_args = ~[];
|
||||
for (arg a in args) {
|
||||
auto new_ty = fold_ty(cx, fld, a.ty);
|
||||
new_args += [rec(mode=a.mode, ty=new_ty)];
|
||||
new_args += ~[rec(mode=a.mode, ty=new_ty)];
|
||||
}
|
||||
ty =
|
||||
copy_cname(cx,
|
||||
|
@ -816,9 +816,10 @@ fn fold_ty(&ctxt cx, fold_mode fld, t ty_0) -> t {
|
|||
case (ty_obj(?methods)) {
|
||||
let vec[method] new_methods = [];
|
||||
for (method m in methods) {
|
||||
let vec[arg] new_args = [];
|
||||
let arg[] new_args = ~[];
|
||||
for (arg a in m.inputs) {
|
||||
new_args += [rec(mode=a.mode, ty=fold_ty(cx, fld, a.ty))];
|
||||
new_args += ~[rec(mode=a.mode,
|
||||
ty=fold_ty(cx, fld, a.ty))];
|
||||
}
|
||||
new_methods +=
|
||||
[rec(proto=m.proto,
|
||||
|
@ -1302,7 +1303,7 @@ fn hash_type_structure(&sty st) -> uint {
|
|||
h += h << 5u + hash_ty(subty);
|
||||
ret h;
|
||||
}
|
||||
fn hash_fn(uint id, &vec[arg] args, &t rty) -> uint {
|
||||
fn hash_fn(uint id, &arg[] args, &t rty) -> uint {
|
||||
auto h = id;
|
||||
for (arg a in args) { h += h << 5u + hash_ty(a.ty); }
|
||||
h += h << 5u + hash_ty(rty);
|
||||
|
@ -1448,11 +1449,11 @@ fn equal_type_structures(&sty a, &sty b) -> bool {
|
|||
fn equal_mt(&mt a, &mt b) -> bool {
|
||||
ret a.mut == b.mut && eq_ty(a.ty, b.ty);
|
||||
}
|
||||
fn equal_fn(&vec[arg] args_a, &t rty_a, &vec[arg] args_b, &t rty_b) ->
|
||||
fn equal_fn(&arg[] args_a, &t rty_a, &arg[] args_b, &t rty_b) ->
|
||||
bool {
|
||||
if (!eq_ty(rty_a, rty_b)) { ret false; }
|
||||
auto len = vec::len[arg](args_a);
|
||||
if (len != vec::len[arg](args_b)) { ret false; }
|
||||
auto len = ivec::len[arg](args_a);
|
||||
if (len != ivec::len[arg](args_b)) { ret false; }
|
||||
auto i = 0u;
|
||||
while (i < len) {
|
||||
auto arg_a = args_a.(i);
|
||||
|
@ -1788,7 +1789,7 @@ fn type_contains_params(&ctxt cx, &t typ) -> bool {
|
|||
|
||||
|
||||
// Type accessors for substructures of types
|
||||
fn ty_fn_args(&ctxt cx, &t fty) -> vec[arg] {
|
||||
fn ty_fn_args(&ctxt cx, &t fty) -> arg[] {
|
||||
alt (struct(cx, fty)) {
|
||||
case (ty::ty_fn(_, ?a, _, _, _)) { ret a; }
|
||||
case (ty::ty_native_fn(_, ?a, _)) { ret a; }
|
||||
|
@ -2073,20 +2074,20 @@ mod unify {
|
|||
}
|
||||
tag fn_common_res {
|
||||
fn_common_res_err(result);
|
||||
fn_common_res_ok(vec[arg], t);
|
||||
fn_common_res_ok(arg[], t);
|
||||
}
|
||||
fn unify_fn_common(&@ctxt cx, &t expected, &t actual,
|
||||
&vec[arg] expected_inputs, &t expected_output,
|
||||
&vec[arg] actual_inputs, &t actual_output) ->
|
||||
&arg[] expected_inputs, &t expected_output,
|
||||
&arg[] actual_inputs, &t actual_output) ->
|
||||
fn_common_res {
|
||||
auto expected_len = vec::len[arg](expected_inputs);
|
||||
auto actual_len = vec::len[arg](actual_inputs);
|
||||
auto expected_len = ivec::len[arg](expected_inputs);
|
||||
auto actual_len = ivec::len[arg](actual_inputs);
|
||||
if (expected_len != actual_len) {
|
||||
ret fn_common_res_err(ures_err(terr_arg_count));
|
||||
}
|
||||
// TODO: as above, we should have an iter2 iterator.
|
||||
|
||||
let vec[arg] result_ins = [];
|
||||
let arg[] result_ins = ~[];
|
||||
auto i = 0u;
|
||||
while (i < expected_len) {
|
||||
auto expected_input = expected_inputs.(i);
|
||||
|
@ -2101,7 +2102,7 @@ mod unify {
|
|||
auto result = unify_step(cx, expected_input.ty, actual_input.ty);
|
||||
alt (result) {
|
||||
case (ures_ok(?rty)) {
|
||||
result_ins += [rec(mode=result_mode, ty=rty)];
|
||||
result_ins += ~[rec(mode=result_mode, ty=rty)];
|
||||
}
|
||||
case (_) { ret fn_common_res_err(result); }
|
||||
}
|
||||
|
@ -2116,8 +2117,8 @@ mod unify {
|
|||
}
|
||||
}
|
||||
fn unify_fn(&@ctxt cx, &ast::proto e_proto, &ast::proto a_proto,
|
||||
&t expected, &t actual, &vec[arg] expected_inputs,
|
||||
&t expected_output, &vec[arg] actual_inputs, &t actual_output,
|
||||
&t expected, &t actual, &arg[] expected_inputs,
|
||||
&t expected_output, &arg[] actual_inputs, &t actual_output,
|
||||
&controlflow expected_cf, &controlflow actual_cf,
|
||||
&vec[@constr_def] expected_constrs,
|
||||
&vec[@constr_def] actual_constrs) -> result {
|
||||
|
@ -2158,8 +2159,8 @@ mod unify {
|
|||
}
|
||||
fn unify_native_fn(&@ctxt cx, &ast::native_abi e_abi,
|
||||
&ast::native_abi a_abi, &t expected, &t actual,
|
||||
&vec[arg] expected_inputs, &t expected_output,
|
||||
&vec[arg] actual_inputs, &t actual_output) -> result {
|
||||
&arg[] expected_inputs, &t expected_output,
|
||||
&arg[] actual_inputs, &t actual_output) -> result {
|
||||
if (e_abi != a_abi) { ret ures_err(terr_mismatch); }
|
||||
auto t =
|
||||
unify_fn_common(cx, expected, actual, expected_inputs,
|
||||
|
|
|
@ -308,9 +308,12 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
|
|||
typ = ty::mk_rec(tcx, flds);
|
||||
}
|
||||
case (ast::ty_fn(?proto, ?inputs, ?output, ?cf, ?constrs)) {
|
||||
auto f = bind ast_arg_to_arg(tcx, getter, _);
|
||||
auto i = vec::map[ast::ty_arg, arg](f, inputs);
|
||||
auto i = ~[];
|
||||
for (ast::ty_arg ta in inputs) {
|
||||
i += ~[ast_arg_to_arg(tcx, getter, ta)];
|
||||
}
|
||||
auto out_ty = ast_ty_to_ty(tcx, getter, output);
|
||||
|
||||
let fn(&@ast::constr) -> @ty::constr_def g =
|
||||
bind ast_constr_to_constr(tcx, _);
|
||||
let vec[@ty::constr_def] out_constrs = vec::map(g, constrs);
|
||||
|
@ -336,8 +339,12 @@ fn ast_ty_to_ty(&ty::ctxt tcx, &ty_getter getter, &@ast::ty ast_ty) -> ty::t {
|
|||
let vec[ty::method] tmeths = [];
|
||||
auto f = bind ast_arg_to_arg(tcx, getter, _);
|
||||
for (ast::ty_method m in meths) {
|
||||
auto ins = vec::map[ast::ty_arg, arg](f, m.node.inputs);
|
||||
auto ins = ~[];
|
||||
for (ast::ty_arg ta in m.node.inputs) {
|
||||
ins += ~[ast_arg_to_arg(tcx, getter, ta)];
|
||||
}
|
||||
auto out = ast_ty_to_ty(tcx, getter, m.node.output);
|
||||
|
||||
let fn(&@ast::constr) -> @ty::constr_def g =
|
||||
bind ast_constr_to_constr(tcx, _);
|
||||
let vec[@ty::constr_def] out_constrs =
|
||||
|
@ -453,8 +460,10 @@ mod collect {
|
|||
ast::proto proto, &vec[ast::ty_param] ty_params,
|
||||
&option::t[ast::def_id] def_id) ->
|
||||
ty::ty_param_count_and_ty {
|
||||
auto input_tys = vec::map[ast::arg, arg](ty_of_arg, decl.inputs);
|
||||
auto input_tys = ~[];
|
||||
for (ast::arg a in decl.inputs) { input_tys += ~[ty_of_arg(a)]; }
|
||||
auto output_ty = convert(decl.output);
|
||||
|
||||
let fn(&@ast::constr) -> @ty::constr_def g =
|
||||
bind ast_constr_to_constr(cx.tcx, _);
|
||||
let vec[@ty::constr_def] out_constrs = vec::map(g, decl.constraints);
|
||||
|
@ -475,8 +484,10 @@ mod collect {
|
|||
&vec[ast::ty_param] ty_params,
|
||||
&ast::def_id def_id) ->
|
||||
ty::ty_param_count_and_ty {
|
||||
auto input_tys = vec::map[ast::arg, arg](ty_of_arg, decl.inputs);
|
||||
auto input_tys = ~[];
|
||||
for (ast::arg a in decl.inputs) { input_tys += ~[ty_of_arg(a)]; }
|
||||
auto output_ty = convert(decl.output);
|
||||
|
||||
auto t_fn = ty::mk_native_fn(cx.tcx, abi, input_tys, output_ty);
|
||||
auto ty_param_count = vec::len[ast::ty_param](ty_params);
|
||||
auto tpt = tup(ty_param_count, t_fn);
|
||||
|
@ -519,8 +530,13 @@ mod collect {
|
|||
fn ty_of_method(@ctxt cx, &@ast::method m) -> ty::method {
|
||||
auto get = bind getter(cx, _);
|
||||
auto convert = bind ast_ty_to_ty(cx.tcx, get, _);
|
||||
|
||||
auto inputs = ~[];
|
||||
for (ast::arg a in m.node.meth.decl.inputs) {
|
||||
inputs += ~[ty_of_arg(cx, a)];
|
||||
}
|
||||
auto f = bind ty_of_arg(cx, _);
|
||||
auto inputs = vec::map[ast::arg, arg](f, m.node.meth.decl.inputs);
|
||||
|
||||
auto output = convert(m.node.meth.decl.output);
|
||||
let fn(&@ast::constr) -> @ty::constr_def g =
|
||||
bind ast_constr_to_constr(cx.tcx, _);
|
||||
|
@ -541,12 +557,14 @@ mod collect {
|
|||
ast::node_id ctor_id, &vec[ast::ty_param] ty_params) ->
|
||||
ty::ty_param_count_and_ty {
|
||||
auto t_obj = ty_of_obj(cx, id, obj_info, ty_params);
|
||||
let vec[arg] t_inputs = [];
|
||||
|
||||
let arg[] t_inputs = ~[];
|
||||
for (ast::obj_field f in obj_info.fields) {
|
||||
auto g = bind getter(cx, _);
|
||||
auto t_field = ast_ty_to_ty(cx.tcx, g, f.ty);
|
||||
vec::push(t_inputs, rec(mode=ty::mo_alias(false), ty=t_field));
|
||||
t_inputs += ~[rec(mode=ty::mo_alias(false), ty=t_field)];
|
||||
}
|
||||
|
||||
auto t_fn = ty::mk_fn(cx.tcx, ast::proto_fn, t_inputs, t_obj._1,
|
||||
ast::return, []);
|
||||
auto tpt = tup(t_obj._0, t_fn);
|
||||
|
@ -650,10 +668,10 @@ mod collect {
|
|||
// should be called to resolve named types.
|
||||
|
||||
auto f = bind getter(cx, _);
|
||||
let vec[arg] args = [];
|
||||
let arg[] args = ~[];
|
||||
for (ast::variant_arg va in variant.node.args) {
|
||||
auto arg_ty = ast_ty_to_ty(cx.tcx, f, va.ty);
|
||||
args += [rec(mode=ty::mo_alias(false), ty=arg_ty)];
|
||||
args += ~[rec(mode=ty::mo_alias(false), ty=arg_ty)];
|
||||
}
|
||||
auto tag_t = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
|
||||
// FIXME: this will be different for constrained types
|
||||
|
@ -718,7 +736,7 @@ mod collect {
|
|||
|
||||
auto args = ty::ty_fn_args(cx.tcx, tpt._1);
|
||||
i = 0u;
|
||||
while (i < vec::len[ty::arg](args)) {
|
||||
while (i < ivec::len[ty::arg](args)) {
|
||||
auto fld = object.fields.(i);
|
||||
write::ty_only(cx.tcx, fld.id, args.(i).ty);
|
||||
i += 1u;
|
||||
|
@ -728,7 +746,7 @@ mod collect {
|
|||
alt (object.dtor) {
|
||||
case (none) {/* nothing to do */ }
|
||||
case (some(?m)) {
|
||||
auto t = ty::mk_fn(cx.tcx, ast::proto_fn, [],
|
||||
auto t = ty::mk_fn(cx.tcx, ast::proto_fn, ~[],
|
||||
ty::mk_nil(cx.tcx), ast::return, []);
|
||||
write::ty_only(cx.tcx, m.node.id, t);
|
||||
}
|
||||
|
@ -738,9 +756,9 @@ mod collect {
|
|||
auto t_arg = ty_of_arg(cx, f.decl.inputs.(0));
|
||||
auto t_res = ty::mk_res(cx.tcx, local_def(it.id), t_arg.ty,
|
||||
mk_ty_params(cx, vec::len(tps)));
|
||||
auto t_ctor = ty::mk_fn(cx.tcx, ast::proto_fn, [t_arg],
|
||||
auto t_ctor = ty::mk_fn(cx.tcx, ast::proto_fn, ~[t_arg],
|
||||
t_res, ast::return, []);
|
||||
auto t_dtor = ty::mk_fn(cx.tcx, ast::proto_fn, [t_arg],
|
||||
auto t_dtor = ty::mk_fn(cx.tcx, ast::proto_fn, ~[t_arg],
|
||||
ty::mk_nil(cx.tcx), ast::return, []);
|
||||
write::ty_only(cx.tcx, it.id, t_res);
|
||||
write::ty_only(cx.tcx, ctor_id, t_ctor);
|
||||
|
@ -1343,7 +1361,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
}
|
||||
// Check that the correct number of arguments were supplied.
|
||||
|
||||
auto expected_arg_count = vec::len[ty::arg](arg_tys);
|
||||
auto expected_arg_count = ivec::len[ty::arg](arg_tys);
|
||||
auto supplied_arg_count = vec::len[option::t[@ast::expr]](args);
|
||||
if (expected_arg_count != supplied_arg_count) {
|
||||
fcx.ccx.tcx.sess.span_fatal(sp,
|
||||
|
@ -1794,7 +1812,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
// Pull the argument and return types out.
|
||||
|
||||
auto proto_1;
|
||||
let vec[ty::arg] arg_tys_1 = [];
|
||||
let ty::arg[] arg_tys_1 = ~[];
|
||||
auto rt_1;
|
||||
auto fty = expr_ty(fcx.ccx.tcx, f);
|
||||
auto t_1;
|
||||
|
@ -1813,7 +1831,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
while (i < vec::len[option::t[@ast::expr]](args)) {
|
||||
alt (args.(i)) {
|
||||
case (some(_)) {/* no-op */ }
|
||||
case (none) { arg_tys_1 += [arg_tys.(i)]; }
|
||||
case (none) { arg_tys_1 += ~[arg_tys.(i)]; }
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
|
@ -2149,9 +2167,12 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
}
|
||||
fn ty_of_method(@crate_ctxt ccx, &@ast::method m) -> ty::method {
|
||||
auto convert = bind ast_ty_to_ty_crate(ccx, _);
|
||||
auto f = bind ty_of_arg(ccx, _);
|
||||
auto inputs =
|
||||
vec::map[ast::arg, arg](f, m.node.meth.decl.inputs);
|
||||
|
||||
auto inputs = ~[];
|
||||
for (ast::arg aa in m.node.meth.decl.inputs) {
|
||||
inputs += ~[ty_of_arg(ccx, aa)];
|
||||
}
|
||||
|
||||
auto output = convert(m.node.meth.decl.output);
|
||||
let fn(&@ast::constr) -> @ty::constr_def g =
|
||||
bind ast_constr_to_constr(ccx.tcx, _);
|
||||
|
|
|
@ -48,9 +48,8 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
|
|||
ret s + ty_to_str(cx, input.ty);
|
||||
}
|
||||
fn fn_to_str(&ctxt cx, ast::proto proto, option::t[ast::ident] ident,
|
||||
vec[arg] inputs, t output, ast::controlflow cf,
|
||||
&arg[] inputs, t output, ast::controlflow cf,
|
||||
&vec[@constr_def] constrs) -> str {
|
||||
auto f = bind fn_input_to_str(cx, _);
|
||||
auto s;
|
||||
alt (proto) {
|
||||
case (ast::proto_iter) { s = "iter"; }
|
||||
|
@ -58,7 +57,9 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
|
|||
}
|
||||
alt (ident) { case (some(?i)) { s += " "; s += i; } case (_) { } }
|
||||
s += "(";
|
||||
s += str::connect(vec::map[arg, str](f, inputs), ", ");
|
||||
auto strs = [];
|
||||
for (arg a in inputs) { strs += [fn_input_to_str(cx, a)]; }
|
||||
s += str::connect(strs, ", ");
|
||||
s += ")";
|
||||
if (struct(cx, output) != ty_nil) {
|
||||
alt (cf) {
|
||||
|
@ -130,9 +131,8 @@ fn ty_to_str(&ctxt cx, &t typ) -> str {
|
|||
s += fn_to_str(cx, proto, none, inputs, output, cf, constrs);
|
||||
}
|
||||
case (ty_native_fn(_, ?inputs, ?output)) {
|
||||
s +=
|
||||
fn_to_str(cx, ast::proto_fn, none, inputs, output,
|
||||
ast::return, []);
|
||||
s += fn_to_str(cx, ast::proto_fn, none, inputs, output,
|
||||
ast::return, []);
|
||||
}
|
||||
case (ty_obj(?meths)) {
|
||||
auto f = bind method_to_str(cx, _);
|
||||
|
|
Loading…
Reference in New Issue