rustc: Remove all exterior vectors from the AST
This commit is contained in:
parent
3958c72cd8
commit
e1b107d74e
12 changed files with 62 additions and 70 deletions
|
@ -36,9 +36,9 @@ fn filter_item(&ast::crate_cfg cfg,
|
||||||
fn fold_mod(&ast::crate_cfg cfg, &ast::_mod m,
|
fn fold_mod(&ast::crate_cfg cfg, &ast::_mod m,
|
||||||
fold::ast_fold fld) -> ast::_mod {
|
fold::ast_fold fld) -> ast::_mod {
|
||||||
auto filter = bind filter_item(cfg, _);
|
auto filter = bind filter_item(cfg, _);
|
||||||
auto filtered_items = vec::filter_map(filter, m.items);
|
auto filtered_items = ivec::filter_map(filter, m.items);
|
||||||
ret rec(view_items=vec::map(fld.fold_view_item, m.view_items),
|
ret rec(view_items=ivec::map(fld.fold_view_item, m.view_items),
|
||||||
items=vec::map(fld.fold_item, filtered_items));
|
items=ivec::map(fld.fold_item, filtered_items));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn filter_native_item(&ast::crate_cfg cfg, &@ast::native_item item)
|
fn filter_native_item(&ast::crate_cfg cfg, &@ast::native_item item)
|
||||||
|
@ -53,10 +53,10 @@ fn filter_native_item(&ast::crate_cfg cfg, &@ast::native_item item)
|
||||||
fn fold_native_mod(&ast::crate_cfg cfg, &ast::native_mod nm,
|
fn fold_native_mod(&ast::crate_cfg cfg, &ast::native_mod nm,
|
||||||
fold::ast_fold fld) -> ast::native_mod {
|
fold::ast_fold fld) -> ast::native_mod {
|
||||||
auto filter = bind filter_native_item(cfg, _);
|
auto filter = bind filter_native_item(cfg, _);
|
||||||
auto filtered_items = vec::filter_map(filter, nm.items);
|
auto filtered_items = ivec::filter_map(filter, nm.items);
|
||||||
ret rec(native_name=nm.native_name,
|
ret rec(native_name=nm.native_name,
|
||||||
abi=nm.abi,
|
abi=nm.abi,
|
||||||
view_items=vec::map(fld.fold_view_item, nm.view_items),
|
view_items=ivec::map(fld.fold_view_item, nm.view_items),
|
||||||
items=filtered_items);
|
items=filtered_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,14 +50,12 @@ fn fold_crate(&test_ctxt cx, &ast::crate_ c,
|
||||||
|
|
||||||
fn add_test_module(&test_ctxt cx, &ast::_mod m) -> ast::_mod {
|
fn add_test_module(&test_ctxt cx, &ast::_mod m) -> ast::_mod {
|
||||||
auto testmod = mk_test_module(cx);
|
auto testmod = mk_test_module(cx);
|
||||||
ret rec(items = m.items + [testmod]
|
ret rec(items=m.items + ~[testmod] with m);
|
||||||
with m);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_test_module(&test_ctxt cx) -> @ast::item {
|
fn mk_test_module(&test_ctxt cx) -> @ast::item {
|
||||||
auto mainfn = mk_main(cx);
|
auto mainfn = mk_main(cx);
|
||||||
let ast::_mod testmod = rec(view_items = [],
|
let ast::_mod testmod = rec(view_items=~[], items=~[mainfn]);
|
||||||
items = [mainfn]);
|
|
||||||
auto item_ = ast::item_mod(testmod);
|
auto item_ = ast::item_mod(testmod);
|
||||||
let ast::item item = rec(ident = "__test",
|
let ast::item item = rec(ident = "__test",
|
||||||
attrs = ~[],
|
attrs = ~[],
|
||||||
|
|
|
@ -216,7 +216,7 @@ fn encode_tag_variant_info(&@crate_ctxt cx, &ebml::writer ebml_w,
|
||||||
encode_kind(ebml_w, 'v' as u8);
|
encode_kind(ebml_w, 'v' as u8);
|
||||||
encode_tag_id(ebml_w, local_def(id));
|
encode_tag_id(ebml_w, local_def(id));
|
||||||
encode_type(cx, ebml_w, node_id_to_monotype(cx.tcx, variant.node.id));
|
encode_type(cx, ebml_w, node_id_to_monotype(cx.tcx, variant.node.id));
|
||||||
if (vec::len[variant_arg](variant.node.args) > 0u) {
|
if (ivec::len[variant_arg](variant.node.args) > 0u) {
|
||||||
encode_symbol(cx, ebml_w, variant.node.id);
|
encode_symbol(cx, ebml_w, variant.node.id);
|
||||||
}
|
}
|
||||||
encode_discriminant(cx, ebml_w, variant.node.id);
|
encode_discriminant(cx, ebml_w, variant.node.id);
|
||||||
|
|
|
@ -382,16 +382,15 @@ fn visit_expr_with_scope(&@ast::expr x, &scopes sc, &vt[scopes] v) {
|
||||||
visit::visit_expr(x, new_sc, v);
|
visit::visit_expr(x, new_sc, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn follow_import(&env e, &scopes sc,
|
fn follow_import(&env e, &scopes sc, &ident[] path, &span sp)
|
||||||
vec[ident] path, &span sp) -> option::t[def] {
|
-> option::t[def] {
|
||||||
auto path_len = vec::len(path);
|
auto path_len = ivec::len(path);
|
||||||
auto dcur = lookup_in_scope_strict(e, sc, sp, path.(0), ns_module);
|
auto dcur = lookup_in_scope_strict(e, sc, sp, path.(0), ns_module);
|
||||||
auto i = 1u;
|
auto i = 1u;
|
||||||
while (true && option::is_some(dcur)) {
|
while (true && option::is_some(dcur)) {
|
||||||
if (i == path_len) { break; }
|
if (i == path_len) { break; }
|
||||||
dcur =
|
dcur = lookup_in_mod_strict(e, option::get(dcur),
|
||||||
lookup_in_mod_strict(e, option::get(dcur),
|
sp, path.(i), ns_module, outside);
|
||||||
sp, path.(i), ns_module, outside);
|
|
||||||
i += 1u;
|
i += 1u;
|
||||||
}
|
}
|
||||||
if (i == path_len) {
|
if (i == path_len) {
|
||||||
|
@ -399,8 +398,7 @@ fn follow_import(&env e, &scopes sc,
|
||||||
case (ast::def_mod(?def_id)) { ret dcur; }
|
case (ast::def_mod(?def_id)) { ret dcur; }
|
||||||
case (ast::def_native_mod(?def_id)) { ret dcur; }
|
case (ast::def_native_mod(?def_id)) { ret dcur; }
|
||||||
case (_) {
|
case (_) {
|
||||||
e.sess.span_err(sp,
|
e.sess.span_err(sp, str::connect_ivec(path, "::") +
|
||||||
str::connect(path, "::") +
|
|
||||||
" does not name a module.");
|
" does not name a module.");
|
||||||
ret none;
|
ret none;
|
||||||
}
|
}
|
||||||
|
@ -457,7 +455,7 @@ fn resolve_import(&env e, &@ast::view_item it, &scopes sc) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e.imports.insert(defid._1, resolving(it.span));
|
e.imports.insert(defid._1, resolving(it.span));
|
||||||
auto n_idents = vec::len(ids);
|
auto n_idents = ivec::len(ids);
|
||||||
auto end_id = ids.(n_idents - 1u);
|
auto end_id = ids.(n_idents - 1u);
|
||||||
if (n_idents == 1u) {
|
if (n_idents == 1u) {
|
||||||
auto next_sc = std::list::cdr(sc);
|
auto next_sc = std::list::cdr(sc);
|
||||||
|
|
|
@ -8529,7 +8529,7 @@ fn trans_res_ctor(@local_ctxt cx, &span sp, &ast::_fn dtor,
|
||||||
fn trans_tag_variant(@local_ctxt cx, ast::node_id tag_id,
|
fn trans_tag_variant(@local_ctxt cx, ast::node_id tag_id,
|
||||||
&ast::variant variant, int index, bool is_degen,
|
&ast::variant variant, int index, bool is_degen,
|
||||||
&ast::ty_param[] ty_params) {
|
&ast::ty_param[] ty_params) {
|
||||||
if (vec::len[ast::variant_arg](variant.node.args) == 0u) {
|
if (std::ivec::len[ast::variant_arg](variant.node.args) == 0u) {
|
||||||
ret; // nullary constructors are just constants
|
ret; // nullary constructors are just constants
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9043,7 +9043,7 @@ fn collect_tag_ctor(@crate_ctxt ccx, &@ast::item i, &vec[str] pt,
|
||||||
alt (i.node) {
|
alt (i.node) {
|
||||||
case (ast::item_tag(?variants, ?tps)) {
|
case (ast::item_tag(?variants, ?tps)) {
|
||||||
for (ast::variant variant in variants) {
|
for (ast::variant variant in variants) {
|
||||||
if (vec::len[ast::variant_arg](variant.node.args) != 0u) {
|
if (std::ivec::len(variant.node.args) != 0u) {
|
||||||
decl_fn_and_pair(ccx, i.span,
|
decl_fn_and_pair(ccx, i.span,
|
||||||
new_pt + [variant.node.name], "tag", tps,
|
new_pt + [variant.node.name], "tag", tps,
|
||||||
variant.node.id);
|
variant.node.id);
|
||||||
|
|
|
@ -2830,8 +2830,7 @@ fn tag_variants(&ctxt cx, &ast::def_id id) -> variant_info[] {
|
||||||
auto ctor_ty = node_id_to_monotype
|
auto ctor_ty = node_id_to_monotype
|
||||||
(cx, variant.node.id);
|
(cx, variant.node.id);
|
||||||
let t[] arg_tys = ~[];
|
let t[] arg_tys = ~[];
|
||||||
if (vec::len[ast::variant_arg](variant.node.args) >
|
if (std::ivec::len(variant.node.args) > 0u) {
|
||||||
0u) {
|
|
||||||
for (arg a in ty_fn_args(cx, ctor_ty)) {
|
for (arg a in ty_fn_args(cx, ctor_ty)) {
|
||||||
arg_tys += ~[a.ty];
|
arg_tys += ~[a.ty];
|
||||||
}
|
}
|
||||||
|
|
|
@ -692,7 +692,7 @@ mod collect {
|
||||||
// constructors get turned into functions.
|
// constructors get turned into functions.
|
||||||
|
|
||||||
auto result_ty;
|
auto result_ty;
|
||||||
if (vec::len[ast::variant_arg](variant.node.args) == 0u) {
|
if (ivec::len[ast::variant_arg](variant.node.args) == 0u) {
|
||||||
result_ty = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
|
result_ty = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
|
||||||
} else {
|
} else {
|
||||||
// As above, tell ast_ty_to_ty() that trans_ty_item_to_ty()
|
// As above, tell ast_ty_to_ty() that trans_ty_item_to_ty()
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import std::ivec;
|
import std::ivec;
|
||||||
import std::option;
|
import std::option;
|
||||||
import std::str;
|
import std::str;
|
||||||
import std::vec;
|
|
||||||
import codemap::span;
|
import codemap::span;
|
||||||
import codemap::filename;
|
import codemap::filename;
|
||||||
|
|
||||||
|
@ -481,7 +480,7 @@ type anon_obj =
|
||||||
// with_obj: the original object being extended, if it exists.
|
// with_obj: the original object being extended, if it exists.
|
||||||
option::t[@expr] with_obj);
|
option::t[@expr] with_obj);
|
||||||
|
|
||||||
type _mod = rec(vec[@view_item] view_items, vec[@item] items);
|
type _mod = rec((@view_item)[] view_items, (@item)[] items);
|
||||||
|
|
||||||
tag native_abi {
|
tag native_abi {
|
||||||
native_abi_rust;
|
native_abi_rust;
|
||||||
|
@ -493,12 +492,12 @@ tag native_abi {
|
||||||
type native_mod =
|
type native_mod =
|
||||||
rec(str native_name,
|
rec(str native_name,
|
||||||
native_abi abi,
|
native_abi abi,
|
||||||
vec[@view_item] view_items,
|
(@view_item)[] view_items,
|
||||||
vec[@native_item] items);
|
(@native_item)[] items);
|
||||||
|
|
||||||
type variant_arg = rec(@ty ty, node_id id);
|
type variant_arg = rec(@ty ty, node_id id);
|
||||||
|
|
||||||
type variant_ = rec(str name, vec[variant_arg] args, node_id id);
|
type variant_ = rec(str name, (variant_arg)[] args, node_id id);
|
||||||
|
|
||||||
type variant = spanned[variant_];
|
type variant = spanned[variant_];
|
||||||
|
|
||||||
|
@ -506,8 +505,8 @@ type view_item = spanned[view_item_];
|
||||||
|
|
||||||
tag view_item_ {
|
tag view_item_ {
|
||||||
view_item_use(ident, (@meta_item)[], node_id);
|
view_item_use(ident, (@meta_item)[], node_id);
|
||||||
view_item_import(ident, vec[ident], node_id);
|
view_item_import(ident, ident[], node_id);
|
||||||
view_item_import_glob(vec[ident], node_id);
|
view_item_import_glob(ident[], node_id);
|
||||||
view_item_export(ident, node_id);
|
view_item_export(ident, node_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -463,15 +463,15 @@ fn noop_fold_fn(&_fn f, ast_fold fld) -> _fn {
|
||||||
|
|
||||||
// ...nor do modules
|
// ...nor do modules
|
||||||
fn noop_fold_mod(&_mod m, ast_fold fld) -> _mod {
|
fn noop_fold_mod(&_mod m, ast_fold fld) -> _mod {
|
||||||
ret rec(view_items=map(fld.fold_view_item, m.view_items),
|
ret rec(view_items=ivec::map(fld.fold_view_item, m.view_items),
|
||||||
items=map(fld.fold_item, m.items));
|
items=ivec::map(fld.fold_item, m.items));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_native_mod(&native_mod nm, ast_fold fld) -> native_mod {
|
fn noop_fold_native_mod(&native_mod nm, ast_fold fld) -> native_mod {
|
||||||
ret rec(native_name=nm.native_name,
|
ret rec(native_name=nm.native_name,
|
||||||
abi=nm.abi,
|
abi=nm.abi,
|
||||||
view_items=map(fld.fold_view_item, nm.view_items),
|
view_items=ivec::map(fld.fold_view_item, nm.view_items),
|
||||||
items=map(fld.fold_native_item, nm.items))
|
items=ivec::map(fld.fold_native_item, nm.items))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_variant(&variant_ v, ast_fold fld) -> variant_ {
|
fn noop_fold_variant(&variant_ v, ast_fold fld) -> variant_ {
|
||||||
|
@ -480,7 +480,7 @@ fn noop_fold_variant(&variant_ v, ast_fold fld) -> variant_ {
|
||||||
}
|
}
|
||||||
auto fold_variant_arg = bind fold_variant_arg_(_,fld);
|
auto fold_variant_arg = bind fold_variant_arg_(_,fld);
|
||||||
ret rec(name=v.name,
|
ret rec(name=v.name,
|
||||||
args=map(fold_variant_arg, v.args),
|
args=ivec::map(fold_variant_arg, v.args),
|
||||||
id=v.id);
|
id=v.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@ type ctx =
|
||||||
ast::crate_cfg cfg);
|
ast::crate_cfg cfg);
|
||||||
|
|
||||||
fn eval_crate_directives(ctx cx, &(@ast::crate_directive)[] cdirs,
|
fn eval_crate_directives(ctx cx, &(@ast::crate_directive)[] cdirs,
|
||||||
str prefix, &mutable vec[@ast::view_item] view_items,
|
str prefix, &mutable (@ast::view_item)[] view_items,
|
||||||
&mutable vec[@ast::item] items) {
|
&mutable (@ast::item)[] items) {
|
||||||
for (@ast::crate_directive sub_cdir in cdirs) {
|
for (@ast::crate_directive sub_cdir in cdirs) {
|
||||||
eval_crate_directive(cx, sub_cdir, prefix, view_items, items);
|
eval_crate_directive(cx, sub_cdir, prefix, view_items, items);
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,15 @@ fn eval_crate_directives(ctx cx, &(@ast::crate_directive)[] cdirs,
|
||||||
|
|
||||||
fn eval_crate_directives_to_mod(ctx cx, &(@ast::crate_directive)[] cdirs,
|
fn eval_crate_directives_to_mod(ctx cx, &(@ast::crate_directive)[] cdirs,
|
||||||
str prefix) -> ast::_mod {
|
str prefix) -> ast::_mod {
|
||||||
let vec[@ast::view_item] view_items = [];
|
let (@ast::view_item)[] view_items = ~[];
|
||||||
let vec[@ast::item] items = [];
|
let (@ast::item)[] items = ~[];
|
||||||
eval_crate_directives(cx, cdirs, prefix, view_items, items);
|
eval_crate_directives(cx, cdirs, prefix, view_items, items);
|
||||||
ret rec(view_items=view_items, items=items);
|
ret rec(view_items=view_items, items=items);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
|
fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
|
||||||
&mutable vec[@ast::view_item] view_items,
|
&mutable (@ast::view_item)[] view_items,
|
||||||
&mutable vec[@ast::item] items) {
|
&mutable (@ast::item)[] items) {
|
||||||
alt (cdir.node) {
|
alt (cdir.node) {
|
||||||
case (ast::cdir_src_mod(?id, ?file_opt, ?attrs)) {
|
case (ast::cdir_src_mod(?id, ?file_opt, ?attrs)) {
|
||||||
auto file_path = id + ".rs";
|
auto file_path = id + ".rs";
|
||||||
|
@ -68,7 +68,7 @@ fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
|
||||||
mod_attrs);
|
mod_attrs);
|
||||||
// Thread defids and chpos through the parsers
|
// Thread defids and chpos through the parsers
|
||||||
cx.chpos = p0.get_chpos();
|
cx.chpos = p0.get_chpos();
|
||||||
vec::push[@ast::item](items, i);
|
items += ~[i];
|
||||||
}
|
}
|
||||||
case (ast::cdir_dir_mod(?id, ?dir_opt, ?cdirs, ?attrs)) {
|
case (ast::cdir_dir_mod(?id, ?dir_opt, ?cdirs, ?attrs)) {
|
||||||
auto path = id;
|
auto path = id;
|
||||||
|
@ -85,11 +85,9 @@ fn eval_crate_directive(ctx cx, @ast::crate_directive cdir, str prefix,
|
||||||
node=ast::item_mod(m0),
|
node=ast::item_mod(m0),
|
||||||
span=cdir.span);
|
span=cdir.span);
|
||||||
cx.sess.next_id += 1;
|
cx.sess.next_id += 1;
|
||||||
vec::push[@ast::item](items, i);
|
items += ~[i];
|
||||||
}
|
|
||||||
case (ast::cdir_view_item(?vi)) {
|
|
||||||
vec::push[@ast::view_item](view_items, vi);
|
|
||||||
}
|
}
|
||||||
|
case (ast::cdir_view_item(?vi)) { view_items += ~[vi]; }
|
||||||
case (ast::cdir_syntax(?pth)) { }
|
case (ast::cdir_syntax(?pth)) { }
|
||||||
case (ast::cdir_auth(?pth, ?eff)) { }
|
case (ast::cdir_auth(?pth, ?eff)) { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1859,15 +1859,15 @@ fn parse_mod_items(&parser p, token::token term,
|
||||||
parse_view(p)
|
parse_view(p)
|
||||||
} else {
|
} else {
|
||||||
// Shouldn't be any view items since we've already parsed an item attr
|
// Shouldn't be any view items since we've already parsed an item attr
|
||||||
[]
|
~[]
|
||||||
};
|
};
|
||||||
let vec[@ast::item] items = [];
|
let (@ast::item)[] items = ~[];
|
||||||
auto initial_attrs = first_item_attrs;
|
auto initial_attrs = first_item_attrs;
|
||||||
while (p.peek() != term) {
|
while (p.peek() != term) {
|
||||||
auto attrs = initial_attrs + parse_outer_attributes(p);
|
auto attrs = initial_attrs + parse_outer_attributes(p);
|
||||||
initial_attrs = ~[];
|
initial_attrs = ~[];
|
||||||
alt (parse_item(p, attrs)) {
|
alt (parse_item(p, attrs)) {
|
||||||
case (got_item(?i)) { vec::push(items, i); }
|
case (got_item(?i)) { items += ~[i]; }
|
||||||
case (_) {
|
case (_) {
|
||||||
p.fatal("expected item but found " +
|
p.fatal("expected item but found " +
|
||||||
token::to_str(p.get_reader(), p.peek()));
|
token::to_str(p.get_reader(), p.peek()));
|
||||||
|
@ -1948,14 +1948,14 @@ fn parse_native_mod_items(&parser p, &str native_name, ast::native_abi abi,
|
||||||
parse_native_view(p)
|
parse_native_view(p)
|
||||||
} else {
|
} else {
|
||||||
// Shouldn't be any view items since we've already parsed an item attr
|
// Shouldn't be any view items since we've already parsed an item attr
|
||||||
[]
|
~[]
|
||||||
};
|
};
|
||||||
let vec[@ast::native_item] items = [];
|
let (@ast::native_item)[] items = ~[];
|
||||||
auto initial_attrs = first_item_attrs;
|
auto initial_attrs = first_item_attrs;
|
||||||
while (p.peek() != token::RBRACE) {
|
while (p.peek() != token::RBRACE) {
|
||||||
auto attrs = initial_attrs + parse_outer_attributes(p);
|
auto attrs = initial_attrs + parse_outer_attributes(p);
|
||||||
initial_attrs = ~[];
|
initial_attrs = ~[];
|
||||||
items += [parse_native_item(p, attrs)];
|
items += ~[parse_native_item(p, attrs)];
|
||||||
}
|
}
|
||||||
ret rec(native_name=native_name,
|
ret rec(native_name=native_name,
|
||||||
abi=abi,
|
abi=abi,
|
||||||
|
@ -2028,7 +2028,7 @@ fn parse_item_tag(&parser p, &ast::attribute[] attrs) -> @ast::item {
|
||||||
expect(p, token::SEMI);
|
expect(p, token::SEMI);
|
||||||
auto variant = spanned(ty.span.lo, ty.span.hi,
|
auto variant = spanned(ty.span.lo, ty.span.hi,
|
||||||
rec(name=id,
|
rec(name=id,
|
||||||
args=[rec(ty=ty, id=p.get_id())],
|
args=~[rec(ty=ty, id=p.get_id())],
|
||||||
id=p.get_id()));
|
id=p.get_id()));
|
||||||
ret mk_item(p, lo, ty.span.hi, id,
|
ret mk_item(p, lo, ty.span.hi, id,
|
||||||
ast::item_tag(~[variant], ty_params), attrs);
|
ast::item_tag(~[variant], ty_params), attrs);
|
||||||
|
@ -2041,14 +2041,14 @@ fn parse_item_tag(&parser p, &ast::attribute[] attrs) -> @ast::item {
|
||||||
check_bad_word(p);
|
check_bad_word(p);
|
||||||
auto vlo = p.get_lo_pos();
|
auto vlo = p.get_lo_pos();
|
||||||
p.bump();
|
p.bump();
|
||||||
let vec[ast::variant_arg] args = [];
|
let ast::variant_arg[] args = ~[];
|
||||||
alt (p.peek()) {
|
alt (p.peek()) {
|
||||||
case (token::LPAREN) {
|
case (token::LPAREN) {
|
||||||
auto arg_tys =
|
auto arg_tys =
|
||||||
parse_seq(token::LPAREN, token::RPAREN,
|
parse_seq(token::LPAREN, token::RPAREN,
|
||||||
some(token::COMMA), parse_ty, p);
|
some(token::COMMA), parse_ty, p);
|
||||||
for (@ast::ty ty in arg_tys.node) {
|
for (@ast::ty ty in arg_tys.node) {
|
||||||
args += [rec(ty=ty, id=p.get_id())];
|
args += ~[rec(ty=ty, id=p.get_id())];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case (_) {/* empty */ }
|
case (_) {/* empty */ }
|
||||||
|
@ -2243,7 +2243,7 @@ fn parse_rest_import_name(&parser p, ast::ident first,
|
||||||
option::t[ast::ident] def_ident) ->
|
option::t[ast::ident] def_ident) ->
|
||||||
@ast::view_item {
|
@ast::view_item {
|
||||||
auto lo = p.get_lo_pos();
|
auto lo = p.get_lo_pos();
|
||||||
let vec[ast::ident] identifiers = [first];
|
let ast::ident[] identifiers = ~[first];
|
||||||
let bool glob = false;
|
let bool glob = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
alt (p.peek()) {
|
alt (p.peek()) {
|
||||||
|
@ -2255,7 +2255,7 @@ fn parse_rest_import_name(&parser p, ast::ident first,
|
||||||
case (_) { p.fatal("expecting '::' or ';'"); }
|
case (_) { p.fatal("expecting '::' or ';'"); }
|
||||||
}
|
}
|
||||||
alt (p.peek()) {
|
alt (p.peek()) {
|
||||||
case (token::IDENT(_, _)) { identifiers += [parse_ident(p)]; }
|
case (token::IDENT(_, _)) { identifiers += ~[parse_ident(p)]; }
|
||||||
case (
|
case (
|
||||||
//the lexer can't tell the different kinds of stars apart ) :
|
//the lexer can't tell the different kinds of stars apart ) :
|
||||||
token::BINOP(token::STAR)) {
|
token::BINOP(token::STAR)) {
|
||||||
|
@ -2278,7 +2278,7 @@ fn parse_rest_import_name(&parser p, ast::ident first,
|
||||||
import_decl =
|
import_decl =
|
||||||
ast::view_item_import_glob(identifiers, p.get_id());
|
ast::view_item_import_glob(identifiers, p.get_id());
|
||||||
} else {
|
} else {
|
||||||
auto len = vec::len(identifiers);
|
auto len = ivec::len(identifiers);
|
||||||
import_decl =
|
import_decl =
|
||||||
ast::view_item_import(identifiers.(len - 1u), identifiers,
|
ast::view_item_import(identifiers.(len - 1u), identifiers,
|
||||||
p.get_id());
|
p.get_id());
|
||||||
|
@ -2347,15 +2347,15 @@ fn is_view_item(&parser p) -> bool {
|
||||||
ret false;
|
ret false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_view(&parser p) -> vec[@ast::view_item] {
|
fn parse_view(&parser p) -> (@ast::view_item)[] {
|
||||||
let vec[@ast::view_item] items = [];
|
let (@ast::view_item)[] items = ~[];
|
||||||
while (is_view_item(p)) { items += [parse_view_item(p)]; }
|
while (is_view_item(p)) { items += ~[parse_view_item(p)]; }
|
||||||
ret items;
|
ret items;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_native_view(&parser p) -> vec[@ast::view_item] {
|
fn parse_native_view(&parser p) -> (@ast::view_item)[] {
|
||||||
let vec[@ast::view_item] items = [];
|
let (@ast::view_item)[] items = ~[];
|
||||||
while (is_view_item(p)) { items += [parse_view_item(p)]; }
|
while (is_view_item(p)) { items += ~[parse_view_item(p)]; }
|
||||||
ret items;
|
ret items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -465,7 +465,7 @@ fn print_item(&ps s, &@ast::item item) {
|
||||||
case (ast::item_tag(?variants, ?params)) {
|
case (ast::item_tag(?variants, ?params)) {
|
||||||
auto newtype = ivec::len(variants) == 1u &&
|
auto newtype = ivec::len(variants) == 1u &&
|
||||||
str::eq(item.ident, variants.(0).node.name) &&
|
str::eq(item.ident, variants.(0).node.name) &&
|
||||||
vec::len(variants.(0).node.args) == 1u;
|
ivec::len(variants.(0).node.args) == 1u;
|
||||||
if (newtype) {
|
if (newtype) {
|
||||||
ibox(s, indent_unit);
|
ibox(s, indent_unit);
|
||||||
word_space(s, "tag");
|
word_space(s, "tag");
|
||||||
|
@ -486,13 +486,13 @@ fn print_item(&ps s, &@ast::item item) {
|
||||||
space(s.s);
|
space(s.s);
|
||||||
maybe_print_comment(s, v.span.lo);
|
maybe_print_comment(s, v.span.lo);
|
||||||
word(s.s, v.node.name);
|
word(s.s, v.node.name);
|
||||||
if (vec::len(v.node.args) > 0u) {
|
if (ivec::len(v.node.args) > 0u) {
|
||||||
popen(s);
|
popen(s);
|
||||||
fn print_variant_arg(&ps s, &ast::variant_arg arg) {
|
fn print_variant_arg(&ps s, &ast::variant_arg arg) {
|
||||||
print_type(s, *arg.ty);
|
print_type(s, *arg.ty);
|
||||||
}
|
}
|
||||||
commasep(s, consistent, v.node.args,
|
commasep_ivec(s, consistent, v.node.args,
|
||||||
print_variant_arg);
|
print_variant_arg);
|
||||||
pclose(s);
|
pclose(s);
|
||||||
}
|
}
|
||||||
word(s.s, ";");
|
word(s.s, ";");
|
||||||
|
@ -1161,7 +1161,7 @@ fn print_view_item(&ps s, &@ast::view_item item) {
|
||||||
}
|
}
|
||||||
case (ast::view_item_import(?id, ?ids, _)) {
|
case (ast::view_item_import(?id, ?ids, _)) {
|
||||||
head(s, "import");
|
head(s, "import");
|
||||||
if (!str::eq(id, ids.(vec::len(ids) - 1u))) {
|
if (!str::eq(id, ids.(ivec::len(ids) - 1u))) {
|
||||||
word_space(s, id);
|
word_space(s, id);
|
||||||
word_space(s, "=");
|
word_space(s, "=");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue