diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-29 15:37:14 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-29 15:37:14 +0800 |
commit | bff6e3261499d58b34ad0d142d8056db90c7d4ac (patch) | |
tree | caf25ae2a5915225575ae5b0ea1c453cd51c9ebe /src/resolve/absolute.cpp | |
parent | 9452342adf82b09fd15775e9d060c208b73aef1c (diff) | |
download | mrust-bff6e3261499d58b34ad0d142d8056db90c7d4ac.tar.gz |
Resolve Absolute - Hack around name resolution quirk
Diffstat (limited to 'src/resolve/absolute.cpp')
-rw-r--r-- | src/resolve/absolute.cpp | 68 |
1 files changed, 46 insertions, 22 deletions
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() ); } ) } |