Introduce a config property to the crate AST node

This represents the compilation environment, defined as AST meta_items, Used
for driving conditional compilation and will eventually replace the
environment used by the parser for the current conditional compilation scheme.

Issue #489
This commit is contained in:
Brian Anderson 2011-06-29 18:07:15 -07:00
parent cbcc7bba30
commit d53bfad8e7
3 changed files with 12 additions and 4 deletions

View File

@ -76,11 +76,16 @@ fn def_id_of_def(def d) -> def_id {
fail;
}
// The set of meta_items that define the compilation environment of the crate,
// used to drive conditional compilation
type crate_cfg = vec[@meta_item];
type crate = spanned[crate_];
type crate_ = rec(vec[@crate_directive] directives,
_mod module,
vec[attribute] attrs);
vec[attribute] attrs,
crate_cfg config);
tag crate_directive_ {
cdir_expr(@expr);

View File

@ -131,7 +131,8 @@ fn noop_fold_crate(&crate_ c, ast_fold fld) -> crate_ {
auto fold_attribute = bind fold_attribute_(_,fold_meta_item);
ret rec(directives=map(fld.fold_crate_directive, c.directives),
module=c.module, attrs=map(fold_attribute, c.attrs));
module=c.module, attrs=map(fold_attribute, c.attrs),
config=map(fold_meta_item, c.config));
}
fn noop_fold_crate_directive(&crate_directive_ cd, ast_fold fld)

View File

@ -2318,7 +2318,8 @@ fn parse_crate_from_source_file(&parser p) -> @ast::crate {
let vec[@ast::crate_directive] cdirs = [];
ret @spanned(lo, p.get_lo_pos(), rec(directives=cdirs,
module=m,
attrs=crate_attrs._0));
attrs=crate_attrs._0,
config=[]));
}
fn parse_str(&parser p) -> ast::ident {
@ -2450,7 +2451,8 @@ fn parse_crate_from_crate_file(&parser p) -> @ast::crate {
expect(p, token::EOF);
ret @spanned(lo, hi, rec(directives=cdirs,
module=m,
attrs=crate_attrs));
attrs=crate_attrs,
config=[]));
}
//
// Local Variables: