summaryrefslogtreecommitdiff
path: root/src/hir
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-11-11 08:53:28 +0800
committerJohn Hodge <tpg@mutabah.net>2016-11-11 08:53:28 +0800
commita64152923668cf111618ea42e369bbb49296ae8c (patch)
treec7ee0090390255773ecc3686782cdec15e878cbd /src/hir
parent17a420e04de4672fbce0989f2715f94da605078c (diff)
downloadmrust-a64152923668cf111618ea42e369bbb49296ae8c.tar.gz
HIR - Tweak ErasedType for implementation
Diffstat (limited to 'src/hir')
-rw-r--r--src/hir/from_ast.cpp2
-rw-r--r--src/hir/item_path.hpp14
-rw-r--r--src/hir/type.cpp4
-rw-r--r--src/hir/type.hpp1
4 files changed, 18 insertions, 3 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp
index 78f6b683..af5e6118 100644
--- a/src/hir/from_ast.cpp
+++ b/src/hir/from_ast.cpp
@@ -749,7 +749,7 @@
}
// Leave `m_origin` until the bind pass
return ::HIR::TypeRef( ::HIR::TypeRef::Data::make_ErasedType(::HIR::TypeRef::Data::Data_ErasedType {
- ::HIR::Path(::HIR::SimplePath()),
+ ::HIR::Path(::HIR::SimplePath()), 0,
mv$(traits),
::HIR::LifetimeRef() // TODO: Lifetime ref
} ) );
diff --git a/src/hir/item_path.hpp b/src/hir/item_path.hpp
index 576c7755..9b579b72 100644
--- a/src/hir/item_path.hpp
+++ b/src/hir/item_path.hpp
@@ -48,6 +48,20 @@ public:
return ::HIR::SimplePath();
}
}
+ ::HIR::Path get_full_path() const {
+ assert(parent);
+ assert(name);
+
+ if( parent->name ) {
+ return get_simple_path();
+ }
+ else if( parent->trait ) {
+ return ::HIR::Path( parent->ty->clone(), ::HIR::GenericPath(parent->trait->clone(), parent->trait_params->clone()), ::std::string(name) );
+ }
+ else {
+ return ::HIR::Path( parent->ty->clone(), ::std::string(name) );
+ }
+ }
const char* get_name() const {
return name ? name : "";
}
diff --git a/src/hir/type.cpp b/src/hir/type.cpp
index e1d701ef..865607bc 100644
--- a/src/hir/type.cpp
+++ b/src/hir/type.cpp
@@ -119,7 +119,7 @@ void ::HIR::TypeRef::fmt(::std::ostream& os) const
}
if( e.m_lifetime.name != "" )
os << "+ '" << e.m_lifetime.name;
- os << "/*" << e.m_origin << "*/";
+ os << "/*" << e.m_origin << "#" << e.m_index << "*/";
),
(Array,
os << "[" << *e.inner << "; ";
@@ -786,7 +786,7 @@ bool ::HIR::TypeRef::match_test_generics(const Span& sp, const ::HIR::TypeRef& x
for(const auto& trait : e.m_traits)
traits.push_back( trait.clone() );
return ::HIR::TypeRef( Data::make_ErasedType({
- e.m_origin.clone(),
+ e.m_origin.clone(), e.m_index,
mv$(traits),
e.m_lifetime
}) );
diff --git a/src/hir/type.hpp b/src/hir/type.hpp
index 60ea04bd..653777db 100644
--- a/src/hir/type.hpp
+++ b/src/hir/type.hpp
@@ -141,6 +141,7 @@ public:
}),
(ErasedType, struct {
::HIR::Path m_origin;
+ unsigned int m_index;
::std::vector< ::HIR::TraitPath> m_traits;
::HIR::LifetimeRef m_lifetime;
}),