summaryrefslogtreecommitdiff
path: root/src/hir/path.hpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-07-17 12:31:08 +0800
committerJohn Hodge <tpg@mutabah.net>2016-07-17 12:31:08 +0800
commit923d403d45dbcfe4d02c0fd2923ef97760ff1659 (patch)
treebbb37fef28a7977d94848afe614e5079beda54f7 /src/hir/path.hpp
parentb9543cd50d06c3478987cf3ab6ea4215fd9124e6 (diff)
downloadmrust-923d403d45dbcfe4d02c0fd2923ef97760ff1659.tar.gz
HIR - Allow sorting of types and paths
Diffstat (limited to 'src/hir/path.hpp')
-rw-r--r--src/hir/path.hpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/hir/path.hpp b/src/hir/path.hpp
index 59b5f111..cace3ff9 100644
--- a/src/hir/path.hpp
+++ b/src/hir/path.hpp
@@ -68,6 +68,12 @@ struct SimplePath
if( m_components < x.m_components ) return true;
return false;
}
+ Ordering ord(const SimplePath& x) const {
+ auto rv = ::ord(m_crate_name, x.m_crate_name);
+ if(rv != OrdEqual) return rv;
+ rv = ::ord(m_components, x.m_components);
+ return rv;
+ }
friend ::std::ostream& operator<<(::std::ostream& os, const SimplePath& x);
};
@@ -84,7 +90,10 @@ struct PathParams
PathParams& operator=(PathParams&&) = default;
bool operator==(const PathParams& x) const;
- //bool operator<(const PathParams& x) const;
+ bool operator<(const PathParams& x) const { return ord(x) == OrdLess; }
+ Ordering ord(const PathParams& x) const {
+ return ::ord(m_types, x.m_types);
+ }
friend ::std::ostream& operator<<(::std::ostream& os, const PathParams& x);
};
@@ -104,7 +113,13 @@ public:
bool operator==(const GenericPath& x) const;
bool operator!=(const GenericPath& x) const { return !(*this == x); }
- //bool operator<(const GenericPath& x) const;
+ bool operator<(const GenericPath& x) const { return ord(x) == OrdLess; }
+
+ Ordering ord(const GenericPath& x) const {
+ auto rv = ::ord(m_path, x.m_path);
+ if(rv != OrdEqual) return rv;
+ return ::ord(m_params, x.m_params);
+ }
friend ::std::ostream& operator<<(::std::ostream& os, const GenericPath& x);
};
@@ -123,6 +138,12 @@ public:
bool operator==(const TraitPath& x) const;
bool operator!=(const TraitPath& x) const { return !(*this == x); }
+ Ordering ord(const TraitPath& x) const {
+ ORD(m_path, x.m_path);
+ ORD(m_hrls, x.m_hrls);
+ return ::ord(m_type_bounds, x.m_type_bounds);
+ }
+
friend ::std::ostream& operator<<(::std::ostream& os, const TraitPath& x);
};