diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-26 17:15:16 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2026-10-26 17:15:16 +0100 |
| commit | d38e1ffb1533565ecea6dd83cca88d36690fadef (patch) | |
| tree | 4946ffec374d8d0353a909b2ae314b81cbf07031 /src/zilch/app/object-store.js | |
| parent | 8dd8f96b24710dc4f2d29065928244a40a432379 (diff) | |
zilch: implement async
Diffstat (limited to 'src/zilch/app/object-store.js')
| -rw-r--r-- | src/zilch/app/object-store.js | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/zilch/app/object-store.js b/src/zilch/app/object-store.js index 9a68478..8a4715d 100644 --- a/src/zilch/app/object-store.js +++ b/src/zilch/app/object-store.js @@ -36,12 +36,12 @@ class ObjectStore { } static decodeCall(view, offset) { - const kind = ObjectStore.methods[view.getUint32(offset, true)] + const method = ObjectStore.methods[view.getUint32(offset, true)] - if (!kind) throw "unknown method, cannot decode"; + if (!method) throw "unknown method, cannot decode"; return { - kind: kind, + method: method, num_args: view.getUint8(offset + 4, true), } } @@ -141,7 +141,7 @@ class ObjectStore { } } - static processWasm( + static async processWasm( calls_base, values_base, result_base, @@ -159,16 +159,21 @@ class ObjectStore { const results = []; for (let i = 0; i < length; ++i) { - const method = ObjectStore.decodeCall(calls_view, offset.call); + const call = ObjectStore.decodeCall(calls_view, offset.call); offset.call += wasm.size_of.Call; - let args = new Array(method.num_args).fill().map(_ => { + let args = new Array(call.num_args).fill().map(_ => { const value = ObjectStore.decodeValue(values_view, offset.value, results); offset.value += wasm.size_of.Value; return value; }); - const result = method.kind(...args); + let result = call.method.fn(...args); + + if (call.method.await) { + result = await result; + } + const result_ptr = results_view.getUint32(offset.result, true); offset.result += wasm.size_of.Ptr; |