diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/path.hpp | 5 | ||||
-rw-r--r-- | src/resolve/absolute.cpp | 68 | ||||
-rw-r--r-- | src/resolve/use.cpp | 2 |
3 files changed, 52 insertions, 23 deletions
diff --git a/src/ast/path.hpp b/src/ast/path.hpp index dbb92cde..818d26eb 100644 --- a/src/ast/path.hpp +++ b/src/ast/path.hpp @@ -16,6 +16,10 @@ class TypeRef; +namespace HIR { +class Module; +} // namespace HIR + namespace AST { class GenericParams; @@ -37,6 +41,7 @@ TAGGED_UNION_EX(PathBinding, (), Unbound, ( }), (Module, struct { const Module* module_; + const ::HIR::Module* hir = nullptr; }), (Enum, struct { const Enum* enum_; diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp index fe0ade1a..3b5a1d2f 100644 --- a/src/resolve/absolute.cpp +++ b/src/resolve/absolute.cpp @@ -903,35 +903,59 @@ void Resolve_Absolute_Path(/*const*/ Context& context, const Span& sp, Context:: // TODO: If this is a primitive name, and the next component isn't found in the located module, force to be the type if( ! p.m_class.is_Local() && coretype_fromstring(e.nodes[0].name()) != CORETYPE_INVAL ) { TU_IFLET( ::AST::PathBinding, p.binding(), Module, pe, + bool found = false; + const auto& name = e.nodes[1].name(); if( !pe.module_ ) { - TODO(sp, "Check " << p << " for an item named " << e.nodes[1].name() << " (ext mod)"); + assert( pe.hir ); + const auto& mod = *pe.hir; + + switch( e.nodes.size() == 2 ? mode : Context::LookupMode::Namespace ) + { + case Context::LookupMode::Namespace: + case Context::LookupMode::Type: + // TODO: Restrict if ::Type + if( mod.m_mod_items.find(name) != mod.m_mod_items.end() ) { + found = true; + } + break; + case Context::LookupMode::Pattern: + TODO(sp, "Check " << p << " for an item named " << name << " (Pattern)"); + case Context::LookupMode::Constant: + case Context::LookupMode::Variable: + if( mod.m_value_items.find(name) != mod.m_value_items.end() ) { + found = true; + } + break; + } } - const auto& mod = *pe.module_; - const auto& name = e.nodes[1].name(); - bool found = false; - switch( e.nodes.size() == 2 ? mode : Context::LookupMode::Namespace ) + else { - case Context::LookupMode::Namespace: - if( mod.m_namespace_items.find(name) != mod.m_namespace_items.end() ) { - found = true; - } - case Context::LookupMode::Type: - if( mod.m_namespace_items.find(name) != mod.m_namespace_items.end() ) { - found = true; - } - break; - case Context::LookupMode::Pattern: - TODO(sp, "Check " << p << " for an item named " << e.nodes[1].name() << " (Pattern"); - case Context::LookupMode::Constant: - case Context::LookupMode::Variable: - if( mod.m_value_items.find(name) != mod.m_value_items.end() ) { - found = true; + const auto& mod = *pe.module_; + switch( e.nodes.size() == 2 ? mode : Context::LookupMode::Namespace ) + { + case Context::LookupMode::Namespace: + if( mod.m_namespace_items.find(name) != mod.m_namespace_items.end() ) { + found = true; + } + case Context::LookupMode::Type: + if( mod.m_namespace_items.find(name) != mod.m_namespace_items.end() ) { + found = true; + } + break; + case Context::LookupMode::Pattern: + TODO(sp, "Check " << p << " for an item named " << name << " (Pattern)"); + case Context::LookupMode::Constant: + case Context::LookupMode::Variable: + if( mod.m_value_items.find(name) != mod.m_value_items.end() ) { + found = true; + } + break; } - break; } if( !found ) { - TODO(sp, "Check " << p << " for an item named " << e.nodes[1].name()); + //TODO(sp, "Switch back to primitive from " << p << " for " << path); + p = ::AST::Path( ::AST::Path::TagLocal(), e.nodes[0].name() ); } ) } diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index 33669f22..57679f8b 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -352,7 +352,7 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path TODO(span, "Recurse to get binding for an import"); ), (Module, - return ::AST::PathBinding::make_Module({nullptr}); + return ::AST::PathBinding::make_Module({nullptr, &e}); ), (TypeAlias, return ::AST::PathBinding::make_TypeAlias({nullptr}); |