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/types.cpp | |
parent | f5819ef88927734bcc36769b50d1b69de377b5db (diff) | |
download | mrust-f725889aedd5b64141e8f8e9924e4e59f716c225.tar.gz |
Partial comparisons of types/paths to speed up impl searches
Diffstat (limited to 'src/types.cpp')
-rw-r--r-- | src/types.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/types.cpp b/src/types.cpp index a5b6d6ee..c8af093c 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -315,6 +315,28 @@ bool TypeRef::is_concrete() const throw ::std::runtime_error( FMT("BUGCHECK - Invalid type class on " << *this) ); } +int TypeRef::equal_no_generic(const TypeRef& x) const +{ + if( m_class != x.m_class ) return -1; + switch(m_class) + { + case TypeRef::NONE: + case TypeRef::UNIT: + return 0; + case TypeRef::ANY: + throw CompileError::Todo("TypeRef::equal_no_generic - ANY"); + case TypeRef::PRIMITIVE: + if( m_core_type != x.m_core_type ) return -1; + return 0; + case TypeRef::FUNCTION: + if( m_path[0].name() != x.m_path[0].name() ) return -1; + throw CompileError::Todo("TypeRef::equal_no_generic - FUNCTION"); + case TypeRef::PATH: + return m_path.equal_no_generic( x.m_path ); + default: + throw CompileError::Todo("TypeRef::equal_no_generic"); + } +} Ordering TypeRef::ord(const TypeRef& x) const { Ordering rv; @@ -336,7 +358,7 @@ Ordering TypeRef::ord(const TypeRef& x) const case TypeRef::FUNCTION: rv = ::ord(m_path[0].name(),x.m_path[0].name()); if(rv != OrdEqual) return rv; - return OrdEqual; + return ::ord(m_inner_types, x.m_inner_types); case TypeRef::TUPLE: return ::ord(m_inner_types, x.m_inner_types); //return m_inner_types == x.m_inner_types; |