diff options
author | Konstantin Itskov <[email protected]> | 2019-09-15 20:12:24 -0400 |
---|---|---|
committer | Ayke <[email protected]> | 2019-09-16 13:36:37 +0200 |
commit | 4eb34b36f8843a06402d52408571c298e605032a (patch) | |
tree | 50d4ebfe3850b938eeed0ad3fa574a261a501eb4 /targets/wasm_exec.js | |
parent | 61750be9aa9f4f7b87dbe69c40b55225fd4c9706 (diff) | |
download | tinygo-4eb34b36f8843a06402d52408571c298e605032a.tar.gz tinygo-4eb34b36f8843a06402d52408571c298e605032a.zip |
Add syscall/js.valueInvoke support
Diffstat (limited to 'targets/wasm_exec.js')
-rw-r--r-- | targets/wasm_exec.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/targets/wasm_exec.js b/targets/wasm_exec.js index 3f2a6b5aa..665ac7950 100644 --- a/targets/wasm_exec.js +++ b/targets/wasm_exec.js @@ -265,17 +265,17 @@ }, // func valueInvoke(v ref, args []ref) (ref, bool) - //"syscall/js.valueInvoke": (sp) => { - // try { - // const v = loadValue(sp + 8); - // const args = loadSliceOfValues(sp + 16); - // storeValue(sp + 40, Reflect.apply(v, undefined, args)); - // mem().setUint8(sp + 48, 1); - // } catch (err) { - // storeValue(sp + 40, err); - // mem().setUint8(sp + 48, 0); - // } - //}, + "syscall/js.valueInvoke": (ret_addr, v_addr, args_ptr, args_len, args_cap) => { + try { + const v = loadValue(v_addr); + const args = loadSliceOfValues(args_ptr, args_len, args_cap); + storeValue(ret_addr, Reflect.apply(v, undefined, args)); + mem().setUint8(ret_addr + 8, 1); + } catch (err) { + storeValue(ret_addr, err); + mem().setUint8(ret_addr + 8, 0); + } + }, // func valueNew(v ref, args []ref) (ref, bool) "syscall/js.valueNew": (ret_addr, v_addr, args_ptr, args_len, args_cap) => { |