From b1bad4b5cc65ce0109471d1d4a214163c867efca Mon Sep 17 00:00:00 2001 From: MerryMage Date: Fri, 23 Dec 2016 11:10:02 +0000 Subject: [PATCH] decoder_detail: static_assert member function is from visitor class Improves readability of compiler errors. --- src/frontend/decoder/decoder_detail.h | 4 +++- src/frontend/decoder/matcher.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/frontend/decoder/decoder_detail.h b/src/frontend/decoder/decoder_detail.h index fafe8db9..f1b8cee5 100644 --- a/src/frontend/decoder/decoder_detail.h +++ b/src/frontend/decoder/decoder_detail.h @@ -26,7 +26,8 @@ namespace detail { template struct detail { private: - using opcode_type = typename MatcherT::opcode_type; + using opcode_type = typename MatcherT::opcode_type; + using visitor_type = typename MatcherT::visitor_type; static constexpr size_t opcode_bitsize = Common::BitSize(); @@ -113,6 +114,7 @@ private: CallRetT (Visitor::* const fn)(Args...), const std::array arg_masks, const std::array arg_shifts) { + static_assert(std::is_same::value, "Member function is not from Matcher's Visitor"); return [fn, arg_masks, arg_shifts](Visitor& v, opcode_type instruction) { (void)instruction; return (v.*fn)(static_cast((instruction & arg_masks[iota]) >> arg_shifts[iota])...); diff --git a/src/frontend/decoder/matcher.h b/src/frontend/decoder/matcher.h index bf92bea0..f58825f4 100644 --- a/src/frontend/decoder/matcher.h +++ b/src/frontend/decoder/matcher.h @@ -27,6 +27,7 @@ template class Matcher { public: using opcode_type = OpcodeType; + using visitor_type = Visitor; using handler_return_type = typename Visitor::instruction_return_type; using handler_function = std::function;