diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ast/ast.cpp | 1 | ||||
-rw-r--r-- | src/ast/path.cpp | 9 | ||||
-rw-r--r-- | src/ast/path.hpp | 5 | ||||
-rw-r--r-- | src/convert/resolve.cpp | 4 |
4 files changed, 16 insertions, 3 deletions
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 T> typename ::std::vector<Item<T> >::const_iterator find_named(const ::std::vector<Item<T> >& vec, const ::std::string& name)
{
return ::std::find_if(vec.begin(), vec.end(), [&name](const Item<T>& 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<TypeRef>& args) m_binding_type = STRUCT; m_binding.struct_ = &ent; } +void Path::bind_struct_member(const Struct& ent, const ::std::vector<TypeRef>& 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<TypeRef>& args); void bind_enum_var(const Enum& ent, const ::std::string& name, const ::std::vector<TypeRef>& args); void bind_struct(const Struct& ent, const ::std::vector<TypeRef>& args); + void bind_struct_member(const Struct& ent, const ::std::vector<TypeRef>& 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("#"<<i), {} ) );
+ local_path.nodes().push_back( AST::PathNode( FMT("#" << m_res.m_module_stack[i].first), {} ) );
ResolvePaths_HandleModule_Use(m_res.m_crate, local_path, *node.m_inner_mod);
}
@@ -355,7 +355,7 @@ void CPathResolver::handle_path(AST::Path& path, CASTIterator::PathMode mode) {
AST::Path local_path = m_module_path;
for(unsigned int i = 0; i < m_module_stack.size(); i ++)
- local_path.nodes().push_back( AST::PathNode( FMT("#"<<i), {} ) );
+ local_path.nodes().push_back( AST::PathNode( FMT("#" << m_module_stack[i].first), {} ) );
for(unsigned int i = m_module_stack.size(); i--; )
{
|