summaryrefslogtreecommitdiff
path: root/Base
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-05-17 00:16:44 +0430
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-05-26 15:34:13 +0430
commita2af04837eec403734fa81aa92cf112fa10bc0b7 (patch)
tree70e03d71f33ffaad65728d3a00984ba4a7f11702 /Base
parentbdd7741ae12955bd31225870fa85e96a6e79e9dd (diff)
downloadserenity-a2af04837eec403734fa81aa92cf112fa10bc0b7.zip
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 :^)
Diffstat (limited to 'Base')
-rw-r--r--Base/res/html/misc/wasm.html19
1 files changed, 19 insertions, 0 deletions
diff --git a/Base/res/html/misc/wasm.html b/Base/res/html/misc/wasm.html
new file mode 100644
index 0000000000..3177f9552e
--- /dev/null
+++ b/Base/res/html/misc/wasm.html
@@ -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>