aboutsummaryrefslogtreecommitdiff
path: root/src/zilch/app/object-store.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/zilch/app/object-store.js')
-rw-r--r--src/zilch/app/object-store.js19
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;