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
|
@ -82,8 +82,8 @@ fn filter_stmt(&ast::crate_cfg cfg,
|
|||
fn fold_block(&ast::crate_cfg cfg, &ast::block_ b,
|
||||
fold::ast_fold fld) -> ast::block_ {
|
||||
auto filter = bind filter_stmt(cfg, _);
|
||||
auto filtered_stmts = vec::filter_map(filter, b.stmts);
|
||||
ret rec(stmts=vec::map(fld.fold_stmt, filtered_stmts),
|
||||
auto filtered_stmts = ivec::filter_map(filter, b.stmts);
|
||||
ret rec(stmts=ivec::map(fld.fold_stmt, filtered_stmts),
|
||||
expr=option::map(fld.fold_expr, b.expr),
|
||||
id=b.id);
|
||||
}
|
||||
|
|
|
@ -71,14 +71,14 @@ fn mk_main(&test_ctxt cx) -> @ast::item {
|
|||
auto ret_ty = @rec(node=ast::ty_nil,
|
||||
span=rec(lo=0u, hi=0u));
|
||||
|
||||
let ast::fn_decl decl = rec(inputs = [],
|
||||
let ast::fn_decl decl = rec(inputs = ~[],
|
||||
output = ret_ty,
|
||||
purity = ast::impure_fn,
|
||||
cf = ast::return,
|
||||
constraints = ~[]);
|
||||
auto proto = ast::proto_fn;
|
||||
|
||||
let ast::block_ body_ = rec(stmts = [],
|
||||
let ast::block_ body_ = rec(stmts = ~[],
|
||||
expr = option::none,
|
||||
id = cx.next_node_id());
|
||||
auto body = rec(node = body_, span = rec(lo=0u, hi=0u));
|
||||
|
@ -87,7 +87,7 @@ fn mk_main(&test_ctxt cx) -> @ast::item {
|
|||
proto = proto,
|
||||
body = body);
|
||||
|
||||
auto item_ = ast::item_fn(fn_, []);
|
||||
auto item_ = ast::item_fn(fn_, ~[]);
|
||||
let ast::item item = rec(ident = "main",
|
||||
attrs = ~[],
|
||||
id = cx.next_node_id(),
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// Metadata encoding
|
||||
|
||||
import std::ivec;
|
||||
import std::str;
|
||||
import std::vec;
|
||||
import std::uint;
|
||||
|
@ -33,7 +34,7 @@ fn encode_def_id(&ebml::writer ebml_w, &def_id id) {
|
|||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
|
||||
fn encode_tag_variant_paths(&ebml::writer ebml_w, &vec[variant] variants,
|
||||
fn encode_tag_variant_paths(&ebml::writer ebml_w, &variant[] variants,
|
||||
&vec[str] path,
|
||||
&mutable vec[tup(str, uint)] index) {
|
||||
for (variant variant in variants) {
|
||||
|
@ -164,9 +165,9 @@ fn encode_kind(&ebml::writer ebml_w, u8 c) {
|
|||
|
||||
fn def_to_str(&def_id did) -> str { ret #fmt("%d:%d", did._0, did._1); }
|
||||
|
||||
fn encode_type_param_count(&ebml::writer ebml_w, &vec[ty_param] tps) {
|
||||
fn encode_type_param_count(&ebml::writer ebml_w, &ty_param[] tps) {
|
||||
ebml::start_tag(ebml_w, tag_items_data_item_ty_param_count);
|
||||
ebml::write_vint(ebml_w.writer, vec::len[ty_param](tps));
|
||||
ebml::write_vint(ebml_w.writer, ivec::len[ty_param](tps));
|
||||
ebml::end_tag(ebml_w);
|
||||
}
|
||||
|
||||
|
@ -207,9 +208,9 @@ fn encode_tag_id(&ebml::writer ebml_w, &def_id id) {
|
|||
}
|
||||
|
||||
fn encode_tag_variant_info(&@crate_ctxt cx, &ebml::writer ebml_w,
|
||||
node_id id, &vec[variant] variants,
|
||||
node_id id, &variant[] variants,
|
||||
&mutable vec[tup(int, uint)] index,
|
||||
&vec[ty_param] ty_params) {
|
||||
&ty_param[] ty_params) {
|
||||
for (variant variant in variants) {
|
||||
index += [tup(variant.node.id, ebml_w.writer.tell())];
|
||||
ebml::start_tag(ebml_w, tag_items_data_item);
|
||||
|
|
|
@ -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,7 +7027,7 @@ 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,
|
||||
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);
|
||||
|
||||
|
@ -7849,9 +7851,9 @@ fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ValueRef llfndecl,
|
|||
// helper function for create_vtbl.
|
||||
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,18 +8495,18 @@ 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),
|
||||
~[rec(mode=ast::alias(false),
|
||||
ty=varg.ty,
|
||||
ident="arg" + uint::to_str(i, 10u),
|
||||
id=varg.id)];
|
||||
|
@ -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,7 +2265,7 @@ 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,
|
||||
ivec::map(anon_obj_field_to_obj_field,
|
||||
fields),
|
||||
this_obj=id));
|
||||
|
||||
|
@ -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)));
|
||||
|
|
|
@ -111,7 +111,7 @@ tag meta_item_ {
|
|||
|
||||
type block = spanned[block_];
|
||||
|
||||
type block_ = rec(vec[@stmt] stmts, option::t[@expr] expr, node_id id);
|
||||
type block_ = rec((@stmt)[] stmts, option::t[@expr] expr, node_id id);
|
||||
|
||||
type pat = rec(node_id id,
|
||||
pat_ node,
|
||||
|
@ -121,7 +121,7 @@ tag pat_ {
|
|||
pat_wild;
|
||||
pat_bind(ident);
|
||||
pat_lit(@lit);
|
||||
pat_tag(path, vec[@pat]);
|
||||
pat_tag(path, (@pat)[]);
|
||||
}
|
||||
|
||||
tag mutability { mut; imm; maybe_mut; }
|
||||
|
@ -246,13 +246,13 @@ type expr = rec(node_id id,
|
|||
span span);
|
||||
|
||||
tag expr_ {
|
||||
expr_vec(vec[@expr], mutability, seq_kind);
|
||||
expr_tup(vec[elt]);
|
||||
expr_rec(vec[field], option::t[@expr]);
|
||||
expr_call(@expr, vec[@expr]);
|
||||
expr_vec((@expr)[], mutability, seq_kind);
|
||||
expr_tup(elt[]);
|
||||
expr_rec(field[], option::t[@expr]);
|
||||
expr_call(@expr, (@expr)[]);
|
||||
expr_self_method(ident);
|
||||
expr_bind(@expr, vec[option::t[@expr]]);
|
||||
expr_spawn(spawn_dom, option::t[str], @expr, vec[@expr]);
|
||||
expr_bind(@expr, (option::t[@expr])[]);
|
||||
expr_spawn(spawn_dom, option::t[str], @expr, (@expr)[]);
|
||||
expr_binary(binop, @expr, @expr);
|
||||
expr_unary(unop, @expr);
|
||||
expr_lit(@lit);
|
||||
|
@ -263,7 +263,7 @@ tag expr_ {
|
|||
expr_for(@local, @expr, block);
|
||||
expr_for_each(@local, @expr, block);
|
||||
expr_do_while(block, @expr);
|
||||
expr_alt(@expr, vec[arm]);
|
||||
expr_alt(@expr, arm[]);
|
||||
expr_fn(_fn);
|
||||
expr_block(block);
|
||||
/*
|
||||
|
@ -279,7 +279,7 @@ tag expr_ {
|
|||
expr_field(@expr, ident);
|
||||
expr_index(@expr, @expr);
|
||||
expr_path(path);
|
||||
expr_ext(path, vec[@expr], option::t[str], @expr);
|
||||
expr_ext(path, (@expr)[], option::t[str], @expr);
|
||||
expr_fail(option::t[@expr]);
|
||||
expr_break;
|
||||
expr_cont;
|
||||
|
@ -298,7 +298,7 @@ tag expr_ {
|
|||
expr_if_check(@expr, block, option::t[@expr]);
|
||||
expr_port(option::t[@ty]);
|
||||
expr_chan(@expr);
|
||||
expr_anon_obj(anon_obj, vec[ty_param]);
|
||||
expr_anon_obj(anon_obj, ty_param[]);
|
||||
}
|
||||
|
||||
type lit = spanned[lit_];
|
||||
|
@ -438,7 +438,7 @@ type constr = spanned[constr_];
|
|||
type arg = rec(mode mode, @ty ty, ident ident, node_id id);
|
||||
|
||||
type fn_decl =
|
||||
rec(vec[arg] inputs,
|
||||
rec(arg[] inputs,
|
||||
@ty output,
|
||||
purity purity,
|
||||
controlflow cf,
|
||||
|
@ -470,13 +470,13 @@ type anon_obj_field = rec(mutability mut, @ty ty, @expr expr, ident ident,
|
|||
node_id id);
|
||||
|
||||
type _obj =
|
||||
rec(vec[obj_field] fields, vec[@method] methods, option::t[@method] dtor);
|
||||
rec(obj_field[] fields, (@method)[] methods, option::t[@method] dtor);
|
||||
|
||||
type anon_obj =
|
||||
rec(
|
||||
// New fields and methods, if they exist.
|
||||
option::t[vec[anon_obj_field]] fields,
|
||||
vec[@method] methods,
|
||||
option::t[anon_obj_field[]] fields,
|
||||
(@method)[] methods,
|
||||
|
||||
// with_obj: the original object being extended, if it exists.
|
||||
option::t[@expr] with_obj);
|
||||
|
@ -533,14 +533,14 @@ type item = rec(ident ident,
|
|||
|
||||
tag item_ {
|
||||
item_const(@ty, @expr);
|
||||
item_fn(_fn, vec[ty_param]);
|
||||
item_fn(_fn, ty_param[]);
|
||||
item_mod(_mod);
|
||||
item_native_mod(native_mod);
|
||||
item_ty(@ty, vec[ty_param]);
|
||||
item_tag(vec[variant], vec[ty_param]);
|
||||
item_obj(_obj, vec[ty_param], node_id /* constructor id */);
|
||||
item_ty(@ty, ty_param[]);
|
||||
item_tag(variant[], ty_param[]);
|
||||
item_obj(_obj, ty_param[], node_id /* constructor id */);
|
||||
item_res(_fn /* dtor */, node_id /* dtor id */,
|
||||
vec[ty_param], node_id /* ctor id */);
|
||||
ty_param[], node_id /* ctor id */);
|
||||
}
|
||||
|
||||
type native_item = rec(ident ident,
|
||||
|
@ -551,7 +551,7 @@ type native_item = rec(ident ident,
|
|||
|
||||
tag native_item_ {
|
||||
native_item_ty;
|
||||
native_item_fn(option::t[str], fn_decl, vec[ty_param]);
|
||||
native_item_fn(option::t[str], fn_decl, ty_param[]);
|
||||
}
|
||||
|
||||
fn is_exported(ident i, _mod m) -> bool {
|
||||
|
@ -609,7 +609,7 @@ fn hash_ty(&@ty t) -> uint { ret t.span.lo << 16u + t.span.hi; }
|
|||
|
||||
fn block_from_expr(@expr e) -> block {
|
||||
let block_ blk_ =
|
||||
rec(stmts=[],
|
||||
rec(stmts=~[],
|
||||
expr=option::some[@expr](e),
|
||||
id=e.id);
|
||||
ret rec(node=blk_, span=e.span);
|
||||
|
|
|
@ -8,8 +8,8 @@ import std::map::new_str_hash;
|
|||
import codemap;
|
||||
|
||||
type syntax_expander =
|
||||
fn(&ext_ctxt, span, &vec[@ast::expr], option::t[str]) -> @ast::expr;
|
||||
type macro_definer = fn(&ext_ctxt, span, &vec[@ast::expr],
|
||||
fn(&ext_ctxt, span, &(@ast::expr)[], option::t[str]) -> @ast::expr;
|
||||
type macro_definer = fn(&ext_ctxt, span, &(@ast::expr)[],
|
||||
option::t[str]) -> tup(str, syntax_extension);
|
||||
|
||||
tag syntax_extension {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* should all get sucked into either the compiler syntax extension plugin
|
||||
* interface.
|
||||
*/
|
||||
import std::ivec;
|
||||
import std::str;
|
||||
import std::vec;
|
||||
import std::option;
|
||||
|
@ -12,9 +13,9 @@ import std::generic_os;
|
|||
import base::*;
|
||||
export expand_syntax_ext;
|
||||
|
||||
fn expand_syntax_ext(&ext_ctxt cx, codemap::span sp, &vec[@ast::expr] args,
|
||||
fn expand_syntax_ext(&ext_ctxt cx, codemap::span sp, &(@ast::expr)[] args,
|
||||
option::t[str] body) -> @ast::expr {
|
||||
if (vec::len[@ast::expr](args) != 1u) {
|
||||
if (ivec::len[@ast::expr](args) != 1u) {
|
||||
cx.span_fatal(sp, "malformed #env call");
|
||||
}
|
||||
// FIXME: if this was more thorough it would manufacture an
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* should all get sucked into either the standard library extfmt module or the
|
||||
* compiler syntax extension plugin interface.
|
||||
*/
|
||||
import std::ivec;
|
||||
import std::str;
|
||||
import std::vec;
|
||||
import std::option;
|
||||
|
@ -15,9 +16,9 @@ import base::*;
|
|||
import codemap::span;
|
||||
export expand_syntax_ext;
|
||||
|
||||
fn expand_syntax_ext(&ext_ctxt cx, span sp, &vec[@ast::expr] args,
|
||||
fn expand_syntax_ext(&ext_ctxt cx, span sp, &(@ast::expr)[] args,
|
||||
option::t[str] body) -> @ast::expr {
|
||||
if (vec::len[@ast::expr](args) == 0u) {
|
||||
if (ivec::len[@ast::expr](args) == 0u) {
|
||||
cx.span_fatal(sp, "#fmt requires a format string");
|
||||
}
|
||||
auto fmt = expr_to_str(cx, args.(0), "first argument to #fmt must be a "
|
||||
|
@ -37,7 +38,7 @@ fn expand_syntax_ext(&ext_ctxt cx, span sp, &vec[@ast::expr] args,
|
|||
// be factored out in common with other code that builds expressions.
|
||||
// FIXME: Cleanup the naming of these functions
|
||||
fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
|
||||
vec[@ast::expr] args) -> @ast::expr {
|
||||
&(@ast::expr)[] args) -> @ast::expr {
|
||||
fn make_new_lit(&ext_ctxt cx, span sp, ast::lit_ lit) ->
|
||||
@ast::expr {
|
||||
auto sp_lit = @rec(node=lit, span=sp);
|
||||
|
@ -67,26 +68,26 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
|
|||
auto pathexpr = ast::expr_path(sp_path);
|
||||
ret @rec(id=cx.next_id(), node=pathexpr, span=sp);
|
||||
}
|
||||
fn make_vec_expr(&ext_ctxt cx, span sp, vec[@ast::expr] exprs) ->
|
||||
fn make_vec_expr(&ext_ctxt cx, span sp, &(@ast::expr)[] exprs) ->
|
||||
@ast::expr {
|
||||
auto vecexpr = ast::expr_vec(exprs, ast::imm, ast::sk_rc);
|
||||
ret @rec(id=cx.next_id(), node=vecexpr, span=sp);
|
||||
}
|
||||
fn make_call(&ext_ctxt cx, span sp, &ast::ident[] fn_path,
|
||||
vec[@ast::expr] args) -> @ast::expr {
|
||||
&(@ast::expr)[] args) -> @ast::expr {
|
||||
auto pathexpr = make_path_expr(cx, sp, fn_path);
|
||||
auto callexpr = ast::expr_call(pathexpr, args);
|
||||
ret @rec(id=cx.next_id(), node=callexpr, span=sp);
|
||||
}
|
||||
fn make_rec_expr(&ext_ctxt cx, span sp,
|
||||
vec[tup(ast::ident, @ast::expr)] fields) -> @ast::expr {
|
||||
let vec[ast::field] astfields = [];
|
||||
let ast::field[] astfields = ~[];
|
||||
for (tup(ast::ident, @ast::expr) field in fields) {
|
||||
auto ident = field._0;
|
||||
auto val = field._1;
|
||||
auto astfield =
|
||||
rec(node=rec(mut=ast::imm, ident=ident, expr=val), span=sp);
|
||||
astfields += [astfield];
|
||||
astfields += ~[astfield];
|
||||
}
|
||||
auto recexpr = ast::expr_rec(astfields, option::none[@ast::expr]);
|
||||
ret @rec(id=cx.next_id(), node=recexpr, span=sp);
|
||||
|
@ -109,7 +110,7 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
|
|||
@ast::expr {
|
||||
fn make_flags(&ext_ctxt cx, span sp, vec[flag] flags) ->
|
||||
@ast::expr {
|
||||
let vec[@ast::expr] flagexprs = [];
|
||||
let (@ast::expr)[] flagexprs = ~[];
|
||||
for (flag f in flags) {
|
||||
auto fstr;
|
||||
alt (f) {
|
||||
|
@ -121,14 +122,14 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
|
|||
case (flag_sign_always) { fstr = "flag_sign_always"; }
|
||||
case (flag_alternate) { fstr = "flag_alternate"; }
|
||||
}
|
||||
flagexprs += [make_rt_path_expr(cx, sp, fstr)];
|
||||
flagexprs += ~[make_rt_path_expr(cx, sp, fstr)];
|
||||
}
|
||||
// FIXME: 0-length vectors can't have their type inferred
|
||||
// through the rec that these flags are a member of, so
|
||||
// this is a hack placeholder flag
|
||||
|
||||
if (vec::len[@ast::expr](flagexprs) == 0u) {
|
||||
flagexprs += [make_rt_path_expr(cx, sp, "flag_none")];
|
||||
if (ivec::len[@ast::expr](flagexprs) == 0u) {
|
||||
flagexprs += ~[make_rt_path_expr(cx, sp, "flag_none")];
|
||||
}
|
||||
ret make_vec_expr(cx, sp, flagexprs);
|
||||
}
|
||||
|
@ -141,7 +142,7 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
|
|||
case (count_is(?c)) {
|
||||
auto count_lit = make_new_int(cx, sp, c);
|
||||
auto count_is_path = make_path_vec("count_is");
|
||||
auto count_is_args = [count_lit];
|
||||
auto count_is_args = ~[count_lit];
|
||||
ret make_call(cx, sp, count_is_path, count_is_args);
|
||||
}
|
||||
case (_) {
|
||||
|
@ -185,7 +186,7 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
|
|||
auto fname = "conv_" + conv_type;
|
||||
auto path = make_path_vec(fname);
|
||||
auto cnv_expr = make_rt_conv_expr(cx, sp, cnv);
|
||||
auto args = [cnv_expr, arg];
|
||||
auto args = ~[cnv_expr, arg];
|
||||
ret make_call(cx, arg.span, path, args);
|
||||
}
|
||||
fn make_new_conv(&ext_ctxt cx, span sp, conv cnv, @ast::expr arg)
|
||||
|
@ -328,7 +329,7 @@ fn pieces_to_expr(&ext_ctxt cx, span sp, vec[piece] pieces,
|
|||
auto fmt_sp = args.(0).span;
|
||||
auto n = 0u;
|
||||
auto tmp_expr = make_new_str(cx, sp, "");
|
||||
auto nargs = vec::len[@ast::expr](args);
|
||||
auto nargs = ivec::len[@ast::expr](args);
|
||||
for (piece pc in pieces) {
|
||||
alt (pc) {
|
||||
case (piece_string(?s)) {
|
||||
|
|
|
@ -34,7 +34,7 @@ fn position[T](&T x, &vec[T] v) -> option::t[uint] {
|
|||
}
|
||||
|
||||
// substitute, in a position that's required to be an ident
|
||||
fn subst_ident(&ext_ctxt cx, &vec[@ast::expr] args,
|
||||
fn subst_ident(&ext_ctxt cx, &(@ast::expr)[] args,
|
||||
@vec[ident] param_names, &ident i, ast_fold fld) -> ident {
|
||||
alt (position(i, *param_names)) {
|
||||
case (some[uint](?idx)) {
|
||||
|
@ -48,7 +48,7 @@ fn subst_ident(&ext_ctxt cx, &vec[@ast::expr] args,
|
|||
}
|
||||
}
|
||||
|
||||
fn subst_path(&ext_ctxt cx, &vec[@ast::expr] args,
|
||||
fn subst_path(&ext_ctxt cx, &(@ast::expr)[] args,
|
||||
@vec[ident] param_names, &path_ p, ast_fold fld) -> path_ {
|
||||
// Don't substitute into qualified names.
|
||||
if (ivec::len(p.types) > 0u || ivec::len(p.idents) != 1u) { ret p; }
|
||||
|
@ -70,7 +70,7 @@ fn subst_path(&ext_ctxt cx, &vec[@ast::expr] args,
|
|||
}
|
||||
|
||||
|
||||
fn subst_expr(&ext_ctxt cx, &vec[@ast::expr] args, @vec[ident] param_names,
|
||||
fn subst_expr(&ext_ctxt cx, &(@ast::expr)[] args, @vec[ident] param_names,
|
||||
&ast::expr_ e, ast_fold fld,
|
||||
fn(&ast::expr_, ast_fold) -> ast::expr_ orig) -> ast::expr_ {
|
||||
ret alt(e) {
|
||||
|
@ -90,20 +90,21 @@ fn subst_expr(&ext_ctxt cx, &vec[@ast::expr] args, @vec[ident] param_names,
|
|||
}
|
||||
|
||||
|
||||
fn add_new_extension(&ext_ctxt cx, span sp, &vec[@ast::expr] args,
|
||||
fn add_new_extension(&ext_ctxt cx, span sp, &(@ast::expr)[] args,
|
||||
option::t[str] body) -> tup(str, syntax_extension) {
|
||||
if (len(args) < 2u) {
|
||||
if (ivec::len(args) < 2u) {
|
||||
cx.span_fatal(sp, "malformed extension description");
|
||||
}
|
||||
|
||||
fn generic_extension(&ext_ctxt cx, span sp, &vec[@ast::expr] args,
|
||||
fn generic_extension(&ext_ctxt cx, span sp, &(@ast::expr)[] args,
|
||||
option::t[str] body, @vec[ident] param_names,
|
||||
@ast::expr dest_form) -> @ast::expr {
|
||||
if (len(args) != len(*param_names)) {
|
||||
if (ivec::len(args) != len(*param_names)) {
|
||||
cx.span_fatal(sp, #fmt("extension expects %u arguments, got %u",
|
||||
len(*param_names), len(args)));
|
||||
len(*param_names), ivec::len(args)));
|
||||
}
|
||||
|
||||
// FIXME: This binds to alias arguments.
|
||||
auto afp = default_ast_fold();
|
||||
auto f_pre =
|
||||
rec(fold_ident = bind subst_ident(cx, args, param_names, _, _),
|
||||
|
@ -120,7 +121,7 @@ fn add_new_extension(&ext_ctxt cx, span sp, &vec[@ast::expr] args,
|
|||
|
||||
let vec[ident] param_names = vec::empty[ident]();
|
||||
let uint idx = 1u;
|
||||
while(1u+idx < len(args)) {
|
||||
while(1u+idx < ivec::len(args)) {
|
||||
param_names +=
|
||||
[expr_to_ident(cx, args.(idx),
|
||||
"this parameter name must be an identifier.")];
|
||||
|
@ -129,7 +130,7 @@ fn add_new_extension(&ext_ctxt cx, span sp, &vec[@ast::expr] args,
|
|||
|
||||
ret tup(expr_to_str(cx, args.(0), "first arg must be a literal string."),
|
||||
normal(bind generic_extension(_,_,_,_,@param_names,
|
||||
args.(len(args)-1u))));
|
||||
args.(ivec::len(args)-1u))));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -172,7 +172,8 @@ fn noop_fold_native_item(&@native_item ni, ast_fold fld) -> @native_item {
|
|||
case (native_item_ty) { native_item_ty }
|
||||
case (native_item_fn(?st, ?fdec, ?typms)) {
|
||||
native_item_fn(st,
|
||||
rec(inputs=map(fold_arg, fdec.inputs),
|
||||
rec(inputs=ivec::map(fold_arg,
|
||||
fdec.inputs),
|
||||
output=fld.fold_ty(fdec.output),
|
||||
purity=fdec.purity, cf=fdec.cf,
|
||||
constraints=ivec::map(fld.fold_constr,
|
||||
|
@ -216,11 +217,11 @@ fn noop_fold_item_underscore(&item_ i, ast_fold fld) -> item_ {
|
|||
item_ty(fld.fold_ty(t), typms)
|
||||
}
|
||||
case (item_tag(?variants, ?typms)) {
|
||||
item_tag(map(fld.fold_variant, variants), typms)
|
||||
item_tag(ivec::map(fld.fold_variant, variants), typms)
|
||||
}
|
||||
case (item_obj(?o, ?typms, ?d)) {
|
||||
item_obj(rec(fields=map(fold_obj_field,o.fields),
|
||||
methods=map(fld.fold_method,o.methods),
|
||||
item_obj(rec(fields=ivec::map(fold_obj_field,o.fields),
|
||||
methods=ivec::map(fld.fold_method,o.methods),
|
||||
dtor=option::map(fld.fold_method,o.dtor)),
|
||||
typms, d)
|
||||
}
|
||||
|
@ -237,7 +238,7 @@ fn noop_fold_method(&method_ m, ast_fold fld) -> method_ {
|
|||
|
||||
|
||||
fn noop_fold_block(&block_ b, ast_fold fld) -> block_ {
|
||||
ret rec(stmts=map(fld.fold_stmt, b.stmts),
|
||||
ret rec(stmts=ivec::map(fld.fold_stmt, b.stmts),
|
||||
expr=option::map(fld.fold_expr, b.expr), id=b.id);
|
||||
}
|
||||
|
||||
|
@ -261,7 +262,7 @@ fn noop_fold_pat(&pat_ p, ast_fold fld) -> pat_ {
|
|||
case (pat_bind(?ident)) { pat_bind(fld.fold_ident(ident))}
|
||||
case (pat_lit(_)) { p }
|
||||
case (pat_tag(?pth, ?pats)) {
|
||||
pat_tag(fld.fold_path(pth), map(fld.fold_pat, pats))
|
||||
pat_tag(fld.fold_path(pth), ivec::map(fld.fold_pat, pats))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -298,12 +299,12 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
|||
auto fold_anon_obj_field = bind fold_anon_obj_field_(_,fld);
|
||||
|
||||
ret rec(fields=alt(ao.fields) {
|
||||
case (option::none[vec[anon_obj_field]]) { ao.fields }
|
||||
case (option::some[vec[anon_obj_field]](?v)) {
|
||||
option::some[vec[anon_obj_field]]
|
||||
(map(fold_anon_obj_field, v))
|
||||
case (option::none[anon_obj_field[]]) { ao.fields }
|
||||
case (option::some[anon_obj_field[]](?v)) {
|
||||
option::some[anon_obj_field[]]
|
||||
(ivec::map(fold_anon_obj_field, v))
|
||||
}},
|
||||
methods=map(fld.fold_method, ao.methods),
|
||||
methods=ivec::map(fld.fold_method, ao.methods),
|
||||
with_obj=option::map(fld.fold_expr, ao.with_obj))
|
||||
}
|
||||
auto fold_anon_obj = bind fold_anon_obj_(_,fld);
|
||||
|
@ -311,28 +312,28 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
|||
|
||||
ret alt (e) {
|
||||
case (expr_vec(?exprs, ?mut, ?seq_kind)) {
|
||||
expr_vec(map(fld.fold_expr, exprs), mut, seq_kind)
|
||||
expr_vec(ivec::map(fld.fold_expr, exprs), mut, seq_kind)
|
||||
}
|
||||
case (expr_tup(?elts)) {
|
||||
expr_tup(map(fold_elt, elts))
|
||||
expr_tup(ivec::map(fold_elt, elts))
|
||||
}
|
||||
case (expr_rec(?fields, ?maybe_expr)) {
|
||||
expr_rec(map(fold_field, fields),
|
||||
expr_rec(ivec::map(fold_field, fields),
|
||||
option::map(fld.fold_expr, maybe_expr))
|
||||
}
|
||||
case (expr_call(?f, ?args)) {
|
||||
expr_call(fld.fold_expr(f), map(fld.fold_expr, args))
|
||||
expr_call(fld.fold_expr(f), ivec::map(fld.fold_expr, args))
|
||||
}
|
||||
case (expr_self_method(?id)) {
|
||||
expr_self_method(fld.fold_ident(id))
|
||||
}
|
||||
case (expr_bind(?f, ?args)) {
|
||||
auto opt_map_se = bind option::map(fld.fold_expr,_);
|
||||
expr_bind(fld.fold_expr(f), map(opt_map_se, args))
|
||||
expr_bind(fld.fold_expr(f), ivec::map(opt_map_se, args))
|
||||
}
|
||||
case (expr_spawn(?spawn_dom, ?name, ?f, ?args)) {
|
||||
expr_spawn(spawn_dom, name, fld.fold_expr(f),
|
||||
map(fld.fold_expr, args))
|
||||
ivec::map(fld.fold_expr, args))
|
||||
}
|
||||
case (expr_binary(?binop, ?lhs, ?rhs)) {
|
||||
expr_binary(binop, fld.fold_expr(lhs), fld.fold_expr(rhs))
|
||||
|
@ -368,7 +369,7 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
|||
expr_do_while(fld.fold_block(block), fld.fold_expr(expr))
|
||||
}
|
||||
case (expr_alt(?expr, ?arms)) {
|
||||
expr_alt(fld.fold_expr(expr), map(fld.fold_arm, arms))
|
||||
expr_alt(fld.fold_expr(expr), ivec::map(fld.fold_arm, arms))
|
||||
}
|
||||
case (expr_fn(?f)) {
|
||||
expr_fn(fld.fold_fn(f))
|
||||
|
@ -404,7 +405,7 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
|||
expr_path(fld.fold_path(pth))
|
||||
}
|
||||
case (expr_ext(?pth, ?args, ?body, ?expanded)) {
|
||||
expr_ext(fld.fold_path(pth), map(fld.fold_expr, args),
|
||||
expr_ext(fld.fold_path(pth), ivec::map(fld.fold_expr, args),
|
||||
body, fld.fold_expr(expanded))
|
||||
}
|
||||
case (expr_fail(_)) { e }
|
||||
|
@ -450,7 +451,7 @@ fn noop_fold_constr(&constr_ c, ast_fold fld) -> constr_ {
|
|||
fn noop_fold_fn(&_fn f, ast_fold fld) -> _fn {
|
||||
auto fold_arg = bind fold_arg_(_, fld);
|
||||
|
||||
ret rec(decl= rec(inputs=vec::map(fold_arg, f.decl.inputs),
|
||||
ret rec(decl= rec(inputs=ivec::map(fold_arg, f.decl.inputs),
|
||||
output=fld.fold_ty(f.decl.output),
|
||||
purity=f.decl.purity,
|
||||
cf=f.decl.cf,
|
||||
|
|
|
@ -260,7 +260,7 @@ fn parse_ty_fn(ast::proto proto, &parser p, uint lo) -> ast::ty_ {
|
|||
auto inputs =
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_fn_input_ty, p);
|
||||
auto constrs = parse_constrs([], p);
|
||||
auto constrs = parse_constrs(~[], p);
|
||||
let @ast::ty output;
|
||||
auto cf = ast::return;
|
||||
if (p.peek() == token::RARROW) {
|
||||
|
@ -329,13 +329,13 @@ fn parse_ty_field(&parser p) -> ast::ty_field {
|
|||
|
||||
// if i is the jth ident in args, return j
|
||||
// otherwise, fail
|
||||
fn ident_index(&parser p, &vec[ast::arg] args, &ast::ident i) -> uint {
|
||||
fn ident_index(&parser p, &ast::arg[] args, &ast::ident i) -> uint {
|
||||
auto j = 0u;
|
||||
for (ast::arg a in args) { if (a.ident == i) { ret j; } j += 1u; }
|
||||
p.fatal("Unbound variable " + i + " in constraint arg");
|
||||
}
|
||||
|
||||
fn parse_constr_arg(vec[ast::arg] args, &parser p) -> @ast::constr_arg {
|
||||
fn parse_constr_arg(&ast::arg[] args, &parser p) -> @ast::constr_arg {
|
||||
auto sp = p.get_span();
|
||||
auto carg = ast::carg_base;
|
||||
if (p.peek() == token::BINOP(token::STAR)) {
|
||||
|
@ -347,7 +347,7 @@ fn parse_constr_arg(vec[ast::arg] args, &parser p) -> @ast::constr_arg {
|
|||
ret @rec(node=carg, span=sp);
|
||||
}
|
||||
|
||||
fn parse_ty_constr(&vec[ast::arg] fn_args, &parser p) -> @ast::constr {
|
||||
fn parse_ty_constr(&ast::arg[] fn_args, &parser p) -> @ast::constr {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto path = parse_path(p);
|
||||
auto pf = bind parse_constr_arg(fn_args, _);
|
||||
|
@ -364,7 +364,7 @@ fn parse_ty_constr(&vec[ast::arg] fn_args, &parser p) -> @ast::constr {
|
|||
// Use the args list to translate each bound variable
|
||||
// mentioned in a constraint to an arg index.
|
||||
// Seems weird to do this in the parser, but I'm not sure how else to.
|
||||
fn parse_constrs(&vec[ast::arg] args, &parser p)
|
||||
fn parse_constrs(&ast::arg[] args, &parser p)
|
||||
-> ast::spanned[(@ast::constr)[]] {
|
||||
auto lo = p.get_lo_pos();
|
||||
auto hi = p.get_hi_pos();
|
||||
|
@ -383,7 +383,7 @@ fn parse_constrs(&vec[ast::arg] args, &parser p)
|
|||
|
||||
fn parse_ty_constrs(@ast::ty t, &parser p) -> @ast::ty {
|
||||
if (p.peek() == token::COLON) {
|
||||
auto constrs = parse_constrs([], p);
|
||||
auto constrs = parse_constrs(~[], p);
|
||||
ret @spanned(t.span.lo, constrs.span.hi,
|
||||
ast::ty_constr(t, constrs.node));
|
||||
}
|
||||
|
@ -776,7 +776,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
|||
ret rec(mut=m, expr=e);
|
||||
}
|
||||
auto es =
|
||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_elt, p);
|
||||
hi = es.span.hi;
|
||||
ex = ast::expr_tup(es.node);
|
||||
|
@ -784,8 +784,8 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
|||
p.bump();
|
||||
auto mut = parse_mutability(p);
|
||||
auto es =
|
||||
parse_seq_to_end(token::RBRACKET, some(token::COMMA), parse_expr,
|
||||
p);
|
||||
parse_seq_to_end_ivec(token::RBRACKET, some(token::COMMA),
|
||||
parse_expr, p);
|
||||
ex = ast::expr_vec(es, mut, ast::sk_rc);
|
||||
} else if (p.peek() == token::TILDE) {
|
||||
p.bump();
|
||||
|
@ -795,7 +795,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
|||
p.bump();
|
||||
auto mut = parse_mutability(p);
|
||||
auto es =
|
||||
parse_seq_to_end(token::RBRACKET, some(token::COMMA),
|
||||
parse_seq_to_end_ivec(token::RBRACKET, some(token::COMMA),
|
||||
parse_expr, p);
|
||||
ex = ast::expr_vec(es, mut, ast::sk_unique);
|
||||
}
|
||||
|
@ -817,20 +817,22 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
|||
auto ty_params = parse_ty_params(p);
|
||||
|
||||
// Only make people type () if they're actually adding new fields
|
||||
let option::t[vec[ast::anon_obj_field]] fields = none;
|
||||
let option::t[ast::anon_obj_field[]] fields = none;
|
||||
if (p.peek() == token::LPAREN) {
|
||||
p.bump();
|
||||
fields =
|
||||
some(parse_seq_to_end(token::RPAREN, some(token::COMMA),
|
||||
some(parse_seq_to_end_ivec(token::RPAREN, some(token::COMMA),
|
||||
parse_anon_obj_field, p));
|
||||
}
|
||||
let vec[@ast::method] meths = [];
|
||||
let (@ast::method)[] meths = ~[];
|
||||
let option::t[@ast::expr] with_obj = none;
|
||||
expect(p, token::LBRACE);
|
||||
while (p.peek() != token::RBRACE) {
|
||||
if (eat_word(p, "with")) {
|
||||
with_obj = some(parse_expr(p));
|
||||
} else { vec::push(meths, parse_method(p)); }
|
||||
} else {
|
||||
meths += ~[parse_method(p)];
|
||||
}
|
||||
}
|
||||
hi = p.get_hi_pos();
|
||||
expect(p, token::RBRACE);
|
||||
|
@ -845,7 +847,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
|||
ex = ast::expr_anon_obj(ob, ty_params);
|
||||
} else if (eat_word(p, "rec")) {
|
||||
expect(p, token::LPAREN);
|
||||
auto fields = [parse_field(p)];
|
||||
auto fields = ~[parse_field(p)];
|
||||
auto more = true;
|
||||
auto base = none;
|
||||
while (more) {
|
||||
|
@ -860,7 +862,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
|||
more = false;
|
||||
} else if (p.peek() == token::COMMA) {
|
||||
p.bump();
|
||||
fields += [parse_field(p)];
|
||||
fields += ~[parse_field(p)];
|
||||
} else { unexpected(p, p.peek()); }
|
||||
}
|
||||
ex = ast::expr_rec(fields, base);
|
||||
|
@ -873,7 +875,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
|||
}
|
||||
}
|
||||
auto es =
|
||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_expr_opt, p);
|
||||
hi = es.span.hi;
|
||||
ex = ast::expr_bind(e, es.node);
|
||||
|
@ -969,7 +971,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
|||
|
||||
let @ast::expr f = parse_self_method(p);
|
||||
auto es =
|
||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_expr, p);
|
||||
hi = es.span.hi;
|
||||
ex = ast::expr_call(f, es.node);
|
||||
|
@ -998,7 +1000,7 @@ fn parse_syntax_ext_naked(&parser p, uint lo) -> @ast::expr {
|
|||
if (ivec::len(pth.node.idents) == 0u) {
|
||||
p.fatal("expected a syntax expander name");
|
||||
}
|
||||
auto es = parse_seq(token::LPAREN, token::RPAREN,
|
||||
auto es = parse_seq_ivec(token::LPAREN, token::RPAREN,
|
||||
some(token::COMMA), parse_expr, p);
|
||||
auto hi = es.span.hi;
|
||||
auto ext_span = rec(lo=lo, hi=hi);
|
||||
|
@ -1013,7 +1015,7 @@ fn parse_syntax_ext_naked(&parser p, uint lo) -> @ast::expr {
|
|||
* loading rust crates to process extensions.
|
||||
*/
|
||||
fn expand_syntax_ext(&parser p, span sp, &ast::path path,
|
||||
vec[@ast::expr] args, option::t[str] body) ->
|
||||
&(@ast::expr)[] args, option::t[str] body) ->
|
||||
ast::expr_ {
|
||||
assert (ivec::len(path.node.idents) > 0u);
|
||||
auto extname = path.node.idents.(0);
|
||||
|
@ -1030,7 +1032,7 @@ fn expand_syntax_ext(&parser p, span sp, &ast::path path,
|
|||
auto name_and_extension = ext(ext_cx, sp, args, body);
|
||||
p.get_syntax_expanders().insert(name_and_extension._0,
|
||||
name_and_extension._1);
|
||||
ret ast::expr_tup(vec::empty[ast::elt]());
|
||||
ret ast::expr_tup(~[]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1057,7 +1059,7 @@ fn parse_dot_or_call_expr_with(&parser p, @ast::expr e) -> @ast::expr {
|
|||
// Call expr.
|
||||
|
||||
auto es =
|
||||
parse_seq(token::LPAREN, token::RPAREN,
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN,
|
||||
some(token::COMMA), parse_expr, p);
|
||||
hi = es.span.hi;
|
||||
e = mk_expr(p, lo, hi, ast::expr_call(e, es.node));
|
||||
|
@ -1349,7 +1351,7 @@ fn parse_alt_expr(&parser p) -> @ast::expr {
|
|||
auto lo = p.get_last_lo_pos();
|
||||
auto discriminant = parse_expr(p);
|
||||
expect(p, token::LBRACE);
|
||||
let vec[ast::arm] arms = [];
|
||||
let ast::arm[] arms = ~[];
|
||||
while (p.peek() != token::RBRACE) {
|
||||
// Optionally eat the case keyword.
|
||||
// FIXME remove this (and the optional parens) once we've updated our
|
||||
|
@ -1360,7 +1362,7 @@ fn parse_alt_expr(&parser p) -> @ast::expr {
|
|||
auto pat = parse_pat(p);
|
||||
if (parens) { expect(p, token::RPAREN); }
|
||||
auto block = parse_block(p);
|
||||
arms += [rec(pat=pat, block=block)];
|
||||
arms += ~[rec(pat=pat, block=block)];
|
||||
}
|
||||
auto hi = p.get_hi_pos();
|
||||
p.bump();
|
||||
|
@ -1374,7 +1376,7 @@ fn parse_spawn_expr(&parser p) -> @ast::expr {
|
|||
|
||||
auto fn_expr = parse_bottom_expr(p);
|
||||
auto es =
|
||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_expr, p);
|
||||
auto hi = es.span.hi;
|
||||
ret mk_expr(p, lo, hi, ast::expr_spawn
|
||||
|
@ -1449,17 +1451,17 @@ fn parse_pat(&parser p) -> @ast::pat {
|
|||
} else {
|
||||
auto tag_path = parse_path_and_ty_param_substs(p);
|
||||
hi = tag_path.span.hi;
|
||||
let vec[@ast::pat] args;
|
||||
let (@ast::pat)[] args;
|
||||
alt (p.peek()) {
|
||||
case (token::LPAREN) {
|
||||
auto f = parse_pat;
|
||||
auto a =
|
||||
parse_seq(token::LPAREN, token::RPAREN,
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN,
|
||||
some(token::COMMA), f, p);
|
||||
args = a.node;
|
||||
hi = a.span.hi;
|
||||
}
|
||||
case (_) { args = []; }
|
||||
case (_) { args = ~[]; }
|
||||
}
|
||||
pat = ast::pat_tag(tag_path, args);
|
||||
}
|
||||
|
@ -1645,7 +1647,7 @@ fn stmt_ends_with_semi(&ast::stmt stmt) -> bool {
|
|||
|
||||
fn parse_block(&parser p) -> ast::block {
|
||||
auto lo = p.get_lo_pos();
|
||||
let vec[@ast::stmt] stmts = [];
|
||||
let (@ast::stmt)[] stmts = ~[];
|
||||
let option::t[@ast::expr] expr = none;
|
||||
expect(p, token::LBRACE);
|
||||
while (p.peek() != token::RBRACE) {
|
||||
|
@ -1658,7 +1660,7 @@ fn parse_block(&parser p) -> ast::block {
|
|||
alt (stmt_to_expr(stmt)) {
|
||||
case (some(?e)) {
|
||||
alt (p.peek()) {
|
||||
case (token::SEMI) { p.bump(); stmts += [stmt]; }
|
||||
case (token::SEMI) { p.bump(); stmts += ~[stmt]; }
|
||||
case (token::RBRACE) { expr = some(e); }
|
||||
case (?t) {
|
||||
if (stmt_ends_with_semi(*stmt)) {
|
||||
|
@ -1668,13 +1670,13 @@ fn parse_block(&parser p) -> ast::block {
|
|||
t));
|
||||
fail;
|
||||
}
|
||||
stmts += [stmt];
|
||||
stmts += ~[stmt];
|
||||
}
|
||||
}
|
||||
}
|
||||
case (none) {
|
||||
// Not an expression statement.
|
||||
stmts += [stmt];
|
||||
stmts += ~[stmt];
|
||||
|
||||
if (p.get_file_type() == SOURCE_FILE
|
||||
&& stmt_ends_with_semi(*stmt)) {
|
||||
|
@ -1693,20 +1695,20 @@ fn parse_block(&parser p) -> ast::block {
|
|||
|
||||
fn parse_ty_param(&parser p) -> ast::ty_param { ret parse_ident(p); }
|
||||
|
||||
fn parse_ty_params(&parser p) -> vec[ast::ty_param] {
|
||||
let vec[ast::ty_param] ty_params = [];
|
||||
fn parse_ty_params(&parser p) -> ast::ty_param[] {
|
||||
let ast::ty_param[] ty_params = ~[];
|
||||
if (p.peek() == token::LBRACKET) {
|
||||
ty_params =
|
||||
parse_seq(token::LBRACKET, token::RBRACKET, some(token::COMMA),
|
||||
parse_ty_param, p).node;
|
||||
parse_seq_ivec(token::LBRACKET, token::RBRACKET,
|
||||
some(token::COMMA), parse_ty_param, p).node;
|
||||
}
|
||||
ret ty_params;
|
||||
}
|
||||
|
||||
fn parse_fn_decl(&parser p, ast::purity purity) -> ast::fn_decl {
|
||||
let ast::spanned[vec[ast::arg]] inputs =
|
||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA), parse_arg,
|
||||
p);
|
||||
let ast::spanned[ast::arg[]] inputs =
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_arg, p);
|
||||
let ty_or_bang rslt;
|
||||
auto constrs = parse_constrs(inputs.node, p).node;
|
||||
if (p.peek() == token::RARROW) {
|
||||
|
@ -1740,7 +1742,7 @@ fn parse_fn(&parser p, ast::proto proto, ast::purity purity) -> ast::_fn {
|
|||
ret rec(decl=decl, proto=proto, body=body);
|
||||
}
|
||||
|
||||
fn parse_fn_header(&parser p) -> tup(ast::ident, vec[ast::ty_param]) {
|
||||
fn parse_fn_header(&parser p) -> tup(ast::ident, ast::ty_param[]) {
|
||||
auto id = parse_value_ident(p);
|
||||
auto ty_params = parse_ty_params(p);
|
||||
ret tup(id, ty_params);
|
||||
|
@ -1791,7 +1793,7 @@ fn parse_method(&parser p) -> @ast::method {
|
|||
fn parse_dtor(&parser p) -> @ast::method {
|
||||
auto lo = p.get_last_lo_pos();
|
||||
let ast::block b = parse_block(p);
|
||||
let vec[ast::arg] inputs = [];
|
||||
let ast::arg[] inputs = ~[];
|
||||
let @ast::ty output = @spanned(lo, lo, ast::ty_nil);
|
||||
let ast::fn_decl d =
|
||||
rec(inputs=inputs,
|
||||
|
@ -1812,16 +1814,16 @@ fn parse_item_obj(&parser p, ast::layer lyr, &ast::attribute[] attrs) ->
|
|||
auto lo = p.get_last_lo_pos();
|
||||
auto ident = parse_value_ident(p);
|
||||
auto ty_params = parse_ty_params(p);
|
||||
let ast::spanned[vec[ast::obj_field]] fields =
|
||||
parse_seq[ast::obj_field](token::LPAREN, token::RPAREN,
|
||||
some(token::COMMA), parse_obj_field, p);
|
||||
let vec[@ast::method] meths = [];
|
||||
let ast::spanned[ast::obj_field[]] fields =
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_obj_field, p);
|
||||
let (@ast::method)[] meths = ~[];
|
||||
let option::t[@ast::method] dtor = none;
|
||||
expect(p, token::LBRACE);
|
||||
while (p.peek() != token::RBRACE) {
|
||||
if (eat_word(p, "drop")) {
|
||||
dtor = some(parse_dtor(p));
|
||||
} else { vec::push(meths, parse_method(p)); }
|
||||
} else { meths += ~[parse_method(p)]; }
|
||||
}
|
||||
auto hi = p.get_hi_pos();
|
||||
expect(p, token::RBRACE);
|
||||
|
@ -1840,8 +1842,8 @@ fn parse_item_res(&parser p, ast::layer lyr, &ast::attribute[] attrs) ->
|
|||
auto arg_ident = parse_value_ident(p);
|
||||
expect(p, token::RPAREN);
|
||||
auto dtor = parse_block(p);
|
||||
auto decl = rec(inputs=[rec(mode=ast::alias(false), ty=t, ident=arg_ident,
|
||||
id=p.get_id())],
|
||||
auto decl = rec(inputs=~[rec(mode=ast::alias(false), ty=t,
|
||||
ident=arg_ident, id=p.get_id())],
|
||||
output=@spanned(lo, lo, ast::ty_nil),
|
||||
purity=ast::impure_fn,
|
||||
cf=ast::return,
|
||||
|
@ -2015,7 +2017,7 @@ fn parse_item_tag(&parser p, &ast::attribute[] attrs) -> @ast::item {
|
|||
auto lo = p.get_last_lo_pos();
|
||||
auto id = parse_ident(p);
|
||||
auto ty_params = parse_ty_params(p);
|
||||
let vec[ast::variant] variants = [];
|
||||
let ast::variant[] variants = ~[];
|
||||
// Newtype syntax
|
||||
if (p.peek() == token::EQ) {
|
||||
if (p.get_bad_expr_words().contains_key(id)) {
|
||||
|
@ -2029,7 +2031,7 @@ fn parse_item_tag(&parser p, &ast::attribute[] attrs) -> @ast::item {
|
|||
args=[rec(ty=ty, id=p.get_id())],
|
||||
id=p.get_id()));
|
||||
ret mk_item(p, lo, ty.span.hi, id,
|
||||
ast::item_tag([variant], ty_params), attrs);
|
||||
ast::item_tag(~[variant], ty_params), attrs);
|
||||
}
|
||||
expect(p, token::LBRACE);
|
||||
while (p.peek() != token::RBRACE) {
|
||||
|
@ -2058,7 +2060,7 @@ fn parse_item_tag(&parser p, &ast::attribute[] attrs) -> @ast::item {
|
|||
rec(name=p.get_str(name),
|
||||
args=args,
|
||||
id=p.get_id());
|
||||
variants += [spanned(vlo, vhi, vr)];
|
||||
variants += ~[spanned(vlo, vhi, vr)];
|
||||
}
|
||||
case (token::RBRACE) {/* empty */ }
|
||||
case (_) {
|
||||
|
|
|
@ -103,7 +103,7 @@ fn item_to_str(&@ast::item i) -> str { be to_str(i, print_item); }
|
|||
|
||||
fn path_to_str(&ast::path p) -> str { be to_str(p, print_path); }
|
||||
|
||||
fn fun_to_str(&ast::_fn f, str name, vec[ast::ty_param] params) -> str {
|
||||
fn fun_to_str(&ast::_fn f, str name, &ast::ty_param[] params) -> str {
|
||||
auto writer = io::string_writer();
|
||||
auto s = rust_printer(writer.get_writer());
|
||||
print_fn(s, f.decl, f.proto, name, params);
|
||||
|
@ -257,9 +257,9 @@ fn commasep_cmnt_ivec[IN](&ps s, breaks b, &IN[] elts, fn(&ps, &IN) op,
|
|||
end(s);
|
||||
}
|
||||
|
||||
fn commasep_exprs(&ps s, breaks b, vec[@ast::expr] exprs) {
|
||||
fn commasep_exprs(&ps s, breaks b, &(@ast::expr)[] exprs) {
|
||||
fn expr_span(&@ast::expr expr) -> codemap::span { ret expr.span; }
|
||||
commasep_cmnt(s, b, exprs, print_expr, expr_span);
|
||||
commasep_cmnt_ivec(s, b, exprs, print_expr, expr_span);
|
||||
}
|
||||
|
||||
fn print_mod(&ps s, ast::_mod _mod, &ast::attribute[] attrs) {
|
||||
|
@ -463,7 +463,7 @@ fn print_item(&ps s, &@ast::item item) {
|
|||
break_offset(s.s, 0u, 0);
|
||||
}
|
||||
case (ast::item_tag(?variants, ?params)) {
|
||||
auto newtype = vec::len(variants) == 1u &&
|
||||
auto newtype = ivec::len(variants) == 1u &&
|
||||
str::eq(item.ident, variants.(0).node.name) &&
|
||||
vec::len(variants.(0).node.args) == 1u;
|
||||
if (newtype) {
|
||||
|
@ -515,12 +515,13 @@ fn print_item(&ps s, &@ast::item item) {
|
|||
end(s);
|
||||
}
|
||||
fn get_span(&ast::obj_field f) -> codemap::span { ret f.ty.span; }
|
||||
commasep_cmnt(s, consistent, _obj.fields, print_field, get_span);
|
||||
commasep_cmnt_ivec(s, consistent, _obj.fields, print_field,
|
||||
get_span);
|
||||
pclose(s);
|
||||
space(s.s);
|
||||
bopen(s);
|
||||
for (@ast::method meth in _obj.methods) {
|
||||
let vec[ast::ty_param] typarams = [];
|
||||
let ast::ty_param[] typarams = ~[];
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, meth.span.lo);
|
||||
print_fn(s, meth.node.meth.decl, meth.node.meth.proto,
|
||||
|
@ -687,7 +688,7 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
|||
fn get_span(&ast::elt elt) -> codemap::span { ret elt.expr.span; }
|
||||
word(s.s, "tup");
|
||||
popen(s);
|
||||
commasep_cmnt(s, inconsistent, exprs, printElt, get_span);
|
||||
commasep_cmnt_ivec(s, inconsistent, exprs, printElt, get_span);
|
||||
pclose(s);
|
||||
}
|
||||
case (ast::expr_rec(?fields, ?wth)) {
|
||||
|
@ -704,10 +705,10 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
|||
}
|
||||
word(s.s, "rec");
|
||||
popen(s);
|
||||
commasep_cmnt(s, consistent, fields, print_field, get_span);
|
||||
commasep_cmnt_ivec(s, consistent, fields, print_field, get_span);
|
||||
alt (wth) {
|
||||
case (some(?expr)) {
|
||||
if (vec::len(fields) > 0u) { space(s.s); }
|
||||
if (ivec::len(fields) > 0u) { space(s.s); }
|
||||
ibox(s, indent_unit);
|
||||
word_space(s, "with");
|
||||
print_expr(s, expr);
|
||||
|
@ -737,7 +738,7 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
|||
word_nbsp(s, "bind");
|
||||
print_expr(s, func);
|
||||
popen(s);
|
||||
commasep(s, inconsistent, args, print_opt);
|
||||
commasep_ivec(s, inconsistent, args, print_opt);
|
||||
pclose(s);
|
||||
}
|
||||
case (ast::expr_spawn(_, _, ?e, ?es)) {
|
||||
|
@ -959,7 +960,7 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
|||
case (ast::expr_ext(?path, ?args, ?body, _)) {
|
||||
word(s.s, "#");
|
||||
print_path(s, path);
|
||||
if (vec::len(args) > 0u) {
|
||||
if (ivec::len(args) > 0u) {
|
||||
popen(s);
|
||||
commasep_exprs(s, inconsistent, args);
|
||||
pclose(s);
|
||||
|
@ -1062,9 +1063,9 @@ fn print_pat(&ps s, &@ast::pat pat) {
|
|||
case (ast::pat_lit(?lit)) { print_literal(s, lit); }
|
||||
case (ast::pat_tag(?path, ?args)) {
|
||||
print_path(s, path);
|
||||
if (vec::len(args) > 0u) {
|
||||
if (ivec::len(args) > 0u) {
|
||||
popen(s);
|
||||
commasep(s, inconsistent, args, print_pat);
|
||||
commasep_ivec(s, inconsistent, args, print_pat);
|
||||
pclose(s);
|
||||
}
|
||||
}
|
||||
|
@ -1073,7 +1074,7 @@ fn print_pat(&ps s, &@ast::pat pat) {
|
|||
}
|
||||
|
||||
fn print_fn(&ps s, ast::fn_decl decl, ast::proto proto, str name,
|
||||
vec[ast::ty_param] typarams) {
|
||||
&ast::ty_param[] typarams) {
|
||||
alt (decl.purity) {
|
||||
case (ast::impure_fn) {
|
||||
if (proto == ast::proto_iter) {
|
||||
|
@ -1097,7 +1098,7 @@ fn print_fn_args_and_ret(&ps s, &ast::fn_decl decl) {
|
|||
word(s.s, x.ident);
|
||||
end(s);
|
||||
}
|
||||
commasep(s, inconsistent, decl.inputs, print_arg);
|
||||
commasep_ivec(s, inconsistent, decl.inputs, print_arg);
|
||||
pclose(s);
|
||||
maybe_print_comment(s, decl.output.span.lo);
|
||||
if (decl.output.node != ast::ty_nil) {
|
||||
|
@ -1115,11 +1116,11 @@ fn print_alias(&ps s, ast::mode m) {
|
|||
}
|
||||
}
|
||||
|
||||
fn print_type_params(&ps s, &vec[ast::ty_param] params) {
|
||||
if (vec::len(params) > 0u) {
|
||||
fn print_type_params(&ps s, &ast::ty_param[] params) {
|
||||
if (ivec::len(params) > 0u) {
|
||||
word(s.s, "[");
|
||||
fn printParam(&ps s, &ast::ty_param param) { word(s.s, param); }
|
||||
commasep(s, inconsistent, params, printParam);
|
||||
commasep_ivec(s, inconsistent, params, printParam);
|
||||
word(s.s, "]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ type visitor[E] =
|
|||
fn(&@expr, &E, &vt[E]) visit_expr,
|
||||
fn(&@ty, &E, &vt[E]) visit_ty,
|
||||
fn(&@constr, &E, &vt[E]) visit_constr,
|
||||
fn(&_fn, &vec[ty_param], &span, &fn_ident, node_id, &E, &vt[E])
|
||||
fn(&_fn, &ty_param[], &span, &fn_ident, node_id, &E, &vt[E])
|
||||
visit_fn);
|
||||
|
||||
fn default_visitor[E]() -> visitor[E] {
|
||||
|
@ -121,13 +121,13 @@ fn visit_item[E](&@item i, &E e, &vt[E] v) {
|
|||
case (item_obj(?ob, _, _)) {
|
||||
for (obj_field f in ob.fields) { vt(v).visit_ty(f.ty, e, v); }
|
||||
for (@method m in ob.methods) {
|
||||
vt(v).visit_fn(m.node.meth, [], m.span, some(m.node.ident),
|
||||
vt(v).visit_fn(m.node.meth, ~[], m.span, some(m.node.ident),
|
||||
m.node.id, e, v);
|
||||
}
|
||||
alt (ob.dtor) {
|
||||
case (none) { }
|
||||
case (some(?m)) {
|
||||
vt(v).visit_fn(m.node.meth, [], m.span,
|
||||
vt(v).visit_fn(m.node.meth, ~[], m.span,
|
||||
some(m.node.ident),
|
||||
m.node.id, e, v);
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ fn visit_fn_decl[E](&fn_decl fd, &E e, &vt[E] v) {
|
|||
vt(v).visit_ty(fd.output, e, v);
|
||||
}
|
||||
|
||||
fn visit_fn[E](&_fn f, &vec[ty_param] tp, &span sp, &fn_ident i,
|
||||
fn visit_fn[E](&_fn f, &ty_param[] tp, &span sp, &fn_ident i,
|
||||
node_id id, &E e, &vt[E] v) {
|
||||
visit_fn_decl(f.decl, e, v);
|
||||
vt(v).visit_block(f.body, e, v);
|
||||
|
@ -245,7 +245,7 @@ fn visit_expr_opt[E](option::t[@expr] eo, &E e, &vt[E] v) {
|
|||
}
|
||||
}
|
||||
|
||||
fn visit_exprs[E](vec[@expr] exprs, &E e, &vt[E] v) {
|
||||
fn visit_exprs[E](&(@expr)[] exprs, &E e, &vt[E] v) {
|
||||
for (@expr ex in exprs) { vt(v).visit_expr(ex, e, v); }
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ fn visit_expr[E](&@expr ex, &E e, &vt[E] v) {
|
|||
for (arm a in arms) { vt(v).visit_arm(a, e, v); }
|
||||
}
|
||||
case (expr_fn(?f)) {
|
||||
vt(v).visit_fn(f, [], ex.span, none, ex.id, e, v);
|
||||
vt(v).visit_fn(f, ~[], ex.span, none, ex.id, e, v);
|
||||
}
|
||||
case (expr_block(?b)) { vt(v).visit_block(b, e, v); }
|
||||
case (expr_assign(?a, ?b)) {
|
||||
|
@ -386,7 +386,7 @@ fn visit_expr[E](&@expr ex, &E e, &vt[E] v) {
|
|||
case (some(?ex)) { vt(v).visit_expr(ex, e, v); }
|
||||
}
|
||||
for (@method m in anon_obj.methods) {
|
||||
vt(v).visit_fn(m.node.meth, [], m.span, some(m.node.ident),
|
||||
vt(v).visit_fn(m.node.meth, ~[], m.span, some(m.node.ident),
|
||||
m.node.id, e, v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,9 +39,9 @@ type ast_visitor =
|
|||
fn(&@ast::ty) visit_ty_pre,
|
||||
fn(&@ast::ty) visit_ty_post,
|
||||
fn(&@ast::constr) visit_constr,
|
||||
fn(&ast::_fn, &vec[ast::ty_param], &span, &ast::fn_ident,
|
||||
fn(&ast::_fn, &ast::ty_param[], &span, &ast::fn_ident,
|
||||
ast::node_id) visit_fn_pre,
|
||||
fn(&ast::_fn, &vec[ast::ty_param], &span, &ast::fn_ident,
|
||||
fn(&ast::_fn, &ast::ty_param[], &span, &ast::fn_ident,
|
||||
ast::node_id) visit_fn_post);
|
||||
|
||||
fn walk_crate(&ast_visitor v, &ast::crate c) {
|
||||
|
@ -117,14 +117,14 @@ fn walk_item(&ast_visitor v, @ast::item i) {
|
|||
for (@ast::method m in ob.methods) {
|
||||
v.visit_method_pre(m);
|
||||
// Methods don't have ty params?
|
||||
walk_fn(v, m.node.meth, [], m.span,
|
||||
walk_fn(v, m.node.meth, ~[], m.span,
|
||||
some(m.node.ident), m.node.id);
|
||||
v.visit_method_post(m);
|
||||
}
|
||||
alt (ob.dtor) {
|
||||
case (none) { }
|
||||
case (some(?m)) {
|
||||
walk_fn(v, m.node.meth, [], m.span,
|
||||
walk_fn(v, m.node.meth, ~[], m.span,
|
||||
some(m.node.ident), m.node.id);
|
||||
}
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ fn walk_fn_decl(&ast_visitor v, &ast::fn_decl fd) {
|
|||
walk_ty(v, fd.output);
|
||||
}
|
||||
|
||||
fn walk_fn(&ast_visitor v, &ast::_fn f, &vec[ast::ty_param] tps,
|
||||
fn walk_fn(&ast_visitor v, &ast::_fn f, &ast::ty_param[] tps,
|
||||
&span sp, &ast::fn_ident i, ast::node_id d) {
|
||||
if (!v.keep_going()) { ret; }
|
||||
v.visit_fn_pre(f, tps, sp, i, d);
|
||||
|
@ -262,7 +262,7 @@ fn walk_expr_opt(&ast_visitor v, option::t[@ast::expr] eo) {
|
|||
alt (eo) { case (none) { } case (some(?e)) { walk_expr(v, e); } }
|
||||
}
|
||||
|
||||
fn walk_exprs(&ast_visitor v, vec[@ast::expr] exprs) {
|
||||
fn walk_exprs(&ast_visitor v, &(@ast::expr)[] exprs) {
|
||||
for (@ast::expr e in exprs) { walk_expr(v, e); }
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
|
|||
}
|
||||
}
|
||||
case (ast::expr_fn(?f)) {
|
||||
walk_fn(v, f, [], e.span, none, e.id);
|
||||
walk_fn(v, f, ~[], e.span, none, e.id);
|
||||
}
|
||||
case (ast::expr_block(?b)) { walk_block(v, b); }
|
||||
case (ast::expr_assign(?a, ?b)) {
|
||||
|
@ -402,7 +402,7 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
|
|||
// Methods
|
||||
for (@ast::method m in anon_obj.methods) {
|
||||
v.visit_method_pre(m);
|
||||
walk_fn(v, m.node.meth, [], m.span, some(m.node.ident),
|
||||
walk_fn(v, m.node.meth, ~[], m.span, some(m.node.ident),
|
||||
m.node.id);
|
||||
v.visit_method_post(m);
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ fn def_visit_ty(&@ast::ty t) { }
|
|||
|
||||
fn def_visit_constr(&@ast::constr c) { }
|
||||
|
||||
fn def_visit_fn(&ast::_fn f, &vec[ast::ty_param] tps,
|
||||
fn def_visit_fn(&ast::_fn f, &ast::ty_param[] tps,
|
||||
&span sp, &ast::fn_ident i, ast::node_id d) { }
|
||||
|
||||
fn default_visitor() -> ast_visitor {
|
||||
|
|
|
@ -50,16 +50,18 @@ fn new_def_hash[V]() -> std::map::hashmap[ast::def_id, V] {
|
|||
|
||||
fn elt_expr(&ast::elt e) -> @ast::expr { ret e.expr; }
|
||||
|
||||
fn elt_exprs(&vec[ast::elt] elts) -> vec[@ast::expr] {
|
||||
auto f = elt_expr;
|
||||
ret vec::map[ast::elt, @ast::expr](f, elts);
|
||||
fn elt_exprs(&ast::elt[] elts) -> (@ast::expr)[] {
|
||||
auto es = ~[];
|
||||
for (ast::elt e in elts) { es += ~[e.expr]; }
|
||||
ret es;
|
||||
}
|
||||
|
||||
fn field_expr(&ast::field f) -> @ast::expr { ret f.node.expr; }
|
||||
|
||||
fn field_exprs(vec[ast::field] fields) -> vec[@ast::expr] {
|
||||
auto f = field_expr;
|
||||
ret vec::map[ast::field, @ast::expr](f, fields);
|
||||
fn field_exprs(&ast::field[] fields) -> (@ast::expr)[] {
|
||||
auto es = ~[];
|
||||
for (ast::field f in fields) { es += ~[f.node.expr]; }
|
||||
ret es;
|
||||
}
|
||||
|
||||
fn log_expr(&ast::expr e) { log print::pprust::expr_to_str(@e); }
|
||||
|
@ -76,11 +78,11 @@ fn log_block_err(&ast::block b) { log_err print::pprust::block_to_str(b); }
|
|||
|
||||
fn log_item_err(&@ast::item i) { log_err print::pprust::item_to_str(i); }
|
||||
|
||||
fn log_fn(&ast::_fn f, str name, vec[ast::ty_param] params) {
|
||||
fn log_fn(&ast::_fn f, str name, &ast::ty_param[] params) {
|
||||
log print::pprust::fun_to_str(f, name, params);
|
||||
}
|
||||
|
||||
fn log_fn_err(&ast::_fn f, str name, vec[ast::ty_param] params) {
|
||||
fn log_fn_err(&ast::_fn f, str name, &ast::ty_param[] params) {
|
||||
log_err print::pprust::fun_to_str(f, name, params);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue