summaryrefslogtreecommitdiff
path: root/src/hir/item_path.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hir/item_path.hpp')
-rw-r--r--src/hir/item_path.hpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/hir/item_path.hpp b/src/hir/item_path.hpp
index 9b579b72..8ed140af 100644
--- a/src/hir/item_path.hpp
+++ b/src/hir/item_path.hpp
@@ -11,13 +11,13 @@ namespace HIR {
class ItemPath
{
+public:
const ItemPath* parent = nullptr;
const ::HIR::TypeRef* ty = nullptr;
const ::HIR::SimplePath* trait = nullptr;
const ::HIR::PathParams* trait_params = nullptr;
const char* name = nullptr;
-public:
ItemPath() {}
ItemPath(const ItemPath& p, const char* n):
parent(&p),
@@ -70,6 +70,24 @@ public:
return ItemPath(*this, name.c_str());
}
+ bool operator==(const ::HIR::SimplePath& sp) const {
+ if( sp.m_crate_name != "" ) return false;
+
+ unsigned int i = sp.m_components.size();
+ const auto* n = this;
+ while( n && i -- )
+ {
+ if( !n->name )
+ return false;
+ if( n->name != sp.m_components[i] )
+ return false;
+ n = n->parent;
+ }
+ if( i > 0 || n->name )
+ return false;
+ return true;
+ }
+
friend ::std::ostream& operator<<(::std::ostream& os, const ItemPath& x) {
if( x.parent ) {
os << *x.parent;