convert ast::crate_ into a struct.

This commit is contained in:
Erick Tryzelaar 2013-01-14 19:06:59 -08:00
parent eb8fd119c6
commit 0b9e23146b
6 changed files with 23 additions and 16 deletions

View File

@ -69,7 +69,7 @@ fn inject_libcore_ref(sess: Session,
new_module = fld.fold_mod(new_module);
// XXX: Bad copy.
let new_crate = { module: new_module, ..copy crate };
let new_crate = ast::crate_ { module: new_module, ..copy crate };
(new_crate, span)
},
fold_mod: |module, fld| {

View File

@ -37,8 +37,13 @@ fn inject_intrinsic(sess: Session, crate: @ast::crate) -> @ast::crate {
let items = vec::append(~[item], crate.node.module.items);
@ast::spanned {
node: { module: { items: items ,.. /*bad*/copy crate.node.module },
.. /*bad*/copy crate.node},
node: ast::crate_ {
module: {
items: items,
.. /*bad*/copy crate.node.module
},
.. /*bad*/copy crate.node
},
.. /*bad*/copy *crate
}
}

View File

@ -113,7 +113,8 @@ fn fold_crate(cx: test_ctxt, c: ast::crate_, fld: fold::ast_fold) ->
// Add a special __test module to the crate that will contain code
// generated for the test harness
return {module: add_test_module(cx, /*bad*/copy folded.module),.. folded};
ast::crate_ { module: add_test_module(cx, /*bad*/copy folded.module),
.. folded }
}

View File

@ -293,10 +293,11 @@ type crate_cfg = ~[@meta_item];
type crate = spanned<crate_>;
type crate_ =
{module: _mod,
attrs: ~[attribute],
config: crate_cfg};
struct crate_ {
module: _mod,
attrs: ~[attribute],
config: crate_cfg,
}
type meta_item = spanned<meta_item_>;

View File

@ -165,11 +165,11 @@ fn noop_fold_crate(c: crate_, fld: ast_fold) -> crate_ {
let fold_meta_item = |x| fold_meta_item_(x, fld);
let fold_attribute = |x| fold_attribute_(x, fld);
return {
crate_ {
module: fld.fold_mod(c.module),
attrs: vec::map(c.attrs, |x| fold_attribute(*x)),
config: vec::map(c.config, |x| fold_meta_item(*x))
};
attrs: c.attrs.map(|x| fold_attribute(*x)),
config: c.config.map(|x| fold_meta_item(*x)),
}
}
fn noop_fold_view_item(vi: view_item_, _fld: ast_fold) -> view_item_ {

View File

@ -3855,10 +3855,10 @@ impl Parser {
let crate_attrs = self.parse_inner_attrs_and_next();
let first_item_outer_attrs = crate_attrs.next;
let m = self.parse_mod_items(token::EOF, first_item_outer_attrs);
return @spanned(lo, self.span.lo,
{module: m,
attrs: crate_attrs.inner,
config: self.cfg});
@spanned(lo, self.span.lo,
ast::crate_ { module: m,
attrs: crate_attrs.inner,
config: self.cfg })
}
fn parse_str() -> @~str {