diff options
author | John Hodge <tpg@mutabah.net> | 2016-03-09 21:10:22 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-03-09 21:10:22 +0800 |
commit | 1e8587f474adb1c37147da8d25c4fb364f8fde1c (patch) | |
tree | b285832417818807f301bd9a33237ed947e3056e /src/expand | |
parent | 224e65cf0e6771cb0895af7fa2b1da162050a06d (diff) | |
download | mrust-1e8587f474adb1c37147da8d25c4fb364f8fde1c.tar.gz |
Expand - Expression macro evaluation
Diffstat (limited to 'src/expand')
-rw-r--r-- | src/expand/mod.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index fe7507fb..d77650d0 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -159,9 +159,12 @@ void Expand_Expr(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> m Span(node.get_pos()), node.m_name, node.m_ident, node.m_tokens ); - // TODO: Reparse as expression / item - // TODO: Then call visit on it again - BUG(node.get_pos(), "TODO: Expand expression macros"); + // Reparse as expression / item + auto newexpr = Parse_Expr0(*ttl); + // Then call visit on it again + this->visit(newexpr); + // And schedule it to replace the previous + replacement = mv$(newexpr); } void visit(::AST::ExprNode_Block& node) override { @@ -355,6 +358,8 @@ void Expand_Mod(bool is_early, ::AST::Crate& crate, LList<const AST::Module*> mo } void Expand(::AST::Crate& crate) { + auto modstack = LList<const ::AST::Module*>(nullptr, &crate.m_root_module); + // 1. Crate attributes for( auto& a : crate.m_attrs.m_items ) { @@ -376,8 +381,8 @@ void Expand(::AST::Crate& crate) } // 3. Module tree - Expand_Mod(true , crate, LList<const ::AST::Module*>(nullptr, &crate.m_root_module), ::AST::Path(), crate.m_root_module); - Expand_Mod(false, crate, LList<const ::AST::Module*>(nullptr, &crate.m_root_module), ::AST::Path(), crate.m_root_module); + Expand_Mod(true , crate, modstack, ::AST::Path(), crate.m_root_module); + Expand_Mod(false, crate, modstack, ::AST::Path(), crate.m_root_module); // Post-process #if 0 |