diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-09 10:47:09 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-09 10:47:09 +0800 |
commit | 0241926381c1f069f1b1cfd8e46288e86c49f125 (patch) | |
tree | d7dbd895b823bdc14b9fd4234c67aeb5a93c9832 /src/expand/macro_rules.cpp | |
parent | 967ccfbfd50e0ce0aec985bcb394e34787450f75 (diff) | |
download | mrust-0241926381c1f069f1b1cfd8e46288e86c49f125.tar.gz |
macro_rules - #[macro_export] handling, plan for #[macro_reexport]
Diffstat (limited to 'src/expand/macro_rules.cpp')
-rw-r--r-- | src/expand/macro_rules.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/expand/macro_rules.cpp b/src/expand/macro_rules.cpp index c1d00c70..99e7680b 100644 --- a/src/expand/macro_rules.cpp +++ b/src/expand/macro_rules.cpp @@ -109,8 +109,12 @@ class CMacroExportHandler: if( mac.name() != "macro_rules" ) { ERROR(sp, E0000, "#[macro_export] is only valid on macro_rules!"); } + const auto& name = mac.input_ident(); - //TODO(sp, "macro_export on Item MacroInv"); + // Tag the macro in the module for crate export + auto it = ::std::find_if( mod.macros().begin(), mod.macros().end(), [&](const auto& x){ return x.name == name; } ); + ASSERT_BUG(sp, it != mod.macros().end(), "Macro '" << name << "' not defined in this module"); + it->data->m_exported = true; } else { ERROR(sp, E0000, "Use of #[macro_export] on non-macro - " << i.tag_str()); @@ -125,6 +129,8 @@ class CMacroReexportHandler: void handle(const Span& sp, const AST::MetaItem& mi, ::AST::Crate& crate, const AST::Path& path, AST::Module& mod, AST::Item& i) const override { if( i.is_Crate() ) { + // TODO: Need to look up this crate in the crate list, then import all of the macros listed with the "export" flag set + // - For now, all externally loaded macros are exported (weakly) so things work... } else { ERROR(sp, E0000, "Use of #[macro_reexport] on non-crate - " << i.tag_str()); |