Assemble kernel on client

This commit is contained in:
2026-03-18 14:23:37 +00:00
parent 6ee4adfea5
commit c91f46be88
2 changed files with 22 additions and 3 deletions

16
boot.js
View File

@@ -1,7 +1,19 @@
import { Assembler } from './asm.js';
const assemble = (async () => {
const asm = new Assembler();
const resp = await fetch('wipforth.ws');
for await (const chunk of resp.body) {
asm.push(chunk);
}
return asm.wasm();
})();
self.onmessage = async (e) => {
const exports = { emu: { mem: e.data } };
const mod = await WebAssembly.instantiateStreaming(
fetch('wipforth.wasm'), exports)
const wasm = await assemble;
const mod = await WebAssembly.instantiate(wasm, exports);
await self.postMessage('booting');
mod.instance.exports.reset();
console.log('System halt');
};