diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/expand/mod.cpp | 2 | ||||
-rw-r--r-- | src/resolve/index.cpp | 43 |
2 files changed, 42 insertions, 3 deletions
diff --git a/src/expand/mod.cpp b/src/expand/mod.cpp index 2fc7b18a..097ab77f 100644 --- a/src/expand/mod.cpp +++ b/src/expand/mod.cpp @@ -883,7 +883,7 @@ void Expand(::AST::Crate& crate) break; case ::AST::Crate::LOAD_CORE: if( crate.m_prelude_path == AST::Path() ) - crate.m_prelude_path = AST::Path("core", {AST::PathNode("prelude")}); + crate.m_prelude_path = AST::Path("core", {AST::PathNode("prelude"), AST::PathNode("v1")}); crate.load_extern_crate("core"); crate.m_extern_crates.at("core").with_all_macros([&](const auto& name, const auto& mac) { crate.m_root_module.add_macro_import( name, mac ); diff --git a/src/resolve/index.cpp b/src/resolve/index.cpp index 2890f247..aa4fa750 100644 --- a/src/resolve/index.cpp +++ b/src/resolve/index.cpp @@ -234,7 +234,43 @@ void Resolve_Index_Module_Wildcard(AST::Module& mod, bool handle_pub) if( !e.module_ ) { ASSERT_BUG(sp, e.hir, "Glob import but module pointer not set - " << i.data.path); - TODO(sp, "Glob import from HIR module - " << i.data.path); + const auto& hmod = *e.hir; + struct H { + static AST::Path hir_to_ast(const HIR::SimplePath& p) { + //assert( p.m_crate_name != "" ); + AST::Path rv( p.m_crate_name, {} ); + rv.nodes().reserve( p.m_components.size() ); + for(const auto& n : p.m_components) + rv.nodes().push_back( AST::PathNode(n) ); + return rv; + } + }; + for(const auto& it : hmod.m_mod_items) { + const auto& ve = *it.second; + if( ve.is_public ) { + AST::Path p; + if( ve.ent.is_Import() ) { + p = H::hir_to_ast( ve.ent.as_Import() ); + } + else { + p = i.data.path + it.first; + } + _add_item_type( sp, mod, it.first, i.is_pub, mv$(p), false ); + } + } + for(const auto& it : hmod.m_value_items) { + const auto& ve = *it.second; + if( ve.is_public ) { + AST::Path p; + if( ve.ent.is_Import() ) { + p = H::hir_to_ast( ve.ent.as_Import() ); + } + else { + p = i.data.path + it.first; + } + _add_item_value( sp, mod, it.first, i.is_pub, mv$(p), false ); + } + } } else { @@ -305,7 +341,10 @@ void Resolve_Index_Module_Wildcard(AST::Module& mod, bool handle_pub) void Resolve_Index_Module_Normalise_Path(const ::AST::Crate& crate, const Span& sp, ::AST::Path& path) { const auto& info = path.m_class.as_Absolute(); - if( info.crate != "" ) TODO(sp, "Resolve_Index_Module_Normalise_Path - Crates"); + if( info.crate != "" ) + { + TODO(sp, "Resolve_Index_Module_Normalise_Path - Paths referring to extern crates - " << path); + } const ::AST::Module* mod = &crate.m_root_module; for( unsigned int i = 0; i < info.nodes.size() - 1; i ++ ) |