diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/main_bindings.hpp | 1 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/resolve/absolute.cpp | 16 | ||||
-rw-r--r-- | src/resolve/use.cpp | 27 |
4 files changed, 46 insertions, 2 deletions
diff --git a/src/include/main_bindings.hpp b/src/include/main_bindings.hpp index bd44bae0..8f1c605d 100644 --- a/src/include/main_bindings.hpp +++ b/src/include/main_bindings.hpp @@ -21,6 +21,7 @@ extern void Process_Decorators(AST::Crate& crate); extern void Resolve_Use(::AST::Crate& crate); extern void Resolve_Index(::AST::Crate& crate); +extern void Resolve_Absolutise(::AST::Crate& crate); /// Resolve all in-text paths to absolute variants extern void ResolvePaths(AST::Crate& crate); diff --git a/src/main.cpp b/src/main.cpp index 34da5cb5..07e25f0f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -118,8 +118,10 @@ int main(int argc, char *argv[]) CompilePhaseV("Resolve", [&]() {
Resolve_Use(crate); // - Absolutise and resolve use statements
Resolve_Index(crate); // - Build up a per-module index of avalable names (faster and simpler later resolve)
- //Resolve_Absolutise(crate);
+ Resolve_Absolutise(crate);
//Resolve_UfcsPaths(crate);
+
+ // OLD resolve code, kinda bad
ResolvePaths(crate);
});
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 <ast/crate.hpp> +#include <main_bindings.hpp> + +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) |