diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-16 10:31:00 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-16 10:31:00 +0800 |
commit | f353d572ea66b9bfcfdc9a4e50548838a9e8c7c3 (patch) | |
tree | 7eb8b34804e85f8e0b2fe3eba9e71da9b141803d /src/resolve/index.cpp | |
parent | c2cec3e30a0f142bc2e44d756463558ab8d2f1e1 (diff) | |
download | mrust-f353d572ea66b9bfcfdc9a4e50548838a9e8c7c3.tar.gz |
Resolve - Handle glob imports from external enums
Diffstat (limited to 'src/resolve/index.cpp')
-rw-r--r-- | src/resolve/index.cpp | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/src/resolve/index.cpp b/src/resolve/index.cpp index 3a309305..421f4ae1 100644 --- a/src/resolve/index.cpp +++ b/src/resolve/index.cpp @@ -436,20 +436,42 @@ void Resolve_Index_Module_Wildcard(AST::Crate& crate, AST::Module& mod, bool han } ), (Enum, - ASSERT_BUG(sp, e.enum_, "Glob import but enum pointer not set - " << i_data.path); - DEBUG("Glob enum " << i_data.path); - unsigned int idx = 0; - for( const auto& ev : e.enum_->variants() ) { - ::AST::Path p = i_data.path + ev.m_name; - p.bind( ::AST::PathBinding::make_EnumVar({e.enum_, idx}) ); - if( ev.m_data.is_Struct() ) { - _add_item_type ( sp, mod, ev.m_name, i.is_pub, mv$(p), false ); + ASSERT_BUG(sp, e.enum_ || e.hir, "Glob import but enum pointer not set - " << i_data.path); + if( e.enum_ ) + { + DEBUG("Glob enum " << i_data.path << " (AST)"); + unsigned int idx = 0; + for( const auto& ev : e.enum_->variants() ) { + ::AST::Path p = i_data.path + ev.m_name; + p.bind( ::AST::PathBinding::make_EnumVar({e.enum_, idx}) ); + if( ev.m_data.is_Struct() ) { + _add_item_type ( sp, mod, ev.m_name, i.is_pub, mv$(p), false ); + } + else { + _add_item_value( sp, mod, ev.m_name, i.is_pub, mv$(p), false ); + } + + idx += 1; } - else { - _add_item_value( sp, mod, ev.m_name, i.is_pub, mv$(p), false ); + } + else + { + DEBUG("Glob enum " << i_data.path << " (HIR)"); + unsigned int idx = 0; + for( const auto& ev : e.hir->m_variants ) + { + ::AST::Path p = i_data.path + ev.first; + p.bind( ::AST::PathBinding::make_EnumVar({nullptr, idx, e.hir}) ); + + if( ev.second.is_Struct() ) { + _add_item_type ( sp, mod, ev.first, i.is_pub, mv$(p), false ); + } + else { + _add_item_value( sp, mod, ev.first, i.is_pub, mv$(p), false ); + } + + idx += 1; } - - idx += 1; } ) ) |