Created
November 19, 2020 16:32
-
-
Save Shikugawa/1036a9d9e5a710e4f4729709e00749a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() { | |
auto mod = wasmparser::Parser::doParse("../testdata/fibonacci.wasm"); | |
std::cout << mod.code_sec.size << std::endl; | |
auto decoder = wasmparser::InstructionDecoder(&mod); | |
// using Byte = unsigned char; | |
// { | |
// Byte buf1[1] = {0x04}; | |
// uint32_t a; | |
// wasmparser::decodeULEB128(&buf1[0], &buf1[0], &a); | |
// std::cout << a << std::endl; | |
// | |
// Byte buf2[2] = {0x80, 0x7f}; | |
// uint32_t b; | |
// wasmparser::decodeULEB128(&buf2[0], &buf2[1], &b); | |
// std::cout << b << std::endl; | |
// | |
// Byte buf3[3] = {0xe5, 0x8e, 0x26}; | |
// uint32_t c; | |
// wasmparser::decodeULEB128(&buf3[0], &buf3[2], &c); | |
// std::cout << c << std::endl; | |
// | |
// Byte buf4[4] = {0x80, 0x80, 0x80, 0x4f}; | |
// uint32_t d; | |
// wasmparser::decodeULEB128(&buf4[0], &buf4[3], &d); | |
// std::cout << d << std::endl; | |
// | |
// Byte buf5[5] = {0x89, 0x80, 0x80, 0x80, 0x01}; | |
// uint32_t e; | |
// wasmparser::decodeULEB128(&buf5[0], &buf5[4], &e); | |
// std::cout << e << std::endl; | |
// } | |
// | |
// { | |
// Byte buf1[1] = {0x04}; | |
// uint64_t a; | |
// wasmparser::decodeULEB128(&buf1[0], &buf1[0], &a); | |
// std::cout << a << std::endl; | |
// | |
// Byte buf2[2] = {0x80, 0x7f}; | |
// uint64_t b; | |
// wasmparser::decodeULEB128(&buf2[0], &buf2[1], &b); | |
// std::cout << b << std::endl; | |
// | |
// Byte buf3[3] = {0xe5, 0x8e, 0x26}; | |
// uint64_t c; | |
// wasmparser::decodeULEB128(&buf3[0], &buf3[2], &c); | |
// std::cout << c << std::endl; | |
// | |
// Byte buf4[4] = {0x80, 0x80, 0x80, 0x4f}; | |
// uint64_t d; | |
// wasmparser::decodeULEB128(&buf4[0], &buf4[3], &d); | |
// std::cout << d << std::endl; | |
// | |
// Byte buf5[10] = {0x89, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01}; | |
// uint64_t e; | |
// wasmparser::decodeULEB128(&buf5[0], &buf5[8], &e); | |
// std::cout << e << std::endl; | |
// } | |
// { | |
// Byte buf1[1] = {0x00}; | |
// int32_t a; | |
// wasmparser::decodeSLEB128(&buf1[0], &buf1[0], &a); | |
// std::cout << a << std::endl; | |
// | |
// Byte buf2[1] = {0x04}; | |
// int32_t b; | |
// wasmparser::decodeSLEB128(&buf2[0], &buf2[0], &b); | |
// std::cout << b << std::endl; | |
// | |
// Byte buf3[2] = {0xFF, 0x00}; | |
// int32_t c; | |
// wasmparser::decodeSLEB128(&buf3[0], &buf3[1], &c); | |
// std::cout << c << std::endl; | |
// | |
// Byte buf4[2] = {0x81, 0x01}; | |
// int32_t d; | |
// wasmparser::decodeSLEB128(&buf4[0], &buf4[1], &d); | |
// std::cout << d << std::endl; | |
// | |
// Byte buf5[1] = {0x7f}; | |
// int32_t e; | |
// wasmparser::decodeSLEB128(&buf5[0], &buf5[1], &e); | |
// std::cout << e << std::endl; | |
// | |
// Byte buf6[2] = {0x81, 0x7f}; | |
// int32_t f; | |
// wasmparser::decodeSLEB128(&buf6[0], &buf6[1], &f); | |
// std::cout << f << std::endl; | |
// | |
// Byte buf7[2] = {0xFF, 0x7e}; | |
// int32_t g; | |
// wasmparser::decodeSLEB128(&buf7[0], &buf7[1], &g); | |
// std::cout << g << std::endl; | |
// } | |
// | |
// { | |
// Byte buf1[1] = {0x00}; | |
// int64_t a; | |
// wasmparser::decodeSLEB128(&buf1[0], &buf1[0], &a); | |
// std::cout << a << std::endl; | |
// | |
// Byte buf2[2] = {0x04}; | |
// int64_t b; | |
// wasmparser::decodeSLEB128(&buf2[0], &buf2[0], &b); | |
// std::cout << b << std::endl; | |
// | |
// Byte buf3[2] = {0xFF, 0x00}; | |
// int64_t c; | |
// wasmparser::decodeSLEB128(&buf3[0], &buf3[1], &c); | |
// std::cout << c << std::endl; | |
// | |
// Byte buf4[2] = {0x81, 0x01}; | |
// int64_t d; | |
// wasmparser::decodeSLEB128(&buf4[0], &buf4[1], &d); | |
// std::cout << d << std::endl; | |
// | |
// Byte buf5[1] = {0x7f}; | |
// int64_t e; | |
// wasmparser::decodeSLEB128(&buf5[0], &buf5[1], &e); | |
// std::cout << e << std::endl; | |
// | |
// Byte buf6[2] = {0x81, 0x7f}; | |
// int64_t f; | |
// wasmparser::decodeSLEB128(&buf6[0], &buf6[1], &f); | |
// std::cout << f << std::endl; | |
// | |
// Byte buf7[2] = {0xFF, 0x7e}; | |
// int64_t g; | |
// wasmparser::decodeSLEB128(&buf7[0], &buf7[1], &g); | |
// std::cout << g << std::endl; | |
// | |
// Byte buf8[10] = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x7f}; | |
// int64_t h; | |
// wasmparser::decodeSLEB128(&buf8[0], &buf8[1], &h); | |
// std::cout << h << std::endl; | |
// } | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment