summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/expand/mod.cpp5
-rw-r--r--src/parse/expr.cpp10
2 files changed, 14 insertions, 1 deletions
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp
index e2164a06..788b2109 100644
--- a/src/expand/mod.cpp
+++ b/src/expand/mod.cpp
@@ -690,11 +690,13 @@ struct CExpandExpr:
void Expand_Expr(::AST::Crate& crate, LList<const AST::Module*> modstack, ::std::unique_ptr<AST::ExprNode>& node)
{
+ TRACE_FUNCTION_F("unique_ptr");
auto visitor = CExpandExpr(crate, modstack);
visitor.visit(node);
}
void Expand_Expr(::AST::Crate& crate, LList<const AST::Module*> modstack, ::std::shared_ptr<AST::ExprNode>& node)
{
+ TRACE_FUNCTION_F("shared_ptr");
auto visitor = CExpandExpr(crate, modstack);
node->visit(visitor);
if( visitor.replacement ) {
@@ -703,6 +705,7 @@ void Expand_Expr(::AST::Crate& crate, LList<const AST::Module*> modstack, ::std:
}
void Expand_Expr(::AST::Crate& crate, LList<const AST::Module*> modstack, AST::Expr& node)
{
+ TRACE_FUNCTION_F("AST::Expr");
auto visitor = CExpandExpr(crate, modstack);
node.visit_nodes(visitor);
if( visitor.replacement ) {
@@ -829,7 +832,7 @@ void Expand_Mod(::AST::Crate& crate, LList<const AST::Module*> modstack, ::AST::
{
auto& i = mod.items()[idx];
- DEBUG("- " << i.name << " (" << ::AST::Item::tag_to_str(i.data.tag()) << ") :: " << i.data.attrs);
+ DEBUG("- " << modpath << "::" << i.name << " (" << ::AST::Item::tag_to_str(i.data.tag()) << ") :: " << i.data.attrs);
::AST::Path path = modpath + i.name;
auto attrs = mv$(i.data.attrs);
diff --git a/src/parse/expr.cpp b/src/parse/expr.cpp
index 15a3e179..93adc3d4 100644
--- a/src/parse/expr.cpp
+++ b/src/parse/expr.cpp
@@ -119,6 +119,16 @@ ExprNodeP Parse_ExprBlockLine_WithItems(TokenStream& lex, ::std::shared_ptr<AST:
Parse_Mod_Item(lex, *local_mod, mv$(item_attrs));
return ExprNodeP();
}
+
+ if( tok.type() == TOK_MACRO && tok.str() == "macro_rules" )
+ {
+ // Special case - create a local module if macro_rules! is seen
+ // - Allows correct scoping of defined macros
+ if( !local_mod ) {
+ local_mod = lex.parse_state().get_current_mod().add_anon();
+ }
+ }
+
switch(tok.type())
{
// Items: