aboutsummaryrefslogtreecommitdiff
path: root/src/zilch/App/load.js
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2026-10-19 13:08:25 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2026-10-19 13:08:25 +0200
commit0790cae660a6602697c63cf8b4ada78aa3661f82 (patch)
tree09ec9852285081fd9a42bebbb0f4913fb6f0118a /src/zilch/App/load.js
parent3c1ef9ef717f25341c445dc33a5c9e7b17b74217 (diff)
zilch: export sizeof of shared structs
Diffstat (limited to 'src/zilch/App/load.js')
-rw-r--r--src/zilch/App/load.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/zilch/App/load.js b/src/zilch/App/load.js
new file mode 100644
index 0000000..e93a4a6
--- /dev/null
+++ b/src/zilch/App/load.js
@@ -0,0 +1,37 @@
+const imports = {
+ object_store: {
+ process: ObjectStore.processWasm,
+ },
+ console: {
+ log(buffer, length) {
+ console.log(ObjectStore.decodeString(buffer, length))
+ },
+ warn(buffer, length) {
+ console.warn(ObjectStore.decodeString(buffer, length))
+ },
+ err(buffer, length) {
+ console.error(ObjectStore.decodeString(buffer, length))
+ },
+ debug(buffer, length) {
+ console.debug(ObjectStore.decodeString(buffer, length))
+ },
+ }
+}
+
+const wasm_ready = WebAssembly.instantiateStreaming(fetch("index.wasm"), imports).then(
+ ({ instance, module }) => {
+ const view = new DataView(instance.exports.memory.buffer);
+ const type_names = [ 'Call', 'Value', 'Ptr' ];
+ const size_of = {};
+
+ for (const type of type_names) {
+ size_of[type] = view.getUint16(instance.exports[`type::size::${type}`], true);
+ }
+
+ wasm = {
+ exports: instance.exports,
+ memory: instance.exports.memory,
+ size_of: size_of,
+ }
+ },
+);