mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +00:00
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 :^)
This commit is contained in:
parent
bdd7741ae1
commit
a2af04837e
5 changed files with 450 additions and 1 deletions
19
Base/res/html/misc/wasm.html
Normal file
19
Base/res/html/misc/wasm.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<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>
|
Loading…
Add table
Add a link
Reference in a new issue