rustc: Move crate directives over to interior vectors

This commit is contained in:
Patrick Walton 2011-07-05 17:50:14 -07:00
parent c927d97fa0
commit 3f6c9f8d84
4 changed files with 12 additions and 13 deletions

View File

@ -85,7 +85,7 @@ type crate_cfg = vec[@meta_item];
type crate = spanned[crate_];
type crate_ = rec(vec[@crate_directive] directives,
type crate_ = rec((@crate_directive)[] directives,
_mod module,
attribute[] attrs,
crate_cfg config);
@ -93,7 +93,7 @@ type crate_ = rec(vec[@crate_directive] directives,
tag crate_directive_ {
cdir_src_mod(ident, option::t[filename], attribute[]);
cdir_dir_mod(ident, option::t[filename],
vec[@crate_directive], attribute[]);
(@crate_directive)[], attribute[]);
cdir_view_item(@view_item);
cdir_syntax(path);
cdir_auth(path, _auth);

View File

@ -131,7 +131,7 @@ fn noop_fold_crate(&crate_ c, ast_fold fld) -> crate_ {
auto fold_meta_item = bind fold_meta_item_(_,fld);
auto fold_attribute = bind fold_attribute_(_,fold_meta_item);
ret rec(directives=vec::map(fld.fold_crate_directive, c.directives),
ret rec(directives=ivec::map(fld.fold_crate_directive, c.directives),
module=fld.fold_mod(c.module),
attrs=ivec::map(fold_attribute, c.attrs),
config=vec::map(fold_meta_item, c.config));
@ -145,7 +145,7 @@ fn noop_fold_crate_directive(&crate_directive_ cd, ast_fold fld)
}
case(cdir_dir_mod(?id,?fname,?cds,?attrs)) {
cdir_dir_mod(fld.fold_ident(id),fname,
map(fld.fold_crate_directive, cds), attrs)
ivec::map(fld.fold_crate_directive, cds), attrs)
}
case(cdir_view_item(?vi)) {
cdir_view_item(fld.fold_view_item(vi))

View File

@ -24,7 +24,7 @@ type ctx =
mutable uint chpos,
ast::crate_cfg cfg);
fn eval_crate_directives(ctx cx, vec[@ast::crate_directive] cdirs,
fn eval_crate_directives(ctx cx, &(@ast::crate_directive)[] cdirs,
str prefix, &mutable vec[@ast::view_item] view_items,
&mutable vec[@ast::item] items) {
for (@ast::crate_directive sub_cdir in cdirs) {
@ -32,9 +32,8 @@ fn eval_crate_directives(ctx cx, vec[@ast::crate_directive] cdirs,
}
}
fn eval_crate_directives_to_mod(ctx cx,
vec[@ast::crate_directive] cdirs, str prefix)
-> ast::_mod {
fn eval_crate_directives_to_mod(ctx cx, &(@ast::crate_directive)[] cdirs,
str prefix) -> ast::_mod {
let vec[@ast::view_item] view_items = [];
let vec[@ast::item] items = [];
eval_crate_directives(cx, cdirs, prefix, view_items, items);

View File

@ -2338,7 +2338,7 @@ fn parse_crate_from_source_file(&str input, &ast::crate_cfg cfg,
auto first_item_outer_attrs = crate_attrs._1;
auto m = parse_mod_items(p, token::EOF,
first_item_outer_attrs);
ret @spanned(lo, p.get_lo_pos(), rec(directives=[],
ret @spanned(lo, p.get_lo_pos(), rec(directives=~[],
module=m,
attrs=crate_attrs._0,
config=p.get_cfg()));
@ -2420,8 +2420,8 @@ fn parse_crate_directive(&parser p, &ast::attribute[] first_outer_attr)
}
fn parse_crate_directives(&parser p, token::token term,
&ast::attribute[] first_outer_attr) ->
vec[@ast::crate_directive] {
&ast::attribute[] first_outer_attr)
-> (@ast::crate_directive)[] {
// This is pretty ugly. If we have an outer attribute then we can't accept
// seeing the terminator next, so if we do see it then fail the same way
@ -2430,10 +2430,10 @@ fn parse_crate_directives(&parser p, token::token term,
expect_word(p, "mod");
}
let vec[@ast::crate_directive] cdirs = [];
let (@ast::crate_directive)[] cdirs = ~[];
while (p.peek() != term) {
auto cdir = @parse_crate_directive(p, first_outer_attr);
vec::push(cdirs, cdir);
cdirs += ~[cdir];
}
ret cdirs;
}