diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-08-24 16:50:04 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-08-24 16:50:04 +0800 |
commit | 47b61b93c2ac841fe44d6cc8ca8fd91bd00b0e10 (patch) | |
tree | 050cfe1f1e05efa9d0555a3d0b391c27b5f73086 /src/hir/from_ast.cpp | |
parent | e8526a24a7a05b113584ad12ac6ad35865dc9aef (diff) | |
download | mrust-47b61b93c2ac841fe44d6cc8ca8fd91bd00b0e10.tar.gz |
HIR/Expand - Hack in proc_macro re-exports (this needs to be cleaner)
Diffstat (limited to 'src/hir/from_ast.cpp')
-rw-r--r-- | src/hir/from_ast.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index dde40e03..e271a809 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -1395,6 +1395,9 @@ void _add_mod_ns_item(::HIR::Module& mod, RcString name, ::HIR::Publicity is_pub void _add_mod_val_item(::HIR::Module& mod, RcString name, ::HIR::Publicity is_pub, ::HIR::ValueItem ti) { mod.m_value_items.insert( ::std::make_pair( mv$(name), ::make_unique_ptr(::HIR::VisEnt< ::HIR::ValueItem> { is_pub, mv$(ti) }) ) ); } +void _add_mod_mac_item(::HIR::Module& mod, RcString name, ::HIR::Publicity is_pub, ::HIR::MacroItem ti) { + mod.m_macro_items.insert( ::std::make_pair( mv$(name), ::make_unique_ptr(::HIR::VisEnt< ::HIR::MacroItem> { is_pub, mv$(ti) }) ) ); +} ::HIR::Module LowerHIR_Module(const ::AST::Module& ast_mod, ::HIR::ItemPath path, ::std::vector< ::HIR::SimplePath> traits) { @@ -1590,6 +1593,16 @@ void _add_mod_val_item(::HIR::Module& mod, RcString name, ::HIR::Publicity is_pu } } + for( const auto& ie : ast_mod.m_macro_imports ) + { + //const auto& sp = mod_span; + if( ie.is_pub ) + { + auto mi = ::HIR::MacroItem::make_Import({ ::HIR::SimplePath(ie.path.front(), ::std::vector<RcString>(ie.path.begin()+1, ie.path.end())) }); + _add_mod_mac_item( mod, ie.name, get_pub(true), mv$(mi) ); + } + } + return mod; } @@ -1881,6 +1894,12 @@ public: { if( mac.is_pub ) { + if( !mac.macro_ptr ) { + // Add to the re-export list + auto path = ::HIR::SimplePath(mac.path.front(), ::std::vector<RcString>(mac.path.begin()+1, mac.path.end()));; + rv.m_proc_macro_reexports.insert( ::std::make_pair( mac.name, ::HIR::Crate::MacroImport { path } )); + continue ; + } // TODO: Why does this to such a move? auto v = ::std::make_pair( mac.name, MacroRulesPtr(new MacroRules( mv$(*const_cast<MacroRules*>(mac.macro_ptr)) )) ); |