summaryrefslogtreecommitdiff
path: root/src/ast/path.cpp
diff options
context:
space:
mode:
authorJohn Hodge (sonata) <tpg@mutabah.net>2015-01-12 19:30:26 +0800
committerJohn Hodge (sonata) <tpg@mutabah.net>2015-01-12 19:30:26 +0800
commit4af0826c332c52af0796a2fe30074bbd6aba664b (patch)
treefae67e36abed7361016b3088315e0e917667b212 /src/ast/path.cpp
parent645ecea1a60e913ada6bdc8665d098d4b00a5f01 (diff)
downloadmrust-4af0826c332c52af0796a2fe30074bbd6aba664b.tar.gz
Path resolution working in one function (types still to come, need AST rep)
Diffstat (limited to 'src/ast/path.cpp')
-rw-r--r--src/ast/path.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/ast/path.cpp b/src/ast/path.cpp
index 354da4da..a868be5d 100644
--- a/src/ast/path.cpp
+++ b/src/ast/path.cpp
@@ -142,11 +142,28 @@ void Path::resolve(const Crate& root_crate)
return ;
}
else {
- throw ParseError::Generic("Import of enum, too many extra nodes");
+ throw ParseError::Generic("Binding path to enum, too many extra nodes");
}
}
}
// - Constants / statics
+ {
+ auto& items = mod->statics();
+ auto it = find_named(items, node.name());
+ if( it != items.end() )
+ {
+ DEBUG("Found static/const");
+ if( is_last ) {
+ if( node.args().size() )
+ throw ParseError::Generic("Unexpected generic params on static/const");
+ bind_static(it->data);
+ return ;
+ }
+ else {
+ throw ParseError::Generic("Binding path to static, trailing nodes");
+ }
+ }
+ }
throw ParseError::Generic("Unable to find component '" + node.name() + "'");
}
@@ -198,6 +215,12 @@ void Path::bind_struct(const Struct& ent, const ::std::vector<TypeRef>& args)
{
throw ParseError::Todo("Path::resolve() bind to struct type");
}
+void Path::bind_static(const Static& ent)
+{
+ m_binding_type = STATIC;
+ m_binding.static_ = &ent;
+}
+
Path& Path::operator+=(const Path& other)
{