summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-10-09 09:15:48 +0800
committerJohn Hodge <tpg@mutabah.net>2016-10-09 09:15:48 +0800
commit5d75ae0b19803ee79d191cd985b5e8896df51ccb (patch)
tree782f3d65fdb21b58ebcf15d95934980c5283eea8
parent42d954bae579c9a72543a5ade61061f1b0cdcd08 (diff)
downloadmrust-5d75ae0b19803ee79d191cd985b5e8896df51ccb.tar.gz
HIR - Save/load macro source crate
-rw-r--r--src/hir/deserialise.cpp3
-rw-r--r--src/hir/from_ast.cpp10
-rw-r--r--src/hir/serialise.cpp1
3 files changed, 9 insertions, 5 deletions
diff --git a/src/hir/deserialise.cpp b/src/hir/deserialise.cpp
index 9fc7d23c..be8cccc9 100644
--- a/src/hir/deserialise.cpp
+++ b/src/hir/deserialise.cpp
@@ -288,6 +288,9 @@ namespace {
::MacroRules rv;
rv.m_exported = true;
rv.m_rules = deserialise_vec_c< ::MacroRulesArm>( [&](){ return deserialise_macrorulesarm(); });
+ rv.m_source_crate = read_string();
+ if(rv.m_source_crate == "")
+ rv.m_source_crate = m_crate_name;
return rv;
}
::MacroPatEnt deserialise_macropatent() {
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp
index 275e5845..c62cc6b9 100644
--- a/src/hir/from_ast.cpp
+++ b/src/hir/from_ast.cpp
@@ -1304,16 +1304,16 @@ public:
auto& macros = rv.m_exported_macros;
// - Extract macros from root module
- for( /*const*/ auto& mac : crate.m_root_module.macros() ) {
- //if( mac.data.export ) {
- macros.insert( ::std::make_pair( mac.name, mv$(mac.data) ) );
- //}
- }
for( auto& mac : crate.m_root_module.macro_imports_res() ) {
//if( mac.data->export ) {
macros.insert( ::std::make_pair( mac.name, MacroRulesPtr(new MacroRules( mv$(*const_cast<MacroRules*>(mac.data)) )) ) );
//}
}
+ for( /*const*/ auto& mac : crate.m_root_module.macros() ) {
+ //if( mac.data.export ) {
+ macros.insert( ::std::make_pair( mac.name, mv$(mac.data) ) );
+ //}
+ }
auto sp = Span();
// - Store the lang item paths so conversion code can use them.
diff --git a/src/hir/serialise.cpp b/src/hir/serialise.cpp
index 7c112b23..238b90d0 100644
--- a/src/hir/serialise.cpp
+++ b/src/hir/serialise.cpp
@@ -407,6 +407,7 @@ namespace {
{
//m_exported: IGNORE, should be set
serialise_vec(mac.m_rules);
+ write_string(mac.m_source_crate);
}
void serialise(const ::MacroPatEnt& pe) {
write_string(pe.name);