aboutsummaryrefslogtreecommitdiff
path: root/tools/translate.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/translate.c')
-rw-r--r--tools/translate.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/translate.c b/tools/translate.c
index ee6ea99..4361d6f 100644
--- a/tools/translate.c
+++ b/tools/translate.c
@@ -3,6 +3,7 @@
/* WebAssembly opcodes */
#define WASM_END 0x0B
+#define WASM_CALL 0x10
#define WASM_LOCAL_GET 0x20
#define WASM_I32_LOAD 0x28
#define WASM_I32_LOAD8_S 0x2C
@@ -63,6 +64,26 @@ int translate(FILE *handle, struct function *function, struct module *module)
goto fail;
matched = 1;
+ } else if (wasm_opcode == WASM_CALL) {
+ uint32_t funcidx;
+ struct instruction **target;
+
+ if (leb_u32(handle, &funcidx)) {
+ PRERR(MSG_BAD_NUM);
+ goto fail;
+ }
+
+ if (funcidx >= module->functions_count) {
+ PRERR(MSG_BAD_IDX("funcidx"));
+ goto fail;
+ }
+
+ target = &module->functions[funcidx].translated_body;
+
+ if (i_call(ptr(target), &expr))
+ goto fail;
+
+ matched = 1;
} else if (wasm_opcode <= WASM_I64_STORE32 &&
wasm_opcode >= WASM_I32_LOAD) {
uint32_t align, offset;