Skip to content

Commit

Permalink
fix to_hex to work without std::format
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanks12 committed Feb 12, 2024
1 parent c2c02ea commit 3d191f6
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "AvmMini_opcode.hpp"

#include <cstdint>
#include <format>
#include <iomanip>
#include <sstream>

namespace avm_trace {

Expand Down Expand Up @@ -154,7 +155,10 @@ bool Bytecode::has_in_tag(OpCode const op_code)

std::string to_hex(OpCode opcode)
{
return std::format("{:02x}", static_cast<uint8_t>(opcode));
std::ostringstream stream;
// pad with 0s to fill exactly 2 hex characters
stream << std::setfill('0') << std::setw(2) << std::hex << (static_cast<uint8_t>(opcode) & 0xFF);
return stream.str();
}

} // namespace avm_trace

0 comments on commit 3d191f6

Please sign in to comment.