basic error handling, add ts impl to compare to, stumped...

This commit is contained in:
2023-03-29 19:19:23 +02:00
parent c69d395ab5
commit 976832c6e6
3 changed files with 55 additions and 12 deletions

24
main.ts Normal file
View File

@@ -0,0 +1,24 @@
let U8 = (...a) => new Uint8Array(...a);
let memory = new WebAssembly.Memory({ initial: 4 });
let memU8 = U8(memory.buffer);
let importObject = {
env: {
memory
}
};
let loaderWasm = await Deno.readFile("loader.wasm");
let loader = (await WebAssembly.instantiate(loaderWasm, importObject)).instance;
let platformUw8 = await Deno.readFile("platform.uw8");
console.log("platform.uw8 size: " + platformUw8.byteLength);
memU8.set(U8(platformUw8));
let platformSize = loader.exports.load_uw8(platformUw8.byteLength);
let platformWasm = new ArrayBuffer(platformSize);
U8(platformWasm).set(memU8.slice(0, platformSize));
console.log("Unpacked platform size: " + platformSize);
console.log("First byte: " + U8(platformWasm)[0]);