more wasm
This commit is contained in:
parent
9d67af9901
commit
9ac87f93e9
5 changed files with 72 additions and 0 deletions
28
out/index.js
Normal file
28
out/index.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { WASI, OpenFile, File, ConsoleStdout } from "https://cdn.jsdelivr.net/npm/@bjorn3/browser_wasi_shim@0.3.0/dist/index.js";
|
||||
import ghc_wasm_jsffi from "./ghc_wasm_jsffi.js"
|
||||
|
||||
const args = [];
|
||||
const env = ["GHCRTS=-H64m"];
|
||||
const fds = [
|
||||
new OpenFile(new File([])), // stdin
|
||||
ConsoleStdout.lineBuffered((msg) => console.log(`[WASI stdout] ''${msg}`)),
|
||||
ConsoleStdout.lineBuffered((msg) => console.warn(`[WASI stderr] ''${msg}`)),
|
||||
];
|
||||
const options = { debug: false };
|
||||
const wasi = new WASI(args, env, fds, options);
|
||||
|
||||
let __exports = {};
|
||||
|
||||
const { instance } = await WebAssembly.instantiateStreaming(
|
||||
fetch("numbersquare.wasm"),
|
||||
{
|
||||
ghc_wasm_jsffi: ghc_wasm_jsffi(__exports),
|
||||
wasi_snapshot_preview1: wasi.wasiImport,
|
||||
}
|
||||
);
|
||||
|
||||
Object.assign(__exports, instance.exports);
|
||||
|
||||
wasi.initialize(instance);
|
||||
console.log(instance)
|
||||
await instance.exports.hs_start(globalThis.example);
|
||||
Loading…
Add table
Add a link
Reference in a new issue