summaryrefslogtreecommitdiff
path: root/src/hir/type.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-05-29 18:11:02 +0800
committerJohn Hodge <tpg@mutabah.net>2016-05-29 18:11:02 +0800
commitf89032cc3bb82ae691cc353ac33345bbf8a8559a (patch)
treea90294c2439029f0575c52d7a9479600fb0e7fc6 /src/hir/type.cpp
parentd97f3089b257754741326bda377103d2c99f263e (diff)
downloadmrust-f89032cc3bb82ae691cc353ac33345bbf8a8559a.tar.gz
HIR - Add binding pointers to TypeRef and Pattern
Diffstat (limited to 'src/hir/type.cpp')
-rw-r--r--src/hir/type.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/hir/type.cpp b/src/hir/type.cpp
index 6863cd12..caf042e0 100644
--- a/src/hir/type.cpp
+++ b/src/hir/type.cpp
@@ -50,7 +50,7 @@ void ::HIR::TypeRef::fmt(::std::ostream& os) const
os << e;
),
(Path,
- os << e;
+ os << e.path;
),
(Generic,
os << e.name << "/*#" << e.binding << "*/";
@@ -106,6 +106,19 @@ void ::HIR::TypeRef::fmt(::std::ostream& os) const
)
)
}
+
+namespace {
+ ::HIR::TypeRef::TypePathBinding clone_binding(const ::HIR::TypeRef::TypePathBinding& x) {
+ TU_MATCH(::HIR::TypeRef::TypePathBinding, (x), (e),
+ (Unbound, return ::HIR::TypeRef::TypePathBinding::make_Unbound({}); ),
+ (Opaque , return ::HIR::TypeRef::TypePathBinding::make_Opaque({}); ),
+ (Struct , return ::HIR::TypeRef::TypePathBinding(e); ),
+ (Enum , return ::HIR::TypeRef::TypePathBinding(e); )
+ )
+ throw "";
+ }
+}
+
::HIR::TypeRef HIR::TypeRef::clone() const
{
TU_MATCH(::HIR::TypeRef::Data, (m_data), (e),
@@ -119,13 +132,22 @@ void ::HIR::TypeRef::fmt(::std::ostream& os) const
return ::HIR::TypeRef( Data::make_Primitive(e) );
),
(Path,
- return ::HIR::TypeRef( Data::make_Path(e.clone()) );
+ return ::HIR::TypeRef( Data::make_Path({
+ e.path.clone(),
+ clone_binding(e.binding)
+ }) );
),
(Generic,
return ::HIR::TypeRef( Data::make_Generic(e) );
),
(TraitObject,
- TODO(Span(), "TypeRef::clone() - this = " << *this);
+ ::std::vector< ::HIR::GenericPath> traits;
+ for(const auto& trait : e.m_traits)
+ traits.push_back( trait.clone() );
+ return ::HIR::TypeRef( Data::make_TraitObject({
+ mv$(traits),
+ e.m_lifetime
+ }) );
),
(Array,
TODO(Span(), "TypeRef::clone() - this = " << *this);