diff options
author | Wojciech Kosior <kwojtus@protonmail.com> | 2020-10-03 21:45:24 +0200 |
---|---|---|
committer | Wojciech Kosior <kwojtus@protonmail.com> | 2020-10-05 10:13:38 +0200 |
commit | 7a61f213fb9be8ab7f9bd0fb33940b21fa143b05 (patch) | |
tree | 1bd5beab68c778d4d3a2543cf3661bfcb23445c2 /tools/wasm.h | |
parent | c548c0ce5b2e7ca2784257966ebdd386e1f31218 (diff) | |
download | AGH-engineering-thesis-7a61f213fb9be8ab7f9bd0fb33940b21fa143b05.tar.gz AGH-engineering-thesis-7a61f213fb9be8ab7f9bd0fb33940b21fa143b05.zip |
fixes, conditional if-not jump and translation of if-else instruction from wasm
Diffstat (limited to 'tools/wasm.h')
-rw-r--r-- | tools/wasm.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/wasm.h b/tools/wasm.h index 07252fc..bf85490 100644 --- a/tools/wasm.h +++ b/tools/wasm.h @@ -22,6 +22,8 @@ #define EXPORT_GLOBALIDX 0x03 /* WebAssembly opcodes */ +#define WASM_IF 0x04 +#define WASM_ELSE 0x05 #define WASM_END 0x0B #define WASM_CALL 0x10 @@ -43,3 +45,31 @@ #define WASM_I32_SUB 0x6B #define WASM_I32_MUL 0x6C #define WASM_I32_DIV_U 0x6E + +static inline int is_valid_valtype(char value_type) +{ + if (value_type == VALTYPE_I32) + return 1; + + if (value_type == VALTYPE_I64 || + value_type == VALTYPE_F32 || + value_type == VALTYPE_F64) + PRERR("Only type i32 is recognized for now"); + + return -1; + + /* return */ + /* value_type == VALTYPE_I32 || */ + /* value_type == VALTYPE_I64 || */ + /* value_type == VALTYPE_F32 || */ + /* value_type == VALTYPE_F64; */ +} + +static inline int is_valid_exportdesc(char desc) +{ + return + desc == EXPORT_FUNCIDX || + desc == EXPORT_TABLEIDX || + desc == EXPORT_MEMIDX || + desc == EXPORT_GLOBALIDX; +} |