Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
wasm_sysio_binary_ops.cpp
Go to the documentation of this file.
4#include "IR/Module.h"
5#include "IR/Operators.h"
6
7#include <vector>
8
9namespace sysio { namespace chain { namespace wasm_ops {
10using namespace IR;
11
12inline std::string to_string( NoImm imm ) {
13 return "no imm";
14}
15inline std::string to_string( MemoryImm imm ) {
16 return "memory imm";
17}
18inline std::string to_string( CallImm imm ) {
19 return "call index : "+std::to_string(uint32_t(imm.functionIndex));
20}
21inline std::string to_string( CallIndirectImm imm ) {
22 return "call indirect type : "+std::to_string(uint32_t(imm.type.index));
23}
24inline std::string to_string( uint32_t field ) {
25 return std::string("i32 : ")+std::to_string(field);
26}
27inline std::string to_string( uint64_t field ) {
28 return std::string("i64 : ")+std::to_string(field);
29}
30inline std::string to_string( blocktype field ) {
31 return std::string("blocktype : ")+std::to_string((uint32_t)field.result);
32}
33inline std::string to_string( memoryoptype field ) {
34 return std::string("memoryoptype : ")+std::to_string((uint32_t)field.end);
35}
36inline std::string to_string( memarg field ) {
37 return std::string("memarg : ")+std::to_string(field.a)+std::string(", ")+std::to_string(field.o);
38}
39inline std::string to_string( branchtabletype field ) {
40 return std::string("branchtabletype : ")+std::to_string(field.target_depth)+std::string(", ")+std::to_string(field.table_index);
41}
42
43inline std::vector<U8> pack( uint32_t field ) {
44 return { U8(field), U8(field >> 8), U8(field >> 16), U8(field >> 24) };
45}
46inline std::vector<U8> pack( uint64_t field ) {
47 return { U8(field), U8(field >> 8), U8(field >> 16), U8(field >> 24),
48 U8(field >> 32), U8(field >> 40), U8(field >> 48), U8(field >> 56)
49 };
50}
51inline std::vector<U8> pack( blocktype field ) {
52 return { U8(field.result) };
53}
54inline std::vector<U8> pack( memoryoptype field ) {
55 return { U8(field.end) };
56}
57inline std::vector<U8> pack( memarg field ) {
58 return { U8(field.a), U8(field.a >> 8), U8(field.a >> 16), U8(field.a >> 24),
59 U8(field.o), U8(field.o >> 8), U8(field.o >> 16), U8(field.o >> 24),
60 };
61
62}
63inline std::vector<U8> pack( branchtabletype field ) {
64 return { U8(field.target_depth), U8(field.target_depth >> 8), U8(field.target_depth >> 16), U8(field.target_depth >> 24),
65 U8(field.target_depth >> 32), U8(field.target_depth >> 40), U8(field.target_depth >> 48), U8(field.target_depth >> 56),
66 U8(field.table_index), U8(field.table_index >> 8), U8(field.table_index >> 16), U8(field.table_index >> 24),
67 U8(field.table_index >> 32), U8(field.table_index >> 40), U8(field.table_index >> 48), U8(field.table_index >> 56)
68
69 };
70}
71}}} // namespace sysio, chain, wasm_ops
uint8_t U8
Definition BasicTypes.h:5
Defines exception's used by fc.
ehm field
void pack(instruction_stream *stream, uint32_t field)
std::string to_string(uint32_t field)
unsigned int uint32_t
Definition stdint.h:126
unsigned __int64 uint64_t
Definition stdint.h:136
U32 functionIndex
Definition Operators.h:45
IndexedFunctionType type
Definition Operators.h:50