diff options
author | John Hodge <tpg@mutabah.net> | 2016-04-30 12:22:55 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-04-30 12:22:55 +0800 |
commit | 8f694dbd8ee7b0ea786229642b994a6d00cbe478 (patch) | |
tree | f5f7cdc4c0e70d6a239316d68ce13403248c04d1 | |
parent | f5c9ee756d97fb8c02fd74faeab7a50907de6690 (diff) | |
download | mrust-8f694dbd8ee7b0ea786229642b994a6d00cbe478.tar.gz |
Resolve - Include (stubbed) 'Absolutise' pass
-rw-r--r-- | Makefile | 2 | ||||
-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 |
5 files changed, 47 insertions, 3 deletions
@@ -34,7 +34,7 @@ OBJ += expand/format_args.o OBJ += expand/concat.o expand/stringify.o expand/file_line.o OBJ += expand/derive.o expand/lang_item.o OBJ += expand/std_prelude.o -OBJ += resolve/use.o resolve/index.o +OBJ += resolve/use.o resolve/index.o resolve/absolute.o OBJ += hir/from_ast.o OBJ += dump_as_rust.o OBJ += convert/ast_iterate.o 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) |