diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-26 15:51:32 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-26 15:51:32 +0800 |
commit | 5878630c75af3c0c0ec1c770e529dfd47d20ee71 (patch) | |
tree | 0a9c3c33d90c1b9bf8a47cae7a51f3f7a3754511 /src | |
parent | a3d39af759612133912748d9cdcfba62bd8f320d (diff) | |
download | mrust-5878630c75af3c0c0ec1c770e529dfd47d20ee71.tar.gz |
Resolve Use - Search wildcard imports of crates
Diffstat (limited to 'src')
-rw-r--r-- | src/resolve/use.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index ad668b40..ceb7d3f5 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -22,6 +22,7 @@ enum class Lookup ::AST::Path Resolve_Use_AbsolutisePath(const ::AST::Path& base_path, ::AST::Path path); void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path path, slice< const ::AST::Module* > parent_modules={}); ::AST::PathBinding Resolve_Use_GetBinding(const Span& span, const ::AST::Crate& crate, const ::AST::Path& path, slice< const ::AST::Module* > parent_modules, Lookup allow=Lookup::Any); +::AST::PathBinding Resolve_Use_GetBinding__ext(const Span& span, const ::AST::Crate& crate, const ::AST::Path& path, const ::HIR::Module& hmodr, unsigned int start, Lookup allow); void Resolve_Use(::AST::Crate& crate) @@ -404,6 +405,14 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path ( BUG(sp2, "Wildcard import expanded to an invalid item class - " << binding->tag_str()); ), + (Crate, + assert(e.crate_); + const ::HIR::Module& hmod = e.crate_->m_hir->m_root_module; + auto rv = Resolve_Use_GetBinding__ext(sp2, crate, AST::Path("", { AST::PathNode(des_item_name,{}) }), hmod, 0, allow); + if( ! rv.is_Unbound() ) { + return mv$(rv); + } + ), (Module, auto allow_inner = (allow == Lookup::Any ? Lookup::AnyOpt : allow); assert(e.module_); @@ -489,9 +498,10 @@ namespace { ERROR(span, E0000, "Unexpected item type in import " << path << " @ " << i << " - " << it->second->ent.tag_str()); ), (Import, + // TODO: Enum imports. hmod = get_hir_mod_by_path(span, crate, e); if( !hmod ) - BUG(span, "Path component " << nodes[i].name() << " pointed to non-module"); + BUG(span, "Path component " << nodes[i].name() << " pointed to non-module (" << path << ")"); ), (Module, hmod = &e; |