diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-27 16:43:54 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-27 16:43:54 +0800 |
commit | 042776beb6c68cd1fe6df75b8d5e5be4d873799f (patch) | |
tree | ae202d841718657541e2c1076f24eb22ece5a9a5 /src | |
parent | c738ac37629e6d4850431cd995739d1b198c97b1 (diff) | |
download | mrust-042776beb6c68cd1fe6df75b8d5e5be4d873799f.tar.gz |
AST - Use cfg when loading crates
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/crate.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp index f71b6f65..571f9214 100644 --- a/src/ast/crate.cpp +++ b/src/ast/crate.cpp @@ -3,20 +3,30 @@ #include "crate.hpp" #include "ast.hpp" #include "../parse/parseerror.hpp" +#include "../expand/cfg.hpp" #include <serialiser_texttree.hpp> namespace { + bool check_item_cfg(const ::AST::MetaItems& attrs) + { + for(const auto& at : attrs.m_items) { + if( at.name() == "cfg" && !check_cfg(attrs.m_span, at) ) { + return false; + } + } + return true; + } void iterate_module(::AST::Module& mod, ::std::function<void(::AST::Module& mod)> fcn) { fcn(mod); for( auto& sm : mod.items() ) { - TU_MATCH_DEF(::AST::Item, (sm.data), (e), - ( ), - (Module, - iterate_module(e, fcn); - ) + TU_IFLET(::AST::Item, sm.data, Module, e, + if( check_item_cfg(sm.data.attrs) ) + { + iterate_module(e, fcn); + } ) } } @@ -38,7 +48,10 @@ void Crate::load_externs() { TU_IFLET(AST::Item, it.data, Crate, c, const auto& name = c.name; - TODO(it.data.span, "Load crate '" << name << "' as '" << it.name << "'"); + if( check_item_cfg(it.data.attrs) ) + { + TODO(it.data.span, "Load crate '" << name << "' as '" << it.name << "'"); + } ) } }; |