diff options
Diffstat (limited to 'highlevelilinstruction.cpp')
| -rw-r--r-- | highlevelilinstruction.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/highlevelilinstruction.cpp b/highlevelilinstruction.cpp index 3c838c1a..3626dd54 100644 --- a/highlevelilinstruction.cpp +++ b/highlevelilinstruction.cpp @@ -3262,3 +3262,55 @@ ExprId HighLevelILFunction::FloatCompareUnordered(size_t size, ExprId a, ExprId { return AddExprWithLocation(HLIL_FCMP_UO, loc, size, a, b); } + + +fmt::format_context::iterator fmt::formatter<HighLevelILInstruction>::format(const HighLevelILInstruction& obj, format_context& ctx) const +{ + if (!obj.function) + return fmt::format_to(ctx.out(), "<uninit>"); + + vector<InstructionTextToken> tokens; + Ref<DisassemblySettings> settings = new DisassemblySettings(); + vector<DisassemblyTextLine> lines = obj.function->GetExprText(obj, settings); + if (!lines.empty()) + { + if (presentation == '?') + { + fmt::format_to(ctx.out(), "{} ", obj.operation); + fmt::format_to(ctx.out(), "@ {:#x} ", obj.address); + if (obj.exprIndex != BN_INVALID_EXPR && (obj.exprIndex & 0xffff000000000000) == 0) + { + fmt::format_to(ctx.out(), "[expr {}] ", obj.exprIndex); + } + if (obj.instructionIndex != BN_INVALID_EXPR && (obj.instructionIndex & 0xffff000000000000) == 0) + { + fmt::format_to(ctx.out(), "[instr {}] ", obj.instructionIndex); + } + Ref<Type> type = obj.GetType(); + if (type) + { + fmt::format_to(ctx.out(), "[type: {}] ", type->GetString()); + } + } + + bool first = true; + for (auto& line: lines) + { + if (!first) + { + fmt::format_to(ctx.out(), " ; "); + } + first = false; + + for (auto& token: line.tokens) + { + fmt::format_to(ctx.out(), "{}", token.text); + } + } + } + else + { + fmt::format_to(ctx.out(), "???"); + } + return ctx.out(); +} |
