diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-01 13:32:15 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-01 13:32:15 +0800 |
commit | 86eb098313fbc292d411a39d1d3db04b0e58cc83 (patch) | |
tree | 14d03941f4b18f1c17b06e4a6ae69d9513da72d5 /src/hir/hir.cpp | |
parent | 8c8550756e4c1bcfef5195fce182f274a76e1e13 (diff) | |
download | mrust-86eb098313fbc292d411a39d1d3db04b0e58cc83.tar.gz |
HIR - Support looking up items using ext crate paths
Diffstat (limited to 'src/hir/hir.cpp')
-rw-r--r-- | src/hir/hir.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/hir/hir.cpp b/src/hir/hir.cpp index ea575d6f..d0a825f8 100644 --- a/src/hir/hir.cpp +++ b/src/hir/hir.cpp @@ -378,10 +378,15 @@ const ::HIR::TypeItem& ::HIR::Crate::get_typeitem_by_path(const Span& sp, const if( path.m_components.size() == 0) { BUG(sp, "get_typeitem_by_path received invalid path"); } - if( path.m_crate_name != "" ) - TODO(sp, "::HIR::Crate::get_typeitem_by_path in extern crate"); - const ::HIR::Module* mod = &this->m_root_module; + const ::HIR::Module* mod; + if( path.m_crate_name != "" ) { + ASSERT_BUG(sp, m_ext_crates.count(path.m_crate_name) > 0, "Crate '" << path.m_crate_name << "' not loaded"); + mod = &m_ext_crates.at(path.m_crate_name)->m_root_module; + } + else { + mod = &this->m_root_module; + } for( unsigned int i = 0; i < path.m_components.size() - 1; i ++ ) { const auto& pc = path.m_components[i]; @@ -450,10 +455,14 @@ const ::HIR::ValueItem& ::HIR::Crate::get_valitem_by_path(const Span& sp, const if( path.m_components.size() == 0) { BUG(sp, "get_valitem_by_path received invalid path"); } - if( path.m_crate_name != "" ) - TODO(sp, "::HIR::Crate::get_valitem_by_path in extern crate"); - - const ::HIR::Module* mod = &this->m_root_module; + const ::HIR::Module* mod; + if( path.m_crate_name != "" ) { + ASSERT_BUG(sp, m_ext_crates.count(path.m_crate_name) > 0, "Crate '" << path.m_crate_name << "' not loaded"); + mod = &m_ext_crates.at(path.m_crate_name)->m_root_module; + } + else { + mod = &this->m_root_module; + } for( unsigned int i = 0; i < path.m_components.size() - 1; i ++ ) { const auto& pc = path.m_components[i]; |