From 7064468986827633023933435608630110377820 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 10 Jun 2024 19:00:58 -0400 Subject: Add fmt formatters for IL instructions --- mediumlevelilinstruction.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'mediumlevelilinstruction.h') diff --git a/mediumlevelilinstruction.h b/mediumlevelilinstruction.h index 861bf395..b9745177 100644 --- a/mediumlevelilinstruction.h +++ b/mediumlevelilinstruction.h @@ -1713,3 +1713,24 @@ namespace BinaryNinja #undef _STD_UNORDERED_MAP #undef _STD_MAP } // namespace BinaryNinjaCore + +#ifdef BINARYNINJACORE_LIBRARY +#define IL_INS_NS BinaryNinjaCore +#else +#define IL_INS_NS BinaryNinja +#endif +template<> struct fmt::formatter +{ + // -> normal, ? -> debug + char presentation = ' '; + format_context::iterator format(const IL_INS_NS::MediumLevelILInstruction& obj, format_context& ctx) const; + constexpr auto parse(format_parse_context& ctx) -> format_parse_context::iterator + { + auto it = ctx.begin(), end = ctx.end(); + if (it != end && *it == '?') + presentation = *it++; + if (it != end && *it != '}') detail::throw_format_error("invalid format"); + return it; + } +}; +#undef IL_INS_NS -- cgit v1.3.1