diff options
author | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-17 14:44:26 +0800 |
---|---|---|
committer | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-17 14:44:26 +0800 |
commit | 0eaa7a5a300de625dfa813f49b04407c9f0a4feb (patch) | |
tree | 96a81ddeca3006469005591e4433ed9a6d0e9737 /src/ast/path.cpp | |
parent | f99a99e79ff7946dcf7a283c87caf8f0a92c2c03 (diff) | |
download | mrust-0eaa7a5a300de625dfa813f49b04407c9f0a4feb.tar.gz |
Trait serialise
Diffstat (limited to 'src/ast/path.cpp')
-rw-r--r-- | src/ast/path.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/ast/path.cpp b/src/ast/path.cpp index 80c9bbdb..56d06eaf 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -102,8 +102,8 @@ void Path::resolve(const Crate& root_crate) if( it != items.end() ) { DEBUG("Type alias <"<<it->data.params()<<"> " << it->data.type()); - if( node.args().size() != it->data.params().size() ) - throw ParseError::Generic("Param count mismatch when referencing type alias"); + //if( node.args().size() != it->data.params().size() ) + // throw ParseError::Generic("Param count mismatch when referencing type alias"); // Make a copy of the path, replace params with it, then replace *this? // - Maybe leave that up to other code? if( is_last ) { @@ -132,6 +132,27 @@ void Path::resolve(const Crate& root_crate) } } } + + // - Traits + { + auto& items = mod->traits(); + auto it = find_named(items, node.name()); + if( it != items.end() ) + { + DEBUG("Found trait"); + if( is_last ) { + m_binding_type = TRAIT; + m_binding.trait = &it->data; + return; + } + else if( is_sec_last ) { + throw ParseError::Todo("Path::resolve() trait method"); + } + else { + throw ParseError::Generic("Import of trait, too many extra nodes"); + } + } + } // - Structs { auto& items = mod->structs(); @@ -272,7 +293,7 @@ Path& Path::operator+=(const Path& other) os << "Path({" << path.m_nodes << "})"; break; case Path::ABSOLUTE: - os << "Path(TagAbsolute, {" << path.m_nodes << "})"; + os << "Path(TagAbsolute, \""<<path.m_crate<<"\", {" << path.m_nodes << "})"; break; case Path::LOCAL: os << "Path(TagLocal, " << path.m_nodes[0].name() << ")"; |