diff options
| author | Brian Anderson <banderson@mozilla.com> | 2011-06-29 18:07:15 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2011-06-30 10:06:25 -0700 |
| commit | d53bfad8e7b6f199436d8838f75eb90713dffd1d (patch) | |
| tree | e936fa2124063a59ef69002c49f84b96ebb99c92 /src/comp | |
| parent | cbcc7bba30920489d4c772f174bfb9715842f163 (diff) | |
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
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/front/ast.rs | 7 | ||||
| -rw-r--r-- | src/comp/front/fold.rs | 3 | ||||
| -rw-r--r-- | src/comp/front/parser.rs | 6 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 1f4981c809a..c120535d1d0 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -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); diff --git a/src/comp/front/fold.rs b/src/comp/front/fold.rs index 5a878179399..ec3a626a01e 100644 --- a/src/comp/front/fold.rs +++ b/src/comp/front/fold.rs @@ -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) diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 5c50a55e8e3..a383e79619a 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -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: |
