rustc: Change lots of AST nodes to use interior vectors
This commit is contained in:
parent
bbcbaa6601
commit
0e2fff5337
23 changed files with 400 additions and 373 deletions
|
|
@ -53,7 +53,7 @@ fn check_crate(@ty::ctxt tcx, &@ast::crate crate) {
|
|||
tcx.sess.abort_if_errors();
|
||||
}
|
||||
|
||||
fn visit_fn(@ctx cx, &ast::_fn f, &vec[ast::ty_param] tp, &span sp,
|
||||
fn visit_fn(@ctx cx, &ast::_fn f, &ast::ty_param[] tp, &span sp,
|
||||
&fn_ident name, ast::node_id id, &scope sc, &vt[scope] v) {
|
||||
visit::visit_fn_decl(f.decl, sc, v);
|
||||
for (ast::arg arg_ in f.decl.inputs) {
|
||||
|
|
@ -132,7 +132,7 @@ fn visit_expr(@ctx cx, &@ast::expr ex, &scope sc, &vt[scope] v) {
|
|||
if (!handled) { visit::visit_expr(ex, sc, v); }
|
||||
}
|
||||
|
||||
fn check_call(&ctx cx, &@ast::expr f, &vec[@ast::expr] args, &scope sc) ->
|
||||
fn check_call(&ctx cx, &@ast::expr f, &(@ast::expr)[] args, &scope sc) ->
|
||||
rec(vec[node_id] root_vars, vec[ty::t] unsafe_ts) {
|
||||
auto fty = ty::expr_ty(*cx.tcx, f);
|
||||
auto arg_ts = fty_args(cx, fty);
|
||||
|
|
@ -261,7 +261,7 @@ fn check_tail_call(&ctx cx, &@ast::expr call) {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_alt(&ctx cx, &@ast::expr input, &vec[ast::arm] arms, &scope sc,
|
||||
fn check_alt(&ctx cx, &@ast::expr input, &ast::arm[] arms, &scope sc,
|
||||
&vt[scope] v) {
|
||||
visit::visit_expr(input, sc, v);
|
||||
auto root = expr_root(cx, input, true);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export crate_map;
|
|||
tag scope {
|
||||
scope_crate(@ast::crate);
|
||||
scope_item(@ast::item);
|
||||
scope_fn(ast::fn_decl, vec[ast::ty_param]);
|
||||
scope_fn(ast::fn_decl, ast::ty_param[]);
|
||||
scope_native_item(@ast::native_item);
|
||||
scope_loop(@ast::local); // there's only 1 decl per loop.
|
||||
scope_block(ast::block);
|
||||
|
|
@ -346,7 +346,7 @@ fn visit_native_item_with_scope(&@ast::native_item ni, &scopes sc,
|
|||
visit::visit_native_item(ni, cons(scope_native_item(ni), @sc), v);
|
||||
}
|
||||
|
||||
fn visit_fn_with_scope(&@env e, &ast::_fn f, &vec[ast::ty_param] tp, &span sp,
|
||||
fn visit_fn_with_scope(&@env e, &ast::_fn f, &ast::ty_param[] tp, &span sp,
|
||||
&fn_ident name, node_id id, &scopes sc,
|
||||
&vt[scopes] v) {
|
||||
// here's where we need to set up the mapping
|
||||
|
|
@ -376,7 +376,7 @@ fn visit_expr_with_scope(&@ast::expr x, &scopes sc, &vt[scopes] v) {
|
|||
case (ast::expr_for_each(?d, _, _)) {
|
||||
cons[scope](scope_loop(d), @sc)
|
||||
}
|
||||
case (ast::expr_fn(?f)) { cons(scope_fn(f.decl, []), @sc) }
|
||||
case (ast::expr_fn(?f)) { cons(scope_fn(f.decl, ~[]), @sc) }
|
||||
case (_) { sc }
|
||||
};
|
||||
visit::visit_expr(x, new_sc, v);
|
||||
|
|
@ -638,8 +638,7 @@ fn lookup_in_scope(&env e, scopes sc, &span sp, &ident name, namespace ns) ->
|
|||
}
|
||||
case (scope_native_item(?it)) {
|
||||
alt (it.node) {
|
||||
case (ast::native_item_fn(_, ?decl, ?ty_params))
|
||||
{
|
||||
case (ast::native_item_fn(_, ?decl, ?ty_params)) {
|
||||
ret lookup_in_fn(name, decl, ty_params, ns);
|
||||
}
|
||||
}
|
||||
|
|
@ -690,7 +689,7 @@ fn lookup_in_scope(&env e, scopes sc, &span sp, &ident name, namespace ns) ->
|
|||
|
||||
}
|
||||
|
||||
fn lookup_in_ty_params(&ident name, &vec[ast::ty_param] ty_params) ->
|
||||
fn lookup_in_ty_params(&ident name, &ast::ty_param[] ty_params) ->
|
||||
option::t[def] {
|
||||
auto i = 0u;
|
||||
for (ast::ty_param tp in ty_params) {
|
||||
|
|
@ -720,7 +719,7 @@ fn lookup_in_pat(&ident name, &ast::pat pat) -> option::t[def] {
|
|||
}
|
||||
|
||||
fn lookup_in_fn(&ident name, &ast::fn_decl decl,
|
||||
&vec[ast::ty_param] ty_params,
|
||||
&ast::ty_param[] ty_params,
|
||||
namespace ns) -> option::t[def] {
|
||||
alt (ns) {
|
||||
case (ns_value) {
|
||||
|
|
@ -736,7 +735,7 @@ fn lookup_in_fn(&ident name, &ast::fn_decl decl,
|
|||
}
|
||||
}
|
||||
|
||||
fn lookup_in_obj(&ident name, &ast::_obj ob, &vec[ast::ty_param] ty_params,
|
||||
fn lookup_in_obj(&ident name, &ast::_obj ob, &ast::ty_param[] ty_params,
|
||||
namespace ns) -> option::t[def] {
|
||||
alt (ns) {
|
||||
case (ns_value) {
|
||||
|
|
@ -1229,18 +1228,22 @@ fn check_item(@env e, &@ast::item i, &() x, &vt[()] v) {
|
|||
alt (i.node) {
|
||||
case (ast::item_fn(?f, ?ty_params)) {
|
||||
check_fn(*e, i.span, f);
|
||||
ensure_unique(*e, i.span, ty_params, ident_id, "type parameter");
|
||||
ensure_unique_ivec(*e, i.span, ty_params, ident_id,
|
||||
"type parameter");
|
||||
}
|
||||
case (ast::item_obj(?ob, ?ty_params, _)) {
|
||||
fn field_name(&ast::obj_field field) -> ident { ret field.ident; }
|
||||
ensure_unique(*e, i.span, ob.fields, field_name, "object field");
|
||||
ensure_unique_ivec(*e, i.span, ob.fields, field_name,
|
||||
"object field");
|
||||
for (@ast::method m in ob.methods) {
|
||||
check_fn(*e, m.span, m.node.meth);
|
||||
}
|
||||
ensure_unique(*e, i.span, ty_params, ident_id, "type parameter");
|
||||
ensure_unique_ivec(*e, i.span, ty_params, ident_id,
|
||||
"type parameter");
|
||||
}
|
||||
case (ast::item_tag(_, ?ty_params)) {
|
||||
ensure_unique(*e, i.span, ty_params, ident_id, "type parameter");
|
||||
ensure_unique_ivec(*e, i.span, ty_params, ident_id,
|
||||
"type parameter");
|
||||
}
|
||||
case (_) { }
|
||||
}
|
||||
|
|
@ -1315,7 +1318,7 @@ fn check_block(@env e, &ast::block b, &() x, &vt[()] v) {
|
|||
|
||||
fn check_fn(&env e, &span sp, &ast::_fn f) {
|
||||
fn arg_name(&ast::arg a) -> ident { ret a.ident; }
|
||||
ensure_unique(e, sp, f.decl.inputs, arg_name, "argument");
|
||||
ensure_unique_ivec(e, sp, f.decl.inputs, arg_name, "argument");
|
||||
}
|
||||
|
||||
type checker = @rec(mutable vec[ident] seen, str kind, session sess);
|
||||
|
|
@ -1341,6 +1344,14 @@ fn ensure_unique[T](&env e, &span sp, &vec[T] elts, fn(&T) -> ident id,
|
|||
auto ch = checker(e, kind);
|
||||
for (T elt in elts) { add_name(ch, sp, id(elt)); }
|
||||
}
|
||||
|
||||
// FIXME: Remove me.
|
||||
fn ensure_unique_ivec[T](&env e, &span sp, &T[] elts, fn(&T) -> ident id,
|
||||
&str kind) {
|
||||
auto ch = checker(e, kind);
|
||||
for (T elt in elts) { add_name(ch, sp, id(elt)); }
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
// fill-column: 78;
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ type crate_ctxt =
|
|||
type local_ctxt =
|
||||
rec(vec[str] path,
|
||||
vec[str] module_path,
|
||||
vec[ast::ty_param] obj_typarams,
|
||||
vec[ast::obj_field] obj_fields,
|
||||
ast::ty_param[] obj_typarams,
|
||||
ast::obj_field[] obj_fields,
|
||||
@crate_ctxt ccx);
|
||||
|
||||
|
||||
|
|
@ -4382,8 +4382,10 @@ fn trans_if(&@block_ctxt cx, &@ast::expr cond, &ast::block thn,
|
|||
|
||||
fn trans_for(&@block_ctxt cx, &@ast::local local, &@ast::expr seq,
|
||||
&ast::block body) -> result {
|
||||
// FIXME: We bind to an alias here to avoid a segfault... this is
|
||||
// obviously a bug.
|
||||
fn inner(&@block_ctxt cx, @ast::local local, ValueRef curr, ty::t t,
|
||||
ast::block body, @block_ctxt outer_next_cx) -> result {
|
||||
&ast::block body, @block_ctxt outer_next_cx) -> result {
|
||||
auto next_cx = new_sub_block_ctxt(cx, "next");
|
||||
auto scope_cx =
|
||||
new_loop_scope_block_ctxt(cx, option::some[@block_ctxt](next_cx),
|
||||
|
|
@ -4778,7 +4780,7 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
|
|||
cx.build.ICmp(lib::llvm::LLVMIntEQ, lldiscrim,
|
||||
C_int(variant_tag));
|
||||
cx.build.CondBr(lleq, matched_cx.llbb, next_cx.llbb);
|
||||
if (vec::len(subpats) > 0u) {
|
||||
if (std::ivec::len(subpats) > 0u) {
|
||||
llblobptr =
|
||||
matched_cx.build.GEP(lltagptr, [C_int(0), C_int(1)]);
|
||||
}
|
||||
|
|
@ -4790,7 +4792,7 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
|
|||
auto tps_ivec = ~[];
|
||||
for (ty::t tp in ty_params) { tps_ivec += ~[tp]; }
|
||||
|
||||
if (vec::len(subpats) > 0u) {
|
||||
if (std::ivec::len(subpats) > 0u) {
|
||||
auto i = 0;
|
||||
for (@ast::pat subpat in subpats) {
|
||||
auto rslt =
|
||||
|
|
@ -4834,9 +4836,11 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
|
|||
}
|
||||
}
|
||||
case (ast::pat_tag(_, ?subpats)) {
|
||||
if (vec::len[@ast::pat](subpats) == 0u) { ret rslt(cx, llval); }
|
||||
// Get the appropriate variant for this tag.
|
||||
if (std::ivec::len[@ast::pat](subpats) == 0u) {
|
||||
ret rslt(cx, llval);
|
||||
}
|
||||
|
||||
// Get the appropriate variant for this tag.
|
||||
auto vdef;
|
||||
alt (cx.fcx.lcx.ccx.tcx.def_map.find(pat.id)) {
|
||||
case (some(?x)) { vdef = ast::variant_def_ids(x); }
|
||||
|
|
@ -4874,7 +4878,7 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
|
|||
}
|
||||
}
|
||||
|
||||
fn trans_alt(&@block_ctxt cx, &@ast::expr expr, &vec[ast::arm] arms,
|
||||
fn trans_alt(&@block_ctxt cx, &@ast::expr expr, &ast::arm[] arms,
|
||||
ast::node_id id, &out_method output) -> result {
|
||||
auto expr_res = trans_expr(cx, expr);
|
||||
auto this_cx = expr_res.bcx;
|
||||
|
|
@ -5308,7 +5312,7 @@ fn trans_cast(&@block_ctxt cx, &@ast::expr e, ast::node_id id) -> result {
|
|||
}
|
||||
|
||||
fn trans_bind_thunk(&@local_ctxt cx, &span sp, &ty::t incoming_fty,
|
||||
&ty::t outgoing_fty, &vec[option::t[@ast::expr]] args,
|
||||
&ty::t outgoing_fty, &(option::t[@ast::expr])[] args,
|
||||
&ty::t closure_ty, &vec[ty::t] bound_tys,
|
||||
uint ty_param_count) -> ValueRef {
|
||||
|
||||
|
|
@ -5474,7 +5478,7 @@ fn trans_bind_thunk(&@local_ctxt cx, &span sp, &ty::t incoming_fty,
|
|||
}
|
||||
|
||||
fn trans_bind(&@block_ctxt cx, &@ast::expr f,
|
||||
&vec[option::t[@ast::expr]] args, ast::node_id id) -> result {
|
||||
&(option::t[@ast::expr])[] args, ast::node_id id) -> result {
|
||||
auto f_res = trans_lval(cx, f);
|
||||
if (f_res.is_mem) {
|
||||
cx.fcx.lcx.ccx.sess.unimpl("re-binding existing function");
|
||||
|
|
@ -5720,7 +5724,7 @@ fn trans_arg_expr(&@block_ctxt cx, &ty::arg arg, TypeRef lldestty0,
|
|||
// - trans_args
|
||||
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) ->
|
||||
&(@ast::expr)[] es, &ty::t fn_ty) ->
|
||||
tup(@block_ctxt, vec[ValueRef], ValueRef) {
|
||||
let ty::arg[] args = ty::ty_fn_args(cx.fcx.lcx.ccx.tcx, fn_ty);
|
||||
let vec[ValueRef] llargs = [];
|
||||
|
|
@ -5812,7 +5816,7 @@ fn trans_args(&@block_ctxt cx, ValueRef llenv, &option::t[ValueRef] llobj,
|
|||
}
|
||||
|
||||
fn trans_call(&@block_ctxt cx, &@ast::expr f, &option::t[ValueRef] lliterbody,
|
||||
&vec[@ast::expr] args, ast::node_id id) -> result {
|
||||
&(@ast::expr)[] args, ast::node_id id) -> result {
|
||||
// NB: 'f' isn't necessarily a function; it might be an entire self-call
|
||||
// expression because of the hack that allows us to process self-calls
|
||||
// with trans_call.
|
||||
|
|
@ -5896,8 +5900,7 @@ fn trans_call(&@block_ctxt cx, &@ast::expr f, &option::t[ValueRef] lliterbody,
|
|||
ret rslt(bcx, retval);
|
||||
}
|
||||
|
||||
fn trans_tup(&@block_ctxt cx, &vec[ast::elt] elts, ast::node_id id)
|
||||
-> result {
|
||||
fn trans_tup(&@block_ctxt cx, &ast::elt[] elts, ast::node_id id) -> result {
|
||||
auto bcx = cx;
|
||||
auto t = node_id_type(bcx.fcx.lcx.ccx, id);
|
||||
auto tup_res = alloc_ty(bcx, t);
|
||||
|
|
@ -5916,7 +5919,7 @@ fn trans_tup(&@block_ctxt cx, &vec[ast::elt] elts, ast::node_id id)
|
|||
ret rslt(bcx, tup_val);
|
||||
}
|
||||
|
||||
fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args, ast::node_id id) ->
|
||||
fn trans_vec(&@block_ctxt cx, &(@ast::expr)[] args, ast::node_id id) ->
|
||||
result {
|
||||
auto t = node_id_type(cx.fcx.lcx.ccx, id);
|
||||
auto unit_ty = t;
|
||||
|
|
@ -5928,7 +5931,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args, ast::node_id id) ->
|
|||
auto unit_sz = size_of(bcx, unit_ty);
|
||||
bcx = unit_sz.bcx;
|
||||
auto data_sz =
|
||||
bcx.build.Mul(C_int(vec::len[@ast::expr](args) as int), unit_sz.val);
|
||||
bcx.build.Mul(C_uint(std::ivec::len[@ast::expr](args)), unit_sz.val);
|
||||
// FIXME: pass tydesc properly.
|
||||
|
||||
auto vec_val =
|
||||
|
|
@ -5941,7 +5944,8 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args, ast::node_id id) ->
|
|||
auto body = bcx.build.GEP(vec_val, [C_int(0), C_int(abi::vec_elt_data)]);
|
||||
auto pseudo_tup_ty =
|
||||
ty::mk_imm_tup(cx.fcx.lcx.ccx.tcx,
|
||||
std::ivec::init_elt[ty::t](unit_ty, vec::len(args)));
|
||||
std::ivec::init_elt[ty::t](unit_ty,
|
||||
std::ivec::len(args)));
|
||||
let int i = 0;
|
||||
for (@ast::expr e in args) {
|
||||
auto src = trans_lval(bcx, e);
|
||||
|
|
@ -5975,7 +5979,7 @@ fn trans_vec(&@block_ctxt cx, &vec[@ast::expr] args, ast::node_id id) ->
|
|||
|
||||
|
||||
// TODO: Move me to ivec::
|
||||
fn trans_ivec(@block_ctxt bcx, &vec[@ast::expr] args, ast::node_id id) ->
|
||||
fn trans_ivec(@block_ctxt bcx, &(@ast::expr)[] args, ast::node_id id) ->
|
||||
result {
|
||||
auto typ = node_id_type(bcx.fcx.lcx.ccx, id);
|
||||
auto unit_ty;
|
||||
|
|
@ -5993,11 +5997,12 @@ fn trans_ivec(@block_ctxt bcx, &vec[@ast::expr] args, ast::node_id id) ->
|
|||
|
||||
add_clean_temp(bcx, llvecptr, typ);
|
||||
|
||||
auto lllen = bcx.build.Mul(C_uint(vec::len(args)), unit_sz);
|
||||
auto lllen = bcx.build.Mul(C_uint(std::ivec::len(args)), unit_sz);
|
||||
// Allocate the vector pieces and store length and allocated length.
|
||||
|
||||
auto llfirsteltptr;
|
||||
if (vec::len(args) > 0u && vec::len(args) <= abi::ivec_default_length) {
|
||||
if (std::ivec::len(args) > 0u &&
|
||||
std::ivec::len(args) <= abi::ivec_default_length) {
|
||||
// Interior case.
|
||||
|
||||
bcx.build.Store(lllen,
|
||||
|
|
@ -6022,7 +6027,7 @@ fn trans_ivec(@block_ctxt bcx, &vec[@ast::expr] args, ast::node_id id) ->
|
|||
auto llstubptr = bcx.build.PointerCast(llvecptr, T_ptr(llstubty));
|
||||
bcx.build.Store(C_int(0), bcx.build.InBoundsGEP(llstubptr, stub_z));
|
||||
auto llheapty = T_ivec_heap_part(llunitty);
|
||||
if (vec::len(args) == 0u) {
|
||||
if (std::ivec::len(args) == 0u) {
|
||||
// Null heap pointer indicates a zero-length vector.
|
||||
|
||||
bcx.build.Store(llalen, bcx.build.InBoundsGEP(llstubptr, stub_a));
|
||||
|
|
@ -6067,7 +6072,7 @@ fn trans_ivec(@block_ctxt bcx, &vec[@ast::expr] args, ast::node_id id) ->
|
|||
ret rslt(bcx, llvecptr);
|
||||
}
|
||||
|
||||
fn trans_rec(&@block_ctxt cx, &vec[ast::field] fields,
|
||||
fn trans_rec(&@block_ctxt cx, &ast::field[] fields,
|
||||
&option::t[@ast::expr] base, ast::node_id id) -> result {
|
||||
auto bcx = cx;
|
||||
auto t = node_id_type(bcx.fcx.lcx.ccx, id);
|
||||
|
|
@ -6172,7 +6177,7 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
|
|||
auto sub_cx = extend_path(cx.fcx.lcx, ccx.names.next("anon"));
|
||||
auto s = mangle_internal_name_by_path(ccx, sub_cx.path);
|
||||
auto llfn = decl_internal_fastcall_fn(ccx.llmod, s, llfnty);
|
||||
trans_fn(sub_cx, e.span, f, llfn, none, [], e.id);
|
||||
trans_fn(sub_cx, e.span, f, llfn, none, ~[], e.id);
|
||||
ret rslt(cx, create_fn_pair(ccx, s, llfnty, llfn, false));
|
||||
}
|
||||
case (ast::expr_block(?blk)) {
|
||||
|
|
@ -6696,16 +6701,17 @@ fn trans_chan(&@block_ctxt cx, &@ast::expr e, ast::node_id id) -> result {
|
|||
}
|
||||
|
||||
fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
|
||||
&@ast::expr func, &vec[@ast::expr] args, ast::node_id id) ->
|
||||
result {
|
||||
&@ast::expr func, &(@ast::expr)[] args, ast::node_id id)
|
||||
-> result {
|
||||
auto bcx = cx;
|
||||
// Make the task name
|
||||
|
||||
auto tname =
|
||||
alt (name) {
|
||||
case (none) {
|
||||
auto argss = vec::map(expr_to_str, args);
|
||||
#fmt("%s(%s)", expr_to_str(func), str::connect(argss, ", "))
|
||||
auto argss = std::ivec::map(expr_to_str, args);
|
||||
#fmt("%s(%s)", expr_to_str(func),
|
||||
str::connect_ivec(argss, ", "))
|
||||
}
|
||||
case (some(?n)) { n }
|
||||
};
|
||||
|
|
@ -6979,7 +6985,7 @@ fn recv_val(&@block_ctxt cx, ValueRef to, &@ast::expr from, &ty::t unit_ty,
|
|||
// instead "inlining" the construction of the object and returning the object
|
||||
// itself.
|
||||
fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||
&vec[ast::ty_param] ty_params, ast::node_id id) -> result {
|
||||
&ast::ty_param[] ty_params, ast::node_id id) -> result {
|
||||
|
||||
// Right now, we're assuming that anon objs don't take ty params, even
|
||||
// though the AST supports it. It's nonsensical to write an expression
|
||||
|
|
@ -6987,13 +6993,13 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
|||
// nevertheless, such an expression will parse. Idea for the future:
|
||||
// support typarams.
|
||||
|
||||
assert (vec::len(ty_params) == 0u);
|
||||
assert (std::ivec::len(ty_params) == 0u);
|
||||
auto ccx = bcx.fcx.lcx.ccx;
|
||||
|
||||
// Fields.
|
||||
// FIXME (part of issue #538): Where do we fill in the field *values* from
|
||||
// the outer object?
|
||||
let vec[ast::anon_obj_field] additional_fields = [];
|
||||
let ast::anon_obj_field[] additional_fields = ~[];
|
||||
let vec[result] additional_field_vals = [];
|
||||
let ty::t[] additional_field_tys = ~[];
|
||||
alt (anon_obj.fields) {
|
||||
|
|
@ -7021,8 +7027,8 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
|||
ret rec(mut=f.mut, ty=f.ty, ident=f.ident, id=f.id);
|
||||
}
|
||||
let ast::_obj wrapper_obj = rec(
|
||||
fields = vec::map(anon_obj_field_to_obj_field,
|
||||
additional_fields),
|
||||
fields = std::ivec::map(anon_obj_field_to_obj_field,
|
||||
additional_fields),
|
||||
methods = anon_obj.methods,
|
||||
dtor = none[@ast::method]);
|
||||
|
||||
|
|
@ -7079,8 +7085,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
|||
auto pair =
|
||||
alloca(bcx,
|
||||
T_struct([val_ty(vtbl),
|
||||
T_obj_ptr(ccx.tn,
|
||||
vec::len[ast::ty_param](ty_params))]));
|
||||
T_obj_ptr(ccx.tn, std::ivec::len(ty_params))]));
|
||||
|
||||
// Take care of cleanups.
|
||||
auto t = node_id_type(ccx, id);
|
||||
|
|
@ -7101,8 +7106,8 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
|||
// typarams, fields, and a pointer to our with_obj.
|
||||
let TypeRef llbox_ty = T_opaque_obj_ptr(ccx.tn);
|
||||
|
||||
if (vec::len[ast::ty_param](ty_params) == 0u &&
|
||||
vec::len[ast::anon_obj_field](additional_fields) == 0u &&
|
||||
if (std::ivec::len[ast::ty_param](ty_params) == 0u &&
|
||||
std::ivec::len[ast::anon_obj_field](additional_fields) == 0u &&
|
||||
anon_obj.with_obj == none) {
|
||||
// If the object we're translating has no fields or type parameters
|
||||
// and no with_obj, there's not much to do.
|
||||
|
|
@ -7544,12 +7549,10 @@ fn trans_block(&@block_ctxt cx, &ast::block b, &out_method output) -> result {
|
|||
|
||||
fn new_local_ctxt(&@crate_ctxt ccx) -> @local_ctxt {
|
||||
let vec[str] pth = [];
|
||||
let vec[ast::ty_param] obj_typarams = [];
|
||||
let vec[ast::obj_field] obj_fields = [];
|
||||
ret @rec(path=pth,
|
||||
module_path=[ccx.link_meta.name],
|
||||
obj_typarams=obj_typarams,
|
||||
obj_fields=obj_fields,
|
||||
obj_typarams=~[],
|
||||
obj_fields=~[],
|
||||
ccx=ccx);
|
||||
}
|
||||
|
||||
|
|
@ -7621,8 +7624,8 @@ fn new_fn_ctxt(@local_ctxt cx, &span sp, ValueRef llfndecl) -> @fn_ctxt {
|
|||
// field of the fn_ctxt with
|
||||
fn create_llargs_for_fn_args(&@fn_ctxt cx, ast::proto proto,
|
||||
option::t[ty_self_pair] ty_self, ty::t ret_ty,
|
||||
&vec[ast::arg] args,
|
||||
&vec[ast::ty_param] ty_params) {
|
||||
&ast::arg[] args,
|
||||
&ast::ty_param[] ty_params) {
|
||||
// Skip the implicit arguments 0, 1, and 2. TODO: Pull out 3u and define
|
||||
// it as a constant, since we're using it in several places in trans this
|
||||
// way.
|
||||
|
|
@ -7684,8 +7687,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,
|
||||
&ty::arg[] arg_tys) {
|
||||
fn copy_args_to_allocas(@fn_ctxt fcx, &ast::arg[] args, &ty::arg[] arg_tys) {
|
||||
auto bcx = new_raw_block_ctxt(fcx, fcx.llcopyargs);
|
||||
let uint arg_n = 0u;
|
||||
for (ast::arg aarg in args) {
|
||||
|
|
@ -7707,7 +7709,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,
|
||||
fn add_cleanups_for_args(&@block_ctxt bcx, &ast::arg[] args,
|
||||
&ty::arg[] arg_tys) {
|
||||
let uint arg_n = 0u;
|
||||
for (ast::arg aarg in args) {
|
||||
|
|
@ -7745,7 +7747,7 @@ fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, val_self_pair llself) {
|
|||
// its magic.
|
||||
|
||||
auto fields_tup_ty = ty::mk_imm_tup(fcx.lcx.ccx.tcx, field_tys);
|
||||
auto n_typarams = vec::len[ast::ty_param](bcx.fcx.lcx.obj_typarams);
|
||||
auto n_typarams = std::ivec::len[ast::ty_param](bcx.fcx.lcx.obj_typarams);
|
||||
let TypeRef llobj_box_ty = T_obj_ptr(bcx.fcx.lcx.ccx.tn, n_typarams);
|
||||
auto box_cell =
|
||||
bcx.build.GEP(llself.v, [C_int(0), C_int(abi::obj_field_box)]);
|
||||
|
|
@ -7801,7 +7803,7 @@ fn finish_fn(&@fn_ctxt fcx, BasicBlockRef lltop) {
|
|||
// trans_fn: creates an LLVM function corresponding to a source language
|
||||
// function.
|
||||
fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ValueRef llfndecl,
|
||||
option::t[ty_self_pair] ty_self, &vec[ast::ty_param] ty_params,
|
||||
option::t[ty_self_pair] ty_self, &ast::ty_param[] ty_params,
|
||||
ast::node_id id) {
|
||||
set_uwtable(llfndecl);
|
||||
|
||||
|
|
@ -7847,11 +7849,11 @@ fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ValueRef llfndecl,
|
|||
// process_fwding_mthd: Create the forwarding function that appears in a
|
||||
// vtable slot for method calls that "fall through" to an inner object. A
|
||||
// helper function for create_vtbl.
|
||||
fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
||||
fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
||||
TypeRef llself_ty, ty::t self_ty,
|
||||
&vec[ast::ty_param] ty_params,
|
||||
&ast::ty_param[] ty_params,
|
||||
ty::t with_obj_ty,
|
||||
ty::t[] additional_field_tys) -> ValueRef {
|
||||
&ty::t[] additional_field_tys) -> ValueRef {
|
||||
|
||||
// NB: self_ty (and llself_ty) is the type of the outer object;
|
||||
// with_obj_ty is the type of the inner object.
|
||||
|
|
@ -7880,7 +7882,7 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
|||
type_of_fn_full(
|
||||
cx.ccx, sp, m.proto,
|
||||
some[TypeRef](llself_ty), m.inputs, m.output,
|
||||
vec::len[ast::ty_param](ty_params));
|
||||
std::ivec::len[ast::ty_param](ty_params));
|
||||
let ValueRef llforwarding_fn =
|
||||
decl_internal_fastcall_fn(cx.ccx.llmod, s, llforwarding_fn_ty);
|
||||
|
||||
|
|
@ -7997,7 +7999,7 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
|||
some[TypeRef](llself_ty),
|
||||
m.inputs,
|
||||
m.output,
|
||||
vec::len[ast::ty_param](ty_params));
|
||||
std::ivec::len[ast::ty_param](ty_params));
|
||||
llorig_mthd = bcx.build.PointerCast(llorig_mthd,
|
||||
T_ptr(T_ptr(llorig_mthd_ty)));
|
||||
llorig_mthd = bcx.build.Load(llorig_mthd);
|
||||
|
|
@ -8032,7 +8034,7 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
|||
// process_normal_mthd: Create the contents of a normal vtable slot. A helper
|
||||
// function for create_vtbl.
|
||||
fn process_normal_mthd(@local_ctxt cx, @ast::method m, TypeRef llself_ty,
|
||||
ty::t self_ty, &vec[ast::ty_param] ty_params)
|
||||
ty::t self_ty, &ast::ty_param[] ty_params)
|
||||
-> ValueRef {
|
||||
|
||||
auto llfnty = T_nil();
|
||||
|
|
@ -8042,7 +8044,7 @@ fn process_normal_mthd(@local_ctxt cx, @ast::method m, TypeRef llself_ty,
|
|||
type_of_fn_full(
|
||||
cx.ccx, m.span, proto,
|
||||
some[TypeRef](llself_ty), inputs, output,
|
||||
vec::len[ast::ty_param](ty_params));
|
||||
std::ivec::len[ast::ty_param](ty_params));
|
||||
}
|
||||
}
|
||||
let @local_ctxt mcx =
|
||||
|
|
@ -8066,9 +8068,9 @@ fn process_normal_mthd(@local_ctxt cx, @ast::method m, TypeRef llself_ty,
|
|||
// Create a vtable for an object being translated. Returns a pointer into
|
||||
// read-only memory.
|
||||
fn create_vtbl(@local_ctxt cx, &span sp, TypeRef llself_ty, ty::t self_ty,
|
||||
&ast::_obj ob, &vec[ast::ty_param] ty_params,
|
||||
&ast::_obj ob, &ast::ty_param[] ty_params,
|
||||
option::t[ty::t] with_obj_ty,
|
||||
ty::t[] additional_field_tys) -> ValueRef {
|
||||
&ty::t[] additional_field_tys) -> ValueRef {
|
||||
|
||||
// Used only inside create_vtbl to distinguish different kinds of slots
|
||||
// we'll have to create.
|
||||
|
|
@ -8232,7 +8234,7 @@ fn create_vtbl(@local_ctxt cx, &span sp, TypeRef llself_ty, ty::t self_ty,
|
|||
}
|
||||
|
||||
fn trans_dtor(@local_ctxt cx, TypeRef llself_ty, ty::t self_ty,
|
||||
&vec[ast::ty_param] ty_params, &@ast::method dtor) -> ValueRef {
|
||||
&ast::ty_param[] ty_params, &@ast::method dtor) -> ValueRef {
|
||||
auto llfnty = T_dtor(cx.ccx, dtor.span, llself_ty);
|
||||
let str s = mangle_internal_name_by_path(cx.ccx, cx.path + ["drop"]);
|
||||
let ValueRef llfn = decl_internal_fastcall_fn(cx.ccx.llmod, s, llfnty);
|
||||
|
|
@ -8247,7 +8249,7 @@ fn trans_dtor(@local_ctxt cx, TypeRef llself_ty, ty::t self_ty,
|
|||
// trans_obj: creates an LLVM function that is the object constructor for the
|
||||
// object being translated.
|
||||
fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
|
||||
&vec[ast::ty_param] ty_params) {
|
||||
&ast::ty_param[] ty_params) {
|
||||
// To make a function, we have to create a function context and, inside
|
||||
// that, a number of block contexts for which code is generated.
|
||||
|
||||
|
|
@ -8265,10 +8267,10 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
|
|||
// The fields of our object will become the arguments to the function
|
||||
// we're creating.
|
||||
|
||||
let vec[ast::arg] fn_args = [];
|
||||
let ast::arg[] fn_args = ~[];
|
||||
for (ast::obj_field f in ob.fields) {
|
||||
fn_args +=
|
||||
[rec(mode=ast::alias(false), ty=f.ty, ident=f.ident, id=f.id)];
|
||||
~[rec(mode=ast::alias(false), ty=f.ty, ident=f.ident, id=f.id)];
|
||||
}
|
||||
auto fcx = new_fn_ctxt(cx, sp, llctor_decl);
|
||||
|
||||
|
|
@ -8325,7 +8327,7 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
|
|||
// FIXME: we should probably also allocate a box for empty objs that have
|
||||
// a dtor, since otherwise they are never dropped, and the dtor never
|
||||
// runs.
|
||||
if (vec::len[ast::ty_param](ty_params) == 0u &&
|
||||
if (std::ivec::len[ast::ty_param](ty_params) == 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.
|
||||
|
|
@ -8449,7 +8451,7 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
|
|||
}
|
||||
|
||||
fn trans_res_ctor(@local_ctxt cx, &span sp, &ast::_fn dtor,
|
||||
ast::node_id ctor_id, &vec[ast::ty_param] ty_params) {
|
||||
ast::node_id ctor_id, &ast::ty_param[] ty_params) {
|
||||
// Create a function for the constructor
|
||||
auto llctor_decl;
|
||||
alt (cx.ccx.item_ids.find(ctor_id)) {
|
||||
|
|
@ -8493,21 +8495,21 @@ fn trans_res_ctor(@local_ctxt cx, &span sp, &ast::_fn dtor,
|
|||
|
||||
fn trans_tag_variant(@local_ctxt cx, ast::node_id tag_id,
|
||||
&ast::variant variant, int index, bool is_degen,
|
||||
&vec[ast::ty_param] ty_params) {
|
||||
&ast::ty_param[] ty_params) {
|
||||
if (vec::len[ast::variant_arg](variant.node.args) == 0u) {
|
||||
ret; // nullary constructors are just constants
|
||||
|
||||
}
|
||||
// Translate variant arguments to function arguments.
|
||||
|
||||
let vec[ast::arg] fn_args = [];
|
||||
let ast::arg[] fn_args = ~[];
|
||||
auto i = 0u;
|
||||
for (ast::variant_arg varg in variant.node.args) {
|
||||
fn_args +=
|
||||
[rec(mode=ast::alias(false),
|
||||
ty=varg.ty,
|
||||
ident="arg" + uint::to_str(i, 10u),
|
||||
id=varg.id)];
|
||||
~[rec(mode=ast::alias(false),
|
||||
ty=varg.ty,
|
||||
ident="arg" + uint::to_str(i, 10u),
|
||||
id=varg.id)];
|
||||
}
|
||||
assert (cx.ccx.item_ids.contains_key(variant.node.id));
|
||||
let ValueRef llfndecl;
|
||||
|
|
@ -8650,7 +8652,7 @@ fn trans_item(@local_ctxt cx, &ast::item item) {
|
|||
}
|
||||
case (ast::item_tag(?variants, ?tps)) {
|
||||
auto sub_cx = extend_path(cx, item.ident);
|
||||
auto degen = vec::len(variants) == 1u;
|
||||
auto degen = std::ivec::len(variants) == 1u;
|
||||
auto i = 0;
|
||||
for (ast::variant variant in variants) {
|
||||
trans_tag_variant(sub_cx, item.id, variant, i, degen, tps);
|
||||
|
|
@ -8681,20 +8683,20 @@ fn get_pair_fn_ty(TypeRef llpairty) -> TypeRef {
|
|||
}
|
||||
|
||||
fn decl_fn_and_pair(&@crate_ctxt ccx, &span sp, &vec[str] path, str flav,
|
||||
vec[ast::ty_param] ty_params, ast::node_id node_id) {
|
||||
&ast::ty_param[] ty_params, ast::node_id node_id) {
|
||||
decl_fn_and_pair_full(ccx, sp, path, flav, ty_params, node_id,
|
||||
node_id_type(ccx, node_id));
|
||||
}
|
||||
|
||||
fn decl_fn_and_pair_full(&@crate_ctxt ccx, &span sp, &vec[str] path, str flav,
|
||||
vec[ast::ty_param] ty_params, ast::node_id node_id,
|
||||
&ast::ty_param[] ty_params, ast::node_id node_id,
|
||||
ty::t node_type) {
|
||||
auto llfty;
|
||||
alt (ty::struct(ccx.tcx, node_type)) {
|
||||
case (ty::ty_fn(?proto, ?inputs, ?output, _, _)) {
|
||||
llfty =
|
||||
type_of_fn(ccx, sp, proto, inputs, output,
|
||||
vec::len[ast::ty_param](ty_params));
|
||||
std::ivec::len[ast::ty_param](ty_params));
|
||||
}
|
||||
case (_) {
|
||||
ccx.sess.bug("decl_fn_and_pair(): fn item doesn't have fn type!");
|
||||
|
|
@ -8764,7 +8766,7 @@ fn native_fn_ty_param_count(&@crate_ctxt cx, ast::node_id id) -> uint {
|
|||
"actually a fn");
|
||||
}
|
||||
case (ast::native_item_fn(_, _, ?tps)) {
|
||||
count = vec::len[ast::ty_param](tps);
|
||||
count = std::ivec::len[ast::ty_param](tps);
|
||||
}
|
||||
}
|
||||
ret count;
|
||||
|
|
@ -9035,7 +9037,7 @@ fn trans_constant(@crate_ctxt ccx, &@ast::item it, &vec[str] pt,
|
|||
alt (it.node) {
|
||||
case (ast::item_tag(?variants, _)) {
|
||||
auto i = 0u;
|
||||
auto n_variants = vec::len[ast::variant](variants);
|
||||
auto n_variants = std::ivec::len[ast::variant](variants);
|
||||
while (i < n_variants) {
|
||||
auto variant = variants.(i);
|
||||
auto p = new_pt + [it.ident, variant.node.name, "discrim"];
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ fn collect_ids_local(&@local l, @mutable node_id[] rs) {
|
|||
*rs += ~[l.node.id];
|
||||
}
|
||||
|
||||
fn node_ids_in_fn(&_fn f, &vec[ty_param] tps, &span sp, &fn_ident i,
|
||||
fn node_ids_in_fn(&_fn f, &ty_param[] tps, &span sp, &fn_ident i,
|
||||
node_id id, @mutable node_id[] rs) {
|
||||
auto collect_ids = walk::default_visitor();
|
||||
collect_ids =
|
||||
|
|
@ -70,7 +70,7 @@ fn init_vecs(&crate_ctxt ccx, &node_id[] node_ids, uint len) {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_fn(&crate_ctxt ccx, uint num_constraints, &_fn f, &vec[ty_param] tps,
|
||||
fn visit_fn(&crate_ctxt ccx, uint num_constraints, &_fn f, &ty_param[] tps,
|
||||
&span sp, &fn_ident i, node_id id) {
|
||||
let @mutable node_id[] node_ids = @mutable ~[];
|
||||
node_ids_in_fn(f, tps, sp, i, id, node_ids);
|
||||
|
|
@ -78,7 +78,7 @@ fn visit_fn(&crate_ctxt ccx, uint num_constraints, &_fn f, &vec[ty_param] tps,
|
|||
init_vecs(ccx, node_id_vec, num_constraints);
|
||||
}
|
||||
|
||||
fn annotate_in_fn(&crate_ctxt ccx, &_fn f, &vec[ty_param] tps,
|
||||
fn annotate_in_fn(&crate_ctxt ccx, &_fn f, &ty_param[] tps,
|
||||
&span sp, &fn_ident i, node_id id) {
|
||||
auto f_info = get_fn_info(ccx, id);
|
||||
visit_fn(ccx, num_constraints(f_info), f, tps, sp, i, id);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ fn check_states_stmt(&fn_ctxt fcx, &@stmt s) {
|
|||
}
|
||||
|
||||
fn check_states_against_conditions(&fn_ctxt fcx, &_fn f,
|
||||
&vec[ast::ty_param] tps,
|
||||
&ast::ty_param[] tps,
|
||||
node_id id, &span sp, &fn_ident i) {
|
||||
/* Postorder traversal instead of pre is important
|
||||
because we want the smallest possible erroneous statement
|
||||
|
|
@ -176,7 +176,7 @@ fn check_states_against_conditions(&fn_ctxt fcx, &_fn f,
|
|||
check_unused_vars(fcx);
|
||||
}
|
||||
|
||||
fn check_fn_states(&fn_ctxt fcx, &_fn f, &vec[ast::ty_param] tps,
|
||||
fn check_fn_states(&fn_ctxt fcx, &_fn f, &ast::ty_param[] tps,
|
||||
node_id id, &span sp, &fn_ident i) {
|
||||
/* Compute the pre- and post-states for this function */
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ fn check_fn_states(&fn_ctxt fcx, &_fn f, &vec[ast::ty_param] tps,
|
|||
check_states_against_conditions(fcx, f, tps, id, sp, i);
|
||||
}
|
||||
|
||||
fn fn_states(&crate_ctxt ccx, &_fn f, &vec[ast::ty_param] tps,
|
||||
fn fn_states(&crate_ctxt ccx, &_fn f, &ast::ty_param[] tps,
|
||||
&span sp, &fn_ident i, node_id id) {
|
||||
/* Look up the var-to-bit-num map for this function */
|
||||
|
||||
|
|
|
|||
|
|
@ -64,13 +64,12 @@ fn collect_pred(&@expr e, &ctxt cx, &visit::vt[ctxt] v) {
|
|||
visit::visit_expr(e, cx, v);
|
||||
}
|
||||
|
||||
fn do_nothing(&_fn f, &vec[ty_param] tp, &span sp, &fn_ident i,
|
||||
fn do_nothing(&_fn f, &ty_param[] tp, &span sp, &fn_ident i,
|
||||
node_id iid, &ctxt cx, &visit::vt[ctxt] v) {
|
||||
}
|
||||
|
||||
fn find_locals(&ty::ctxt tcx, &_fn f, &vec[ty_param] tps,
|
||||
&span sp, &fn_ident i, node_id id)
|
||||
-> ctxt {
|
||||
fn find_locals(&ty::ctxt tcx, &_fn f, &ty_param[] tps, &span sp, &fn_ident i,
|
||||
node_id id) -> ctxt {
|
||||
let ctxt cx = rec(cs=@mutable ~[], tcx=tcx);
|
||||
auto visitor = visit::default_visitor[ctxt]();
|
||||
|
||||
|
|
@ -118,9 +117,8 @@ fn add_constraint(&ty::ctxt tcx, aux::constr c, uint next, constr_map tbl) ->
|
|||
|
||||
/* builds a table mapping each local var defined in f
|
||||
to a bit number in the precondition/postcondition vectors */
|
||||
fn mk_fn_info(&crate_ctxt ccx, &_fn f, &vec[ty_param] tp,
|
||||
&span f_sp, &fn_ident f_name,
|
||||
node_id id) {
|
||||
fn mk_fn_info(&crate_ctxt ccx, &_fn f, &ty_param[] tp,
|
||||
&span f_sp, &fn_ident f_name, node_id id) {
|
||||
auto res_map = @new_int_hash[constraint]();
|
||||
let uint next = 0u;
|
||||
|
||||
|
|
|
|||
|
|
@ -102,9 +102,8 @@ fn find_pre_post_obj(&crate_ctxt ccx, _obj o) {
|
|||
ccx=ccx);
|
||||
find_pre_post_fn(fcx, m.node.meth);
|
||||
}
|
||||
auto f = bind do_a_method(ccx, _);
|
||||
vec::map[@method, ()](f, o.methods);
|
||||
option::map[@method, ()](f, o.dtor);
|
||||
for (@method m in o.methods) { do_a_method(ccx, m); }
|
||||
option::map[@method, ()](bind do_a_method(ccx, _), o.dtor);
|
||||
}
|
||||
|
||||
fn find_pre_post_item(&crate_ctxt ccx, &item i) {
|
||||
|
|
@ -151,26 +150,21 @@ fn find_pre_post_item(&crate_ctxt ccx, &item i) {
|
|||
sets the precondition in a to be the result of combining
|
||||
the preconditions for <args>, and the postcondition in a to
|
||||
be the union of all postconditions for <args> */
|
||||
fn find_pre_post_exprs(&fn_ctxt fcx, &vec[@expr] args, node_id id) {
|
||||
if (vec::len[@expr](args) > 0u) {
|
||||
fn find_pre_post_exprs(&fn_ctxt fcx, &(@expr)[] args, node_id id) {
|
||||
if (ivec::len[@expr](args) > 0u) {
|
||||
log "find_pre_post_exprs: oper =";
|
||||
log_expr(*args.(0));
|
||||
}
|
||||
fn do_one(fn_ctxt fcx, &@expr e) { find_pre_post_expr(fcx, e); }
|
||||
auto f = bind do_one(fcx, _);
|
||||
vec::map[@expr, ()](f, args);
|
||||
for (@expr e in args) { do_one(fcx, e); }
|
||||
|
||||
fn get_pp(crate_ctxt ccx, &@expr e) -> pre_and_post {
|
||||
ret expr_pp(ccx, e);
|
||||
}
|
||||
auto g = bind get_pp(fcx.ccx, _);
|
||||
auto pps = vec::map[@expr, pre_and_post](g, args);
|
||||
auto pps = ivec::map[@expr, pre_and_post](bind get_pp(fcx.ccx, _), args);
|
||||
|
||||
// TODO: Remove this vec->ivec conversion.
|
||||
auto pps_ivec = ~[];
|
||||
for (pre_and_post pp in pps) { pps_ivec += ~[pp]; }
|
||||
|
||||
set_pre_and_post(fcx.ccx, id, seq_preconds(fcx, pps_ivec),
|
||||
seq_postconds(fcx, ivec::map(get_post, pps_ivec)));
|
||||
set_pre_and_post(fcx.ccx, id, seq_preconds(fcx, pps),
|
||||
seq_postconds(fcx, ivec::map(get_post, pps)));
|
||||
}
|
||||
|
||||
fn find_pre_post_loop(&fn_ctxt fcx, &@local l, &@expr index, &block body,
|
||||
|
|
@ -264,10 +258,10 @@ fn gen_if_local(&fn_ctxt fcx, @expr lhs, @expr rhs, node_id larger_id,
|
|||
rec(id=d_id._1,
|
||||
c=ninit(path_to_ident(fcx.ccx.tcx, pth))));
|
||||
}
|
||||
case (_) { find_pre_post_exprs(fcx, [lhs, rhs], larger_id); }
|
||||
case (_) { find_pre_post_exprs(fcx, ~[lhs, rhs], larger_id); }
|
||||
}
|
||||
}
|
||||
case (_) { find_pre_post_exprs(fcx, [lhs, rhs], larger_id); }
|
||||
case (_) { find_pre_post_exprs(fcx, ~[lhs, rhs], larger_id); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -280,12 +274,8 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
|
||||
alt (e.node) {
|
||||
case (expr_call(?operator, ?operands)) {
|
||||
auto args = vec::clone(operands);
|
||||
vec::push(args, operator);
|
||||
|
||||
// TODO: Remove this vec->ivec conversion.
|
||||
auto operands_ivec = ~[];
|
||||
for (@expr e in operands) { operands_ivec += ~[e]; }
|
||||
auto args = /* copy */ operands;
|
||||
args += ~[operator];
|
||||
|
||||
find_pre_post_exprs(fcx, args, e.id);
|
||||
/* see if the call has any constraints on its type */
|
||||
|
|
@ -295,8 +285,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
bit_num(fcx,
|
||||
rec(id=c.node.id._1,
|
||||
c=substitute_constr_args(fcx.ccx.tcx,
|
||||
operands_ivec,
|
||||
c)));
|
||||
args, c)));
|
||||
require(i, expr_pp(fcx.ccx, e));
|
||||
}
|
||||
|
||||
|
|
@ -307,8 +296,8 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
}
|
||||
}
|
||||
case (expr_spawn(_, _, ?operator, ?operands)) {
|
||||
auto args = vec::clone(operands);
|
||||
vec::push(args, operator);
|
||||
auto args = /* copy */ operands;
|
||||
args += ~[operator];
|
||||
find_pre_post_exprs(fcx, args, e.id);
|
||||
}
|
||||
case (expr_vec(?args, _, _)) {
|
||||
|
|
@ -359,7 +348,10 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
}
|
||||
case (expr_rec(?fields, ?maybe_base)) {
|
||||
auto es = field_exprs(fields);
|
||||
vec::plus_option(es, maybe_base);
|
||||
alt (maybe_base) {
|
||||
case (none) { /* no-op */ }
|
||||
case (some(?b)) { es += ~[b]; }
|
||||
}
|
||||
find_pre_post_exprs(fcx, es, e.id);
|
||||
}
|
||||
case (expr_move(?lhs, ?rhs)) {
|
||||
|
|
@ -367,7 +359,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
case (expr_path(?p)) {
|
||||
gen_if_local(fcx, lhs, rhs, e.id, lhs.id, p);
|
||||
}
|
||||
case (_) { find_pre_post_exprs(fcx, [lhs, rhs], e.id); }
|
||||
case (_) { find_pre_post_exprs(fcx, ~[lhs, rhs], e.id); }
|
||||
}
|
||||
if (is_path(rhs)) {
|
||||
forget_in_postcond(fcx, e.id, rhs.id);
|
||||
|
|
@ -375,7 +367,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
}
|
||||
case (expr_swap(?lhs, ?rhs)) {
|
||||
// Both sides must already be initialized
|
||||
find_pre_post_exprs(fcx, [lhs, rhs], e.id);
|
||||
find_pre_post_exprs(fcx, ~[lhs, rhs], e.id);
|
||||
forget_in_postcond_still_init(fcx, e.id, lhs.id);
|
||||
forget_in_postcond_still_init(fcx, e.id, rhs.id);
|
||||
// Could be more precise and swap the roles of lhs and rhs
|
||||
|
|
@ -387,7 +379,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
gen_if_local(fcx, lhs, rhs, e.id, lhs.id, p);
|
||||
forget_in_postcond_still_init(fcx, e.id, lhs.id);
|
||||
}
|
||||
case (_) { find_pre_post_exprs(fcx, [lhs, rhs], e.id); }
|
||||
case (_) { find_pre_post_exprs(fcx, ~[lhs, rhs], e.id); }
|
||||
}
|
||||
}
|
||||
case (expr_recv(?lhs, ?rhs)) {
|
||||
|
|
@ -400,7 +392,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
// doesn't check that rhs is an lval, but
|
||||
// that's probably ok
|
||||
|
||||
find_pre_post_exprs(fcx, [lhs, rhs], e.id);
|
||||
find_pre_post_exprs(fcx, ~[lhs, rhs], e.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -408,7 +400,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
/* Different from expr_assign in that the lhs *must*
|
||||
already be initialized */
|
||||
|
||||
find_pre_post_exprs(fcx, [lhs, rhs], e.id);
|
||||
find_pre_post_exprs(fcx, ~[lhs, rhs], e.id);
|
||||
forget_in_postcond_still_init(fcx, e.id, lhs.id);
|
||||
}
|
||||
case (expr_lit(_)) { clear_pp(expr_pp(fcx.ccx, e)); }
|
||||
|
|
@ -449,11 +441,11 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
expr_postcond(fcx.ccx, l));
|
||||
}
|
||||
else {
|
||||
find_pre_post_exprs(fcx, [l, r], e.id);
|
||||
find_pre_post_exprs(fcx, ~[l, r], e.id);
|
||||
}
|
||||
}
|
||||
case (expr_send(?l, ?r)) {
|
||||
find_pre_post_exprs(fcx, [l, r], e.id);
|
||||
find_pre_post_exprs(fcx, ~[l, r], e.id);
|
||||
}
|
||||
case (expr_unary(_, ?operand)) {
|
||||
find_pre_post_expr(fcx, operand);
|
||||
|
|
@ -497,7 +489,7 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
find_pre_post_loop(fcx, d, index, body, e.id);
|
||||
}
|
||||
case (expr_index(?val, ?sub)) {
|
||||
find_pre_post_exprs(fcx, [val, sub], e.id);
|
||||
find_pre_post_exprs(fcx, ~[val, sub], e.id);
|
||||
}
|
||||
case (expr_alt(?ex, ?alts)) {
|
||||
find_pre_post_expr(fcx, ex);
|
||||
|
|
@ -505,8 +497,8 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
find_pre_post_block(fcx, an_alt.block);
|
||||
ret block_pp(fcx.ccx, an_alt.block);
|
||||
}
|
||||
auto f = bind do_an_alt(fcx, _);
|
||||
auto alt_pps = vec::map[arm, pre_and_post](f, alts);
|
||||
auto alt_pps = [];
|
||||
for (arm a in alts) { alt_pps += [do_an_alt(fcx, a)]; }
|
||||
fn combine_pp(pre_and_post antec, fn_ctxt fcx, &pre_and_post pp,
|
||||
&pre_and_post next) -> pre_and_post {
|
||||
union(pp.precondition, seq_preconds(fcx, ~[antec, next]));
|
||||
|
|
@ -559,8 +551,14 @@ fn find_pre_post_expr(&fn_ctxt fcx, @expr e) {
|
|||
}
|
||||
|
||||
case (expr_bind(?operator, ?maybe_args)) {
|
||||
auto args = vec::cat_options[@expr](maybe_args);
|
||||
vec::push[@expr](args, operator); /* ??? order of eval? */
|
||||
auto args = ~[];
|
||||
for (option::t[@expr] expr_opt in maybe_args) {
|
||||
alt (expr_opt) {
|
||||
case (none) { /* no-op */ }
|
||||
case (some(?expr)) { args += ~[expr]; }
|
||||
}
|
||||
}
|
||||
args += ~[operator]; /* ??? order of eval? */
|
||||
|
||||
find_pre_post_exprs(fcx, args, e.id);
|
||||
}
|
||||
|
|
@ -659,8 +657,7 @@ fn find_pre_post_block(&fn_ctxt fcx, block b) {
|
|||
log "is:";
|
||||
log_pp(stmt_pp(fcx.ccx, *s));
|
||||
}
|
||||
auto do_one = bind do_one_(fcx, _);
|
||||
vec::map[@stmt, ()](do_one, b.node.stmts);
|
||||
for (@stmt s in b.node.stmts) { do_one_(fcx, s); }
|
||||
fn do_inner_(fn_ctxt fcx, &@expr e) { find_pre_post_expr(fcx, e); }
|
||||
auto do_inner = bind do_inner_(fcx, _);
|
||||
option::map[@expr, ()](do_inner, b.node.expr);
|
||||
|
|
@ -705,7 +702,7 @@ fn find_pre_post_fn(&fn_ctxt fcx, &_fn f) {
|
|||
}
|
||||
}
|
||||
|
||||
fn fn_pre_post(crate_ctxt ccx, &_fn f, &vec[ty_param] tps,
|
||||
fn fn_pre_post(crate_ctxt ccx, &_fn f, &ty_param[] tps,
|
||||
&span sp, &fn_ident i, node_id id) {
|
||||
assert (ccx.fm.contains_key(id));
|
||||
auto fcx = rec(enclosing=ccx.fm.get(id), id=id,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import std::ivec;
|
||||
import std::vec;
|
||||
import std::vec::plus_option;
|
||||
import std::vec::cat_options;
|
||||
|
|
@ -100,7 +101,7 @@ tag oper_type {
|
|||
oper_pure;
|
||||
}
|
||||
|
||||
fn seq_states(&fn_ctxt fcx, prestate pres, vec[@expr] exprs) ->
|
||||
fn seq_states(&fn_ctxt fcx, prestate pres, &(@expr)[] exprs) ->
|
||||
tup(bool, poststate) {
|
||||
auto changed = false;
|
||||
auto post = pres;
|
||||
|
|
@ -162,7 +163,7 @@ fn find_pre_post_state_two(&fn_ctxt fcx, &prestate pres, &@expr a, &@expr b,
|
|||
}
|
||||
|
||||
fn find_pre_post_state_call(&fn_ctxt fcx, &prestate pres, &@expr a,
|
||||
node_id id, &vec[@expr] bs,
|
||||
node_id id, &(@expr)[] bs,
|
||||
controlflow cf) -> bool {
|
||||
auto changed = find_pre_post_state_expr(fcx, pres, a);
|
||||
ret find_pre_post_state_exprs(fcx,
|
||||
|
|
@ -170,7 +171,7 @@ fn find_pre_post_state_call(&fn_ctxt fcx, &prestate pres, &@expr a,
|
|||
}
|
||||
|
||||
fn find_pre_post_state_exprs(&fn_ctxt fcx, &prestate pres, node_id id,
|
||||
&vec[@expr] es, controlflow cf) -> bool {
|
||||
&(@expr)[] es, controlflow cf) -> bool {
|
||||
auto rs = seq_states(fcx, pres, es);
|
||||
auto changed = rs._0 | set_prestate_ann(fcx.ccx, id, pres);
|
||||
/* if this is a failing call, it sets everything as initialized */
|
||||
|
|
@ -313,8 +314,16 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
|
|||
return);
|
||||
}
|
||||
case (expr_bind(?operator, ?maybe_args)) {
|
||||
ret find_pre_post_state_call(fcx, pres, operator, e.id,
|
||||
cat_options(maybe_args), return);
|
||||
auto args = ~[];
|
||||
for (option::t[@expr] a_opt in maybe_args) {
|
||||
alt (a_opt) {
|
||||
case (none) { /* no-op */ }
|
||||
case (some(?a)) { args += ~[a]; }
|
||||
}
|
||||
}
|
||||
|
||||
ret find_pre_post_state_call(fcx, pres, operator, e.id, args,
|
||||
return);
|
||||
}
|
||||
case (expr_path(_)) { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||
case (expr_log(_, ?ex)) {
|
||||
|
|
@ -514,7 +523,7 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
|
|||
find_pre_post_state_expr(fcx, pres, val);
|
||||
auto e_post = expr_poststate(fcx.ccx, val);
|
||||
auto a_post;
|
||||
if (vec::len(alts) > 0u) {
|
||||
if (ivec::len(alts) > 0u) {
|
||||
a_post = false_postcond(num_constrs);
|
||||
for (arm an_alt in alts) {
|
||||
changed |= find_pre_post_state_block
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export check_crate;
|
|||
|
||||
type ty_table = hashmap[ast::def_id, ty::t];
|
||||
|
||||
type obj_info = rec(vec[ast::obj_field] obj_fields, ast::node_id this_obj);
|
||||
type obj_info = rec(ast::obj_field[] obj_fields, ast::node_id this_obj);
|
||||
|
||||
type crate_ctxt =
|
||||
rec(mutable vec[obj_info] obj_infos,
|
||||
|
|
@ -481,7 +481,7 @@ mod collect {
|
|||
}
|
||||
fn ty_of_fn_decl(&@ctxt cx, &fn(&@ast::ty) -> ty::t convert,
|
||||
&fn(&ast::arg) -> arg ty_of_arg, &ast::fn_decl decl,
|
||||
ast::proto proto, &vec[ast::ty_param] ty_params,
|
||||
ast::proto proto, &ast::ty_param[] ty_params,
|
||||
&option::t[ast::def_id] def_id) ->
|
||||
ty::ty_param_count_and_ty {
|
||||
auto input_tys = ~[];
|
||||
|
|
@ -495,7 +495,7 @@ mod collect {
|
|||
auto t_fn =
|
||||
ty::mk_fn(cx.tcx, proto, input_tys, output_ty, decl.cf,
|
||||
out_constrs);
|
||||
auto ty_param_count = vec::len[ast::ty_param](ty_params);
|
||||
auto ty_param_count = ivec::len[ast::ty_param](ty_params);
|
||||
auto tpt = tup(ty_param_count, t_fn);
|
||||
alt (def_id) {
|
||||
case (some(?did)) { cx.tcx.tcache.insert(did, tpt); }
|
||||
|
|
@ -506,7 +506,7 @@ mod collect {
|
|||
fn ty_of_native_fn_decl(&@ctxt cx, &fn(&@ast::ty) -> ty::t convert,
|
||||
&fn(&ast::arg) -> arg ty_of_arg,
|
||||
&ast::fn_decl decl, ast::native_abi abi,
|
||||
&vec[ast::ty_param] ty_params,
|
||||
&ast::ty_param[] ty_params,
|
||||
&ast::def_id def_id) ->
|
||||
ty::ty_param_count_and_ty {
|
||||
auto input_tys = ~[];
|
||||
|
|
@ -514,7 +514,7 @@ mod collect {
|
|||
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 ty_param_count = ivec::len[ast::ty_param](ty_params);
|
||||
auto tpt = tup(ty_param_count, t_fn);
|
||||
cx.tcx.tcache.insert(def_id, tpt);
|
||||
ret tpt;
|
||||
|
|
@ -577,14 +577,14 @@ mod collect {
|
|||
constrs=out_constrs);
|
||||
}
|
||||
fn ty_of_obj(@ctxt cx, &ast::ident id, &ast::_obj obj_info,
|
||||
&vec[ast::ty_param] ty_params) -> ty::ty_param_count_and_ty {
|
||||
&ast::ty_param[] ty_params) -> ty::ty_param_count_and_ty {
|
||||
auto methods = get_obj_method_types(cx, obj_info);
|
||||
auto t_obj = ty::mk_obj(cx.tcx, ty::sort_methods(methods));
|
||||
t_obj = ty::rename(cx.tcx, t_obj, id);
|
||||
ret tup(vec::len(ty_params), t_obj);
|
||||
ret tup(ivec::len(ty_params), t_obj);
|
||||
}
|
||||
fn ty_of_obj_ctor(@ctxt cx, &ast::ident id, &ast::_obj obj_info,
|
||||
ast::node_id ctor_id, &vec[ast::ty_param] ty_params) ->
|
||||
ast::node_id ctor_id, &ast::ty_param[] ty_params) ->
|
||||
ty::ty_param_count_and_ty {
|
||||
auto t_obj = ty_of_obj(cx, id, obj_info, ty_params);
|
||||
|
||||
|
|
@ -630,23 +630,23 @@ mod collect {
|
|||
// call to resolve any named types.
|
||||
|
||||
auto typ = convert(t);
|
||||
auto ty_param_count = vec::len[ast::ty_param](tps);
|
||||
auto ty_param_count = ivec::len[ast::ty_param](tps);
|
||||
auto tpt = tup(ty_param_count, typ);
|
||||
cx.tcx.tcache.insert(local_def(it.id), tpt);
|
||||
ret tpt;
|
||||
}
|
||||
case (ast::item_res(?f, _, ?tps, _)) {
|
||||
auto t_arg = ty_of_arg(cx, f.decl.inputs.(0));
|
||||
auto t_res = tup(vec::len(tps), ty::mk_res
|
||||
auto t_res = tup(ivec::len(tps), ty::mk_res
|
||||
(cx.tcx, local_def(it.id), t_arg.ty,
|
||||
mk_ty_params(cx, vec::len(tps))));
|
||||
mk_ty_params(cx, ivec::len(tps))));
|
||||
cx.tcx.tcache.insert(local_def(it.id), t_res);
|
||||
ret t_res;
|
||||
}
|
||||
case (ast::item_tag(_, ?tps)) {
|
||||
// Create a new generic polytype.
|
||||
|
||||
auto ty_param_count = vec::len[ast::ty_param](tps);
|
||||
auto ty_param_count = ivec::len[ast::ty_param](tps);
|
||||
|
||||
let ty::t[] subtys = mk_ty_params(cx, ty_param_count);
|
||||
auto t = ty::mk_tag(cx.tcx, local_def(it.id), subtys);
|
||||
|
|
@ -681,11 +681,11 @@ mod collect {
|
|||
}
|
||||
}
|
||||
fn get_tag_variant_types(&@ctxt cx, &ast::def_id tag_id,
|
||||
&vec[ast::variant] variants,
|
||||
&vec[ast::ty_param] ty_params) {
|
||||
&ast::variant[] variants,
|
||||
&ast::ty_param[] ty_params) {
|
||||
// Create a set of parameter types shared among all the variants.
|
||||
|
||||
auto ty_param_count = vec::len[ast::ty_param](ty_params);
|
||||
auto ty_param_count = ivec::len[ast::ty_param](ty_params);
|
||||
let ty::t[] ty_param_tys = mk_ty_params(cx, ty_param_count);
|
||||
for (ast::variant variant in variants) {
|
||||
// Nullary tag constructors get turned into constants; n-ary tag
|
||||
|
|
@ -757,7 +757,7 @@ mod collect {
|
|||
|
||||
auto method_types = get_obj_method_types(cx, object);
|
||||
auto i = 0u;
|
||||
while (i < vec::len[@ast::method](object.methods)) {
|
||||
while (i < ivec::len[@ast::method](object.methods)) {
|
||||
write::ty_only(cx.tcx, object.methods.(i).node.id,
|
||||
ty::method_ty_to_fn_ty(cx.tcx,
|
||||
method_types.(i)));
|
||||
|
|
@ -789,7 +789,7 @@ mod collect {
|
|||
case (ast::item_res(?f, ?dtor_id, ?tps, ?ctor_id)) {
|
||||
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)));
|
||||
mk_ty_params(cx, ivec::len(tps)));
|
||||
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],
|
||||
|
|
@ -797,7 +797,7 @@ mod collect {
|
|||
write::ty_only(cx.tcx, it.id, t_res);
|
||||
write::ty_only(cx.tcx, ctor_id, t_ctor);
|
||||
cx.tcx.tcache.insert(local_def(ctor_id),
|
||||
tup(vec::len(tps), t_ctor));
|
||||
tup(ivec::len(tps), t_ctor));
|
||||
write::ty_only(cx.tcx, dtor_id, t_dtor);
|
||||
}
|
||||
case (_) {
|
||||
|
|
@ -995,8 +995,8 @@ fn are_compatible(&@fn_ctxt fcx, &ty::t expected, &ty::t actual) -> bool {
|
|||
|
||||
// Returns the types of the arguments to a tag variant.
|
||||
fn variant_arg_types(&@crate_ctxt ccx, &span sp, &ast::def_id vid,
|
||||
&ty::t[] tag_ty_params) -> vec[ty::t] {
|
||||
let vec[ty::t] result = [];
|
||||
&ty::t[] tag_ty_params) -> ty::t[] {
|
||||
let ty::t[] result = ~[];
|
||||
auto tpt = ty::lookup_item_type(ccx.tcx, vid);
|
||||
alt (ty::struct(ccx.tcx, tpt._1)) {
|
||||
case (ty::ty_fn(_, ?ins, _, _, _)) {
|
||||
|
|
@ -1006,7 +1006,7 @@ fn variant_arg_types(&@crate_ctxt ccx, &span sp, &ast::def_id vid,
|
|||
auto arg_ty =
|
||||
ty::substitute_type_params(ccx.tcx, tag_ty_params,
|
||||
arg.ty);
|
||||
result += [arg_ty];
|
||||
result += ~[arg_ty];
|
||||
}
|
||||
}
|
||||
case (_) {
|
||||
|
|
@ -1121,12 +1121,12 @@ mod writeback {
|
|||
wbcx.ignore = false;
|
||||
}
|
||||
fn visit_fn_pre(@wb_ctxt wbcx, &ast::_fn f,
|
||||
&vec[ast::ty_param] tps, &span sp,
|
||||
&ast::ty_param[] tps, &span sp,
|
||||
&ast::fn_ident i, ast::node_id d) {
|
||||
wbcx.ignore = true;
|
||||
}
|
||||
fn visit_fn_post(@wb_ctxt wbcx, &ast::_fn f,
|
||||
&vec[ast::ty_param] tps, &span sp,
|
||||
&ast::ty_param[] tps, &span sp,
|
||||
&ast::fn_ident i, ast::node_id d) {
|
||||
wbcx.ignore = false;
|
||||
}
|
||||
|
|
@ -1335,11 +1335,11 @@ fn check_pat(&@fn_ctxt fcx, &@ast::pat pat, ty::t expected) {
|
|||
auto arg_types =
|
||||
variant_arg_types(fcx.ccx, pat.span, v_def_ids._1,
|
||||
expected_tps);
|
||||
auto subpats_len = vec::len[@ast::pat](subpats);
|
||||
if (vec::len[ty::t](arg_types) > 0u) {
|
||||
auto subpats_len = std::ivec::len[@ast::pat](subpats);
|
||||
if (std::ivec::len[ty::t](arg_types) > 0u) {
|
||||
// N-ary variant.
|
||||
|
||||
auto arg_len = vec::len[ty::t](arg_types);
|
||||
auto arg_len = ivec::len[ty::t](arg_types);
|
||||
if (arg_len != subpats_len) {
|
||||
// TODO: note definition of tag variant
|
||||
// TODO (issue #448): Wrap a #fmt string over multiple
|
||||
|
|
@ -1430,7 +1430,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
// expressions.
|
||||
|
||||
fn check_call_or_bind(&@fn_ctxt fcx, &span sp, &@ast::expr f,
|
||||
&vec[option::t[@ast::expr]] args, bool is_call) {
|
||||
&(option::t[@ast::expr])[] args, bool is_call) {
|
||||
// Check the function.
|
||||
|
||||
check_expr(fcx, f);
|
||||
|
|
@ -1458,7 +1458,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
// Check that the correct number of arguments were supplied.
|
||||
|
||||
auto expected_arg_count = ivec::len[ty::arg](arg_tys);
|
||||
auto supplied_arg_count = vec::len[option::t[@ast::expr]](args);
|
||||
auto supplied_arg_count = ivec::len[option::t[@ast::expr]](args);
|
||||
if (expected_arg_count != supplied_arg_count) {
|
||||
fcx.ccx.tcx.sess.span_fatal(sp,
|
||||
#fmt("this function takes %u \
|
||||
|
|
@ -1501,10 +1501,10 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
// A generic function for checking call expressions
|
||||
|
||||
fn check_call(&@fn_ctxt fcx, &span sp, &@ast::expr f,
|
||||
&vec[@ast::expr] args) {
|
||||
let vec[option::t[@ast::expr]] args_opt_0 = [];
|
||||
&(@ast::expr)[] args) {
|
||||
let (option::t[@ast::expr])[] args_opt_0 = ~[];
|
||||
for (@ast::expr arg in args) {
|
||||
args_opt_0 += [some[@ast::expr](arg)];
|
||||
args_opt_0 += ~[some[@ast::expr](arg)];
|
||||
}
|
||||
// Call the generic checker.
|
||||
|
||||
|
|
@ -1909,7 +1909,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
auto ty_of_arg = bind collect::ty_of_arg(cx, _);
|
||||
auto fty =
|
||||
collect::ty_of_fn_decl(cx, convert, ty_of_arg, f.decl,
|
||||
f.proto, [], none)._1;
|
||||
f.proto, ~[], none)._1;
|
||||
write::ty_only_fixup(fcx, id, fty);
|
||||
check_fn(fcx.ccx, f.decl, f.proto, f.body, id);
|
||||
}
|
||||
|
|
@ -1949,7 +1949,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
// to the resulting function type.
|
||||
|
||||
auto i = 0u;
|
||||
while (i < vec::len[option::t[@ast::expr]](args)) {
|
||||
while (i < ivec::len[option::t[@ast::expr]](args)) {
|
||||
alt (args.(i)) {
|
||||
case (some(_)) {/* no-op */ }
|
||||
case (none) { arg_tys_1 += ~[arg_tys.(i)]; }
|
||||
|
|
@ -2051,7 +2051,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
}
|
||||
case (ast::expr_vec(?args, ?mut, ?kind)) {
|
||||
let ty::t t;
|
||||
if (vec::len[@ast::expr](args) == 0u) {
|
||||
if (ivec::len[@ast::expr](args) == 0u) {
|
||||
t = next_ty_var(fcx);
|
||||
} else {
|
||||
check_expr(fcx, args.(0));
|
||||
|
|
@ -2075,7 +2075,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
}
|
||||
case (ast::expr_tup(?elts)) {
|
||||
let ty::mt[] elts_mt = ~[];
|
||||
ivec::reserve(elts_mt, vec::len(elts));
|
||||
ivec::reserve(elts_mt, ivec::len(elts));
|
||||
for (ast::elt e in elts) {
|
||||
check_expr(fcx, e.expr);
|
||||
auto ety = expr_ty(fcx.ccx.tcx, e.expr);
|
||||
|
|
@ -2250,7 +2250,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
|
||||
// We're entering an object, so gather up the info we need.
|
||||
|
||||
let vec[ast::anon_obj_field] fields = [];
|
||||
let ast::anon_obj_field[] fields = ~[];
|
||||
alt (anon_obj.fields) {
|
||||
case (none) { }
|
||||
case (some(?v)) { fields = v; }
|
||||
|
|
@ -2265,8 +2265,8 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
|
||||
vec::push[obj_info](fcx.ccx.obj_infos,
|
||||
rec(obj_fields=
|
||||
vec::map(anon_obj_field_to_obj_field,
|
||||
fields),
|
||||
ivec::map(anon_obj_field_to_obj_field,
|
||||
fields),
|
||||
this_obj=id));
|
||||
|
||||
// FIXME: These next three functions are largely ripped off from
|
||||
|
|
@ -2343,7 +2343,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
|||
// collect::convert for regular objects.)
|
||||
|
||||
auto i = 0u;
|
||||
while (i < vec::len[@ast::method](anon_obj.methods)) {
|
||||
while (i < ivec::len[@ast::method](anon_obj.methods)) {
|
||||
write::ty_only(fcx.ccx.tcx, anon_obj.methods.(i).node.id,
|
||||
ty::method_ty_to_fn_ty(fcx.ccx.tcx,
|
||||
method_types.(i)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue