Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(avm-circuit): tests use OpCode enum's instead of hardcoded values #4554

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "AvmMini_opcode.hpp"

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

namespace avm_trace {

Expand Down Expand Up @@ -150,4 +153,12 @@ bool Bytecode::has_in_tag(OpCode const op_code)
}
}

std::string to_hex(OpCode 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <cstddef>
#include <cstdint>
#include <string>
#include <unordered_map>

namespace avm_trace {
Expand Down Expand Up @@ -102,4 +103,6 @@ class Bytecode {
static const std::unordered_map<OpCode, size_t> OPERANDS_NUM;
};

std::string to_hex(OpCode opcode);

} // namespace avm_trace
Loading
Loading