diff options
author | John Hodge <tpg@mutabah.net> | 2015-03-31 14:20:18 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2015-03-31 14:20:18 +0800 |
commit | f725889aedd5b64141e8f8e9924e4e59f716c225 (patch) | |
tree | 7a132887475f67c26478b3c4738e1646652e169e /src/ast/path.cpp | |
parent | f5819ef88927734bcc36769b50d1b69de377b5db (diff) | |
download | mrust-f725889aedd5b64141e8f8e9924e4e59f716c225.tar.gz |
Partial comparisons of types/paths to speed up impl searches
Diffstat (limited to 'src/ast/path.cpp')
-rw-r--r-- | src/ast/path.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/ast/path.cpp b/src/ast/path.cpp index 381685a9..7fa630f9 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -361,6 +361,31 @@ Path& Path::operator+=(const Path& other) return *this; } +int Path::equal_no_generic(const Path& x) const +{ + if( m_class != x.m_class ) + return -1; + if( m_crate != x.m_crate ) + return -1; + + unsigned int i = 0; + for( const auto &e : m_nodes ) + { + if( i >= x.m_nodes.size() ) + return -1; + const auto& xe = x.m_nodes[i]; + if( e.name() != xe.name() ) + return -1; + + if( e.args().size() || xe.args().size() ) + throw CompileError::Todo("Handle Path::equal_no_generic with generic"); + + i ++; + } + + return 0; +} + Ordering Path::ord(const Path& x) const { Ordering rv; |