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
|
|
@ -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,16 +776,16 @@ 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_elt, p);
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_elt, p);
|
||||
hi = es.span.hi;
|
||||
ex = ast::expr_tup(es.node);
|
||||
} else if (p.peek() == token::LBRACKET) {
|
||||
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,8 +795,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_unique);
|
||||
}
|
||||
case (token::LIT_STR(?s)) {
|
||||
|
|
@ -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),
|
||||
parse_anon_obj_field, p));
|
||||
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,8 +875,8 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
|||
}
|
||||
}
|
||||
auto es =
|
||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_expr_opt, p);
|
||||
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);
|
||||
} else if (p.peek() == token::POUND) {
|
||||
|
|
@ -969,8 +971,8 @@ 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_expr, p);
|
||||
parse_seq_ivec(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_expr, p);
|
||||
hi = es.span.hi;
|
||||
ex = ast::expr_call(f, es.node);
|
||||
} else if (is_ident(p.peek()) && !is_word(p, "true") &&
|
||||
|
|
@ -998,8 +1000,8 @@ 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,
|
||||
some(token::COMMA), parse_expr, p);
|
||||
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);
|
||||
auto ex = expand_syntax_ext(p, ext_span, pth, es.node, none);
|
||||
|
|
@ -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,8 +1059,8 @@ fn parse_dot_or_call_expr_with(&parser p, @ast::expr e) -> @ast::expr {
|
|||
// Call expr.
|
||||
|
||||
auto es =
|
||||
parse_seq(token::LPAREN, token::RPAREN,
|
||||
some(token::COMMA), parse_expr, p);
|
||||
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,8 +1376,8 @@ 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_expr, p);
|
||||
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
|
||||
(ast::dom_implicit, option::none, fn_expr, es.node));
|
||||
|
|
@ -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,
|
||||
some(token::COMMA), f, p);
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue