From 5db811ee419fd4288d043b2d4148f17424e15302 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 24 Mar 2015 20:22:16 +0800 Subject: Slow bugfixes --- src/ast/ast.cpp | 1 + src/ast/path.cpp | 9 ++++++++- src/ast/path.hpp | 5 +++++ src/convert/resolve.cpp | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index b2575317..7d0637ac 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -495,6 +495,7 @@ template typename ::std::vector >::const_iterator find_named(const ::std::vector >& vec, const ::std::string& name) { return ::std::find_if(vec.begin(), vec.end(), [&name](const Item& x) { + DEBUG("find_named - x.name = " << x.name); return x.name == name; }); } diff --git a/src/ast/path.cpp b/src/ast/path.cpp index 6109fa94..1e2760ef 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -202,7 +202,8 @@ void Path::resolve(const Crate& root_crate) goto ret; } else if( is_sec_last ) { - throw ParseError::Todo("Path::resolve() struct method"); + bind_struct_member(str, node.args(), m_nodes[i+1]); + goto ret; } else { throw ParseError::Generic("Import of struct, too many extra nodes"); @@ -333,6 +334,12 @@ void Path::bind_struct(const Struct& ent, const ::std::vector& args) m_binding_type = STRUCT; m_binding.struct_ = &ent; } +void Path::bind_struct_member(const Struct& ent, const ::std::vector& args, const PathNode& member_node) +{ + DEBUG("Binding to struct item. This needs to be deferred"); + m_binding_type = STRUCT_METHOD; + m_binding.struct_ = &ent; +} void Path::bind_static(const Static& ent) { m_binding_type = STATIC; diff --git a/src/ast/path.hpp b/src/ast/path.hpp index fdf788a5..c2b345df 100644 --- a/src/ast/path.hpp +++ b/src/ast/path.hpp @@ -100,6 +100,10 @@ private: const Module* module_; const Enum* enum_; const Struct* struct_; + struct { + const Struct* struct_; + unsigned int idx; + } structitem; const Trait* trait_; const Static* static_; const Function* func_; @@ -226,6 +230,7 @@ private: void bind_enum(const Enum& ent, const ::std::vector& args); void bind_enum_var(const Enum& ent, const ::std::string& name, const ::std::vector& args); void bind_struct(const Struct& ent, const ::std::vector& args); + void bind_struct_member(const Struct& ent, const ::std::vector& args, const PathNode& member_node); void bind_static(const Static& ent); }; diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp index 58c15468..3a1f0fb7 100644 --- a/src/convert/resolve.cpp +++ b/src/convert/resolve.cpp @@ -118,7 +118,7 @@ public: // Do use resolution on this module, then do AST::Path local_path = m_res.m_module_path; for(unsigned int i = 0; i < m_res.m_module_stack.size(); i ++) - local_path.nodes().push_back( AST::PathNode( FMT("#"<