ladybird/Base/res/html/misc/wasm.html
Ali Mohammad Pur a2af04837e LibWeb: Implement a very basic WebAssembly JS API
This impl is *extremely* simple, and is missing a lot of things, it's
also not particularly spec-compliant in some places, but it's definitely
a start :^)
2021-05-26 15:34:13 +04:30

20 lines
913 B
HTML

<html>
<body>
<script>
const bytes = new Uint8Array([
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x60,
0x01, 0x7f, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x07, 0x07, 0x01, 0x03,
0x66, 0x69, 0x62, 0x00, 0x00, 0x0a, 0x1f, 0x01, 0x1d, 0x00, 0x20, 0x00,
0x41, 0x02, 0x48, 0x04, 0x40, 0x41, 0x01, 0x0f, 0x0b, 0x20, 0x00, 0x41,
0x02, 0x6b, 0x10, 0x00, 0x20, 0x00, 0x41, 0x01, 0x6b, 0x10, 0x00, 0x6a,
0x0f, 0x0b
]);
WebAssembly.compile(bytes)
.then(module => WebAssembly.instantiate(module))
.then(instance => instance.exports.fib(10))
.then(value => console.log("Calculated fib(10) with wasm and got " + value))
.catch(err => console.log(err.message));
</script>
</body>
</html>