From e9df248d564badc19f3c43d0fca9ccd013432bb4 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Fri, 23 Dec 2016 11:33:40 +0000 Subject: [PATCH] decoder_detail: Support const member functions --- src/frontend/decoder/decoder_detail.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/frontend/decoder/decoder_detail.h b/src/frontend/decoder/decoder_detail.h index f1b8cee5..17f0cc07 100644 --- a/src/frontend/decoder/decoder_detail.h +++ b/src/frontend/decoder/decoder_detail.h @@ -121,6 +121,21 @@ private: }; } }; + + template + struct VisitorCaller { + template + static auto Make(std::integer_sequence, + CallRetT (Visitor::* const fn)(Args...) const, + 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](const Visitor& v, opcode_type instruction) { + (void)instruction; + return (v.*fn)(static_cast((instruction & arg_masks[iota]) >> arg_shifts[iota])...); + }; + } + }; #ifdef _MSC_VER #pragma warning(pop) #endif