summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-29 13:01:44 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-29 13:01:44 +0800
commitfad3c858ed5a61ab420ba9ba5fc6bdb39b0ce081 (patch)
treeb6502ca17df4f5f98bc53bc66d9c95739b95e158 /src
parent1689ddf48bf7ce56df11c19d73eef84aea918e0d (diff)
downloadmrust-fad3c858ed5a61ab420ba9ba5fc6bdb39b0ce081.tar.gz
macro_rules - Source crate!
Diffstat (limited to 'src')
-rw-r--r--src/ast/crate.cpp9
-rw-r--r--src/macro_rules/eval.cpp3
2 files changed, 10 insertions, 2 deletions
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp
index f1f363d9..3480de28 100644
--- a/src/ast/crate.cpp
+++ b/src/ast/crate.cpp
@@ -6,6 +6,7 @@
#include "../expand/cfg.hpp"
#include <hir/hir.hpp> // HIR::Crate
#include <hir/main_bindings.hpp> // HIR_Deserialise
+#include <macro_rules/macro_rules.hpp> // Used to update the crate name
namespace {
bool check_item_cfg(const ::AST::MetaItems& attrs)
@@ -70,6 +71,14 @@ ExternCrate::ExternCrate(const ::std::string& name, const ::std::string& path)
// 1. Loads referenced crates
// 2. Updates all absolute paths with the crate name
// 3. Updates macros with the crate name
+ for(auto& mac : m_hir->m_exported_macros)
+ {
+ if( mac.second->m_source_crate == "" )
+ {
+ mac.second->m_source_crate = name;
+ }
+ }
+ // 4. Sets binding pointers where required
}
void ExternCrate::with_all_macros(::std::function<void(const ::std::string& , const MacroRules&)> cb) const
diff --git a/src/macro_rules/eval.cpp b/src/macro_rules/eval.cpp
index 3f62b166..8039268c 100644
--- a/src/macro_rules/eval.cpp
+++ b/src/macro_rules/eval.cpp
@@ -426,8 +426,7 @@ bool Macro_HandlePattern(TTStream& lex, const MacroPatEnt& pat, ::std::vector<un
}
//bound_tts.dump();
- DEBUG("TODO: Obtain crate name correctly, using \"\" for now");
- TokenStream* ret_ptr = new MacroExpander(name, rule.m_contents, mv$(bound_tts), "");
+ TokenStream* ret_ptr = new MacroExpander(name, rule.m_contents, mv$(bound_tts), rules.m_source_crate);
// HACK! Disable nested macro expansion
//ret_ptr->parse_state().no_expand_macros = true;