summaryrefslogtreecommitdiff
path: root/src/hir/type.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/hir/type.cpp')
-rw-r--r--src/hir/type.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/hir/type.cpp b/src/hir/type.cpp
index a4f96fa0..14424dab 100644
--- a/src/hir/type.cpp
+++ b/src/hir/type.cpp
@@ -119,6 +119,12 @@ void ::HIR::TypeRef::fmt(::std::ostream& os) const
for(const auto& t : e.m_arg_types)
os << t << ", ";
os << ") -> " << *e.m_rettype;
+ ),
+ (Closure,
+ os << "closure["<<e.node<<"](";
+ for(const auto& t : e.m_arg_types)
+ os << t << ", ";
+ os << ") -> " << *e.m_rettype;
)
)
}
@@ -237,6 +243,12 @@ bool ::HIR::TypeRef::operator==(const ::HIR::TypeRef& x) const
return false;
}
return te.m_rettype == xe.m_rettype;
+ ),
+ (Closure,
+ if( te.node != xe.node )
+ return false;
+ assert( te.m_rettype == xe.m_rettype );
+ return true;
)
)
throw "";
@@ -329,6 +341,9 @@ void ::HIR::TypeRef::match_generics(const Span& sp, const ::HIR::TypeRef& x_in,
),
(Function,
TODO(sp, "Function");
+ ),
+ (Closure,
+ TODO(sp, "Closure");
)
)
}
@@ -410,6 +425,14 @@ namespace {
for(const auto& a : e.m_arg_types)
ft.m_arg_types.push_back( a.clone() );
return ::HIR::TypeRef(Data::make_Function( mv$(ft) ));
+ ),
+ (Closure,
+ Data::Data_Closure oe;
+ oe.node = e.node;
+ oe.m_rettype = box$( e.m_rettype->clone() );
+ for(const auto& a : e.m_arg_types)
+ oe.m_arg_types.push_back( a.clone() );
+ return ::HIR::TypeRef(Data::make_Closure( mv$(oe) ));
)
)
throw "";
@@ -520,6 +543,9 @@ namespace {
),
(Function,
TODO(sp, "Compare " << *this << " and " << right);
+ ),
+ (Closure,
+ TODO(sp, "Compare " << *this << " and " << right);
)
)
throw "";