summaryrefslogtreecommitdiff
path: root/src/resolve
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-04-30 12:22:55 +0800
committerJohn Hodge <tpg@mutabah.net>2016-04-30 12:22:55 +0800
commit8f694dbd8ee7b0ea786229642b994a6d00cbe478 (patch)
treef5f7cdc4c0e70d6a239316d68ce13403248c04d1 /src/resolve
parentf5c9ee756d97fb8c02fd74faeab7a50907de6690 (diff)
downloadmrust-8f694dbd8ee7b0ea786229642b994a6d00cbe478.tar.gz
Resolve - Include (stubbed) 'Absolutise' pass
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/absolute.cpp16
-rw-r--r--src/resolve/use.cpp27
2 files changed, 42 insertions, 1 deletions
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)