summaryrefslogtreecommitdiff
path: root/src/hir/type.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-06-06 22:27:21 +0800
committerJohn Hodge <tpg@mutabah.net>2016-06-06 22:27:21 +0800
commit15afd5d1dfe97009b856e96f643d8dd898625932 (patch)
tree77e66942461de4e630347e0ee510ba5792f4582b /src/hir/type.cpp
parent7317c0a66cbd76ff2fc061561de4f5867060352c (diff)
downloadmrust-15afd5d1dfe97009b856e96f643d8dd898625932.tar.gz
HIR Typecheck - Expand associated types returned from methods
Diffstat (limited to 'src/hir/type.cpp')
-rw-r--r--src/hir/type.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/hir/type.cpp b/src/hir/type.cpp
index a5f04df5..2d87ffb9 100644
--- a/src/hir/type.cpp
+++ b/src/hir/type.cpp
@@ -184,6 +184,55 @@ bool ::HIR::TypeRef::operator==(const ::HIR::TypeRef& x) const
)
throw "";
}
+void ::HIR::TypeRef::match_generics(const Span& sp, const ::HIR::TypeRef& x, ::std::function<void(unsigned int, const ::HIR::TypeRef&)> callback) const
+{
+ if( m_data.is_Infer() ) {
+ BUG(sp, "");
+ }
+ if( m_data.is_Generic() ) {
+ callback(m_data.as_Generic().binding, x);
+ return ;
+ }
+ if( m_data.tag() != x.m_data.tag() ) {
+ BUG(sp, "");
+ }
+ TU_MATCH(::HIR::TypeRef::Data, (m_data, x.m_data), (te, xe),
+ (Infer, throw "";),
+ (Generic, throw "";),
+ (Primitive,
+ ),
+ (Diverge,
+ ),
+ (Path,
+ TODO(sp, "Path");
+ ),
+ (TraitObject,
+ TODO(sp, "TraitObject");
+ ),
+ (Array,
+ te.inner->match_generics( sp, *xe.inner, callback );
+ ),
+ (Slice,
+ te.inner->match_generics( sp, *xe.inner, callback );
+ ),
+ (Tuple,
+ if( te.size() != xe.size() ) {
+ BUG(sp, "");
+ }
+ for(unsigned int i = 0; i < te.size(); i ++ )
+ te[i].match_generics( sp, xe[i], callback );
+ ),
+ (Pointer,
+ te.inner->match_generics( sp, *xe.inner, callback );
+ ),
+ (Borrow,
+ te.inner->match_generics( sp, *xe.inner, callback );
+ ),
+ (Function,
+ TODO(sp, "Function");
+ )
+ )
+}
namespace {
::HIR::TypeRef::TypePathBinding clone_binding(const ::HIR::TypeRef::TypePathBinding& x) {