From 4af0826c332c52af0796a2fe30074bbd6aba664b Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Mon, 12 Jan 2015 19:30:26 +0800 Subject: Path resolution working in one function (types still to come, need AST rep) --- src/ast/path.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/ast/path.cpp') 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& 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) { -- cgit v1.2.3