From ebe84a819577aaf0d06171a33e343e04b1d4717e Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 24 Feb 2019 16:12:56 +0800 Subject: Typecheck Expr - Refactor of ivar possibilities to simplify logic --- src/common.hpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/common.hpp') diff --git a/src/common.hpp b/src/common.hpp index f46f93fd..7521b2de 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -243,6 +243,11 @@ inline Join join(const char *sep, const ::std::vector v) { namespace std { +template +inline auto operator<<(::std::ostream& os, const T& v) -> decltype(v.fmt(os)) { + return v.fmt(os); +} + template inline ::std::ostream& operator<<(::std::ostream& os, const ::std::vector& v) { if( v.size() > 0 ) -- cgit v1.2.3 From 85743c7319a9a9b7b44761b77af04957d637bad9 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 22 Mar 2019 08:07:32 +0800 Subject: Common - Add another `ord` overload, fix breakage from that --- src/common.hpp | 4 ++++ src/mir/from_hir_match.cpp | 2 +- src/mir/mir.cpp | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/common.hpp') diff --git a/src/common.hpp b/src/common.hpp index 7521b2de..4cea1633 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -105,6 +105,10 @@ static inline Ordering ord(signed char l, signed char r) { return (l == r ? OrdEqual : (l > r ? OrdGreater : OrdLess)); } +static inline Ordering ord(int l, int r) +{ + return (l == r ? OrdEqual : (l > r ? OrdGreater : OrdLess)); +} static inline Ordering ord(short l, short r) { return (l == r ? OrdEqual : (l > r ? OrdGreater : OrdLess)); diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp index 853e646f..32c97682 100644 --- a/src/mir/from_hir_match.cpp +++ b/src/mir/from_hir_match.cpp @@ -1489,7 +1489,7 @@ namespace { Ordering ord_rule_compatible(const PatternRule& a, const PatternRule& b) { if(a.tag() != b.tag()) - return ::ord( (unsigned)a.tag(), b.tag() ); + return ::ord( (unsigned)a.tag(), (unsigned)b.tag() ); TU_MATCHA( (a, b), (ae, be), (Any, diff --git a/src/mir/mir.cpp b/src/mir/mir.cpp index 840db1ac..ee6c1a6c 100644 --- a/src/mir/mir.cpp +++ b/src/mir/mir.cpp @@ -55,7 +55,7 @@ namespace MIR { ::Ordering Constant::ord(const Constant& b) const { if( this->tag() != b.tag() ) - return ::ord( static_cast(this->tag()), b.tag() ); + return ::ord( static_cast(this->tag()), static_cast(b.tag()) ); TU_MATCHA( (*this,b), (ae,be), (Int, if( ae.v != be.v ) -- cgit v1.2.3 From 4ffc42457c1265dfa6ee3bb2418f16ed4fd57fef Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 20 Jul 2019 14:33:01 +0800 Subject: HIR Typecheck - Move NullOnDrop to a common location --- src/common.hpp | 12 ++++++++++++ src/hir_typeck/static.hpp | 11 ----------- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src/common.hpp') diff --git a/src/common.hpp b/src/common.hpp index 4cea1633..0363c334 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -412,5 +412,17 @@ RunIterable runs(const ::std::vector& x) { return RunIterable(x); } +template +class NullOnDrop { + T*& ptr; +public: + NullOnDrop(T*& ptr): + ptr(ptr) + {} + ~NullOnDrop() { + ptr = nullptr; + } +}; + #endif diff --git a/src/hir_typeck/static.hpp b/src/hir_typeck/static.hpp index 0d9449b1..652bad50 100644 --- a/src/hir_typeck/static.hpp +++ b/src/hir_typeck/static.hpp @@ -84,17 +84,6 @@ public: /// \brief State manipulation /// \{ - template - class NullOnDrop { - T*& ptr; - public: - NullOnDrop(T*& ptr): - ptr(ptr) - {} - ~NullOnDrop() { - ptr = nullptr; - } - }; NullOnDrop set_impl_generics(const ::HIR::GenericParams& gps) { set_impl_generics_raw(gps); return NullOnDrop(m_impl_generics); -- cgit v1.2.3