From 8f694dbd8ee7b0ea786229642b994a6d00cbe478 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 30 Apr 2016 12:22:55 +0800 Subject: Resolve - Include (stubbed) 'Absolutise' pass --- src/resolve/absolute.cpp | 16 ++++++++++++++++ src/resolve/use.cpp | 27 ++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/resolve/absolute.cpp (limited to 'src/resolve') diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp new file mode 100644 index 00000000..dd0c5f0d --- /dev/null +++ b/src/resolve/absolute.cpp @@ -0,0 +1,16 @@ +/* + * Convert all paths in AST into absolute form (or to the relevant local item) + * + * After complete there should be no: + * - Relative/super/self paths + * - MaybeBind patterns + */ +#include +#include + +void Resolve_Absolutise(AST::Crate& crate) +{ + TODO(Span(), "Run 'absolutise' resolve pass"); +} + + diff --git a/src/resolve/use.cpp b/src/resolve/use.cpp index 5d794b66..9931eefa 100644 --- a/src/resolve/use.cpp +++ b/src/resolve/use.cpp @@ -118,7 +118,6 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path } void visit(AST::ExprNode_Block& node) override { - // TODO: Recurse into module, with a stack of immediate-scope modules for resolution. if( node.m_local_mod ) { Resolve_Use_Mod(this->crate, *node.m_local_mod, node.m_local_mod->path(), this->parent_modules); @@ -131,6 +130,7 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path } } expr_iter(crate, mod); + // TODO: Check that all code blocks are covered by these two for(auto& i : mod.items()) { TU_MATCH_DEF( AST::Item, (i.data), (e), @@ -140,9 +140,34 @@ void Resolve_Use_Mod(const ::AST::Crate& crate, ::AST::Module& mod, ::AST::Path if( e.code().is_valid() ) { e.code().node().visit( expr_iter ); } + ), + (Static, + if( e.value().is_valid() ) { + e.value().node().visit( expr_iter ); + } ) ) } + for(auto& im : mod.impls()) + { + for(auto& i : im.items()) + { + TU_MATCH_DEF( AST::Item, (i.data), (e), + ( + ), + (Function, + if( e.code().is_valid() ) { + e.code().node().visit( expr_iter ); + } + ), + (Static, + if( e.value().is_valid() ) { + e.value().node().visit( expr_iter ); + } + ) + ) + } + } } ::AST::PathBinding Resolve_Use_GetBinding_Mod(const Span& span, const ::AST::Crate& crate, const ::AST::Module& mod, const ::std::string& des_item_name, slice< const ::AST::Module* > parent_modules) -- cgit v1.2.3