From d004d8293e289942a99a2137ce0a0455cf078b0d Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 22 Mar 2015 18:57:47 +0800 Subject: Wildcard lookups in convert resolve, use processing of anon modules --- src/convert/resolve.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/convert/resolve.cpp') diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp index f28e9d45..9439297f 100644 --- a/src/convert/resolve.cpp +++ b/src/convert/resolve.cpp @@ -69,6 +69,7 @@ public: // Path resolution checking void ResolvePaths(AST::Crate& crate); +void ResolvePaths_HandleModule_Use(const AST::Crate& crate, const AST::Path& modpath, AST::Module& mod); class CResolvePaths_NodeVisitor: public AST::NodeVisitorDef @@ -100,13 +101,22 @@ public: void visit(AST::ExprNode_Block& node) { // If there's an inner module on this node - if( node.m_inner_mod.get() ) { + if( node.m_inner_mod.get() ) + { + // Add a reference to it to the parent node (add_anon_module will do dedup) AST::Module& parent_mod = *( (m_res.m_module_stack.size() > 0) ? m_res.m_module_stack.back().second : m_res.m_module ); auto idx = parent_mod.add_anon_module( node.m_inner_mod.get() ); - // Increment the module path to include it? (No - Instead handle that when tracing the stack) + // And add to the list of modules to use in lookup m_res.m_module_stack.push_back( ::std::make_pair(idx, node.m_inner_mod.get()) ); + + // Do use resolution on this module, then do + AST::Path local_path = m_res.m_module_path; + for(unsigned int i = 0; i < m_res.m_module_stack.size(); i ++) + local_path.nodes().push_back( AST::PathNode( FMT("#"<