diff options
Diffstat (limited to 'src/opcode.h')
-rw-r--r-- | src/opcode.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/opcode.h b/src/opcode.h index 2a4d7d74..bdf1b589 100644 --- a/src/opcode.h +++ b/src/opcode.h @@ -17,8 +17,11 @@ #ifndef WABT_OPCODE_H_ #define WABT_OPCODE_H_ +#include <vector> + #include "src/common.h" #include "src/opcode-code-table.h" +#include "src/leb128.h" namespace wabt { @@ -54,7 +57,7 @@ struct Opcode { bool HasPrefix() const { return GetInfo().prefix != 0; } uint8_t GetPrefix() const { return GetInfo().prefix; } uint32_t GetCode() const { return GetInfo().code; } - size_t GetLength() const { return HasPrefix() ? 2 : 1; } + size_t GetLength() const { return GetBytes().size(); } const char* GetName() const { return GetInfo().name; } Type GetResultType() const { return GetInfo().result_type; } Type GetParamType1() const { return GetInfo().param1_type; } @@ -62,6 +65,9 @@ struct Opcode { Type GetParamType3() const { return GetInfo().param3_type; } Address GetMemorySize() const { return GetInfo().memory_size; } + // Get the byte sequence for this opcode, including prefix. + std::vector<uint8_t> GetBytes() const; + // Get the lane count of an extract/replace simd op. uint32_t GetSimdLaneCount() const; |