diff options
| author | Glenn Smith <glenn@vector35.com> | 2024-06-10 19:00:58 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2024-06-10 19:00:58 -0400 |
| commit | 7064468986827633023933435608630110377820 (patch) | |
| tree | 0043113cf273007ba8883807d71d248d7d90b9c1 /highlevelilinstruction.h | |
| parent | 9879389091766176705999562870003860338879 (diff) | |
Add fmt formatters for IL instructions
Diffstat (limited to 'highlevelilinstruction.h')
| -rw-r--r-- | highlevelilinstruction.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/highlevelilinstruction.h b/highlevelilinstruction.h index 0476a182..be6f8b43 100644 --- a/highlevelilinstruction.h +++ b/highlevelilinstruction.h @@ -29,6 +29,7 @@ #include "binaryninjaapi.h" #endif #include "mediumlevelilinstruction.h" +#include <fmt/core.h> #ifdef BINARYNINJACORE_LIBRARY namespace BinaryNinjaCore @@ -1419,3 +1420,24 @@ namespace BinaryNinja #undef _STD_SET #undef _STD_UNORDERED_MAP } // namespace BinaryNinjaCore + +#ifdef BINARYNINJACORE_LIBRARY +#define IL_INS_NS BinaryNinjaCore +#else +#define IL_INS_NS BinaryNinja +#endif +template<> struct fmt::formatter<IL_INS_NS::HighLevelILInstruction> +{ + // <empty> -> normal, ? -> debug + char presentation = ' '; + format_context::iterator format(const IL_INS_NS::HighLevelILInstruction& 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 |
