summaryrefslogtreecommitdiff
path: root/src/ast/crate.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-10-08 15:29:59 +0800
committerJohn Hodge <tpg@mutabah.net>2016-10-08 15:29:59 +0800
commitb0dff9731a56ca33d0d6326d402af6d4c54963ec (patch)
treec5432b021a7b17452e967c3fd04b73bb55c4940b /src/ast/crate.cpp
parent391d72b800942aeb55ba77952915a81b2731e970 (diff)
downloadmrust-b0dff9731a56ca33d0d6326d402af6d4c54963ec.tar.gz
HIR+AST - Store/Load/Use extern crate list from loaded crates
Diffstat (limited to 'src/ast/crate.cpp')
-rw-r--r--src/ast/crate.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ast/crate.cpp b/src/ast/crate.cpp
index 5f27e02f..c05b2e29 100644
--- a/src/ast/crate.cpp
+++ b/src/ast/crate.cpp
@@ -99,7 +99,17 @@ void Crate::load_extern_crate(Span sp, const ::std::string& name)
if( !::std::ifstream(path).good() ) {
ERROR(sp, E0000, "Unable to locate crate '" << name << "'");
}
- m_extern_crates.insert(::std::make_pair( name, ExternCrate { name, path } ));
+ auto res = m_extern_crates.insert(::std::make_pair( name, ExternCrate { name, path } ));
+ auto crate_ext_list = mv$( res.first->second.m_hir->m_ext_crates );
+
+ // Load referenced crates
+ for( const auto& ext : crate_ext_list )
+ {
+ if( m_extern_crates.count(ext.first) == 0 )
+ {
+ this->load_extern_crate(sp, ext.first);
+ }
+ }
}
ExternCrate::ExternCrate(const ::std::string& name, const ::std::string& path):
@@ -109,8 +119,6 @@ ExternCrate::ExternCrate(const ::std::string& name, const ::std::string& path):
m_hir = HIR_Deserialise(path, name);
m_hir->post_load_update(name);
-
- // TODO: Load referenced crates
}
void ExternCrate::with_all_macros(::std::function<void(const ::std::string& , const MacroRules&)> cb) const