From 706b4aa323c5fe51ab440f6b206df07d2486f7fd Mon Sep 17 00:00:00 2001 From: Dernbu <63487502+Dernbu@users.noreply.github.com> Date: Sat, 8 Apr 2023 22:09:59 +0800 Subject: [PATCH 1/7] minimal wasm MVP --- modules.json | 5 ++++- package.json | 2 ++ src/bundles/wasm/index.ts | 12 ++++++++++++ src/bundles/wasm/wabt.ts | 23 +++++++++++++++++++++++ yarn.lock | 30 ++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/bundles/wasm/index.ts create mode 100644 src/bundles/wasm/wabt.ts diff --git a/modules.json b/modules.json index de3832b5a2..d53e9bf51b 100644 --- a/modules.json +++ b/modules.json @@ -85,5 +85,8 @@ }, "remote_execution": { "tabs": [] + }, + "wasm": { + "tabs": [] } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 88d7361428..7f440c2e1d 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,8 @@ "react-ace": "^10.1.0", "react-dom": "^17.0.2", "regl": "^2.1.0", + "source-academy-utils": "^1.0.0", + "source-academy-wabt": "^1.0.4", "tslib": "^2.3.1" }, "jest": { diff --git a/src/bundles/wasm/index.ts b/src/bundles/wasm/index.ts new file mode 100644 index 0000000000..3358c57a3a --- /dev/null +++ b/src/bundles/wasm/index.ts @@ -0,0 +1,12 @@ +/** + * A single sentence summarising the module (this sentence is displayed larger). + * + * Sentences describing the module. More sentences about the module. + * + * @module wasm + * @author Kim Yongbeom + */ +export { + wcompile, + wrun, +} from './wabt'; diff --git a/src/bundles/wasm/wabt.ts b/src/bundles/wasm/wabt.ts new file mode 100644 index 0000000000..47dbbfe6ee --- /dev/null +++ b/src/bundles/wasm/wabt.ts @@ -0,0 +1,23 @@ +import { getParseTree, compileParseTree, compile } from 'source-academy-wabt'; +import {objectToLinkedList} from 'source-academy-utils'; + +/** + * Compile stuff + * @param program + * @returns + */ +export const wcompile = (program: string) => Array.from(compile(program)); + +/** + * Run stuff + * @param buffer + * @returns + */ +export const wrun = (buffer: number[] | Uint8Array) => { + if (buffer instanceof Array) { + buffer = new Uint8Array(buffer); + } + + const exps = new WebAssembly.Instance(new WebAssembly.Module(buffer)).exports; + return objectToLinkedList(exps); +}; diff --git a/yarn.lock b/yarn.lock index c6779f2444..17b7c946ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1694,6 +1694,11 @@ cjs-module-lexer@^1.0.0: resolved "https://registry.yarnpkg.com/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz#9f84ba3244a512f3a54e5277e8eef4c489864e40" integrity sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA== +class-transformer@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/class-transformer/-/class-transformer-0.5.1.tgz#24147d5dffd2a6cea930a3250a677addf96ab336" + integrity sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw== + classnames@^2.3.1: version "2.3.2" resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.3.2.tgz#351d813bf0137fcc6a76a16b88208d2560a0d924" @@ -4926,6 +4931,11 @@ readable-stream@~2.3.6: string_decoder "~1.1.1" util-deprecate "~1.0.1" +reflect-metadata@^0.1.13: + version "0.1.13" + resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08" + integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg== + regenerator-runtime@^0.13.11: version "0.13.11" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" @@ -5194,6 +5204,21 @@ socks@^2.6.2: ip "^2.0.0" smart-buffer "^4.2.0" +source-academy-utils@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/source-academy-utils/-/source-academy-utils-1.0.1.tgz#5fb596c952c86a6751207de6df5f5d01213d1054" + integrity sha512-xcY9kHeS+E5XY/29KPDKxWcdO3858I7Kb/IxuetNSGCrfhkIi3rVE69lsCkY1WwK6x2AwiqX2qHxrq/htfsPRQ== + +source-academy-wabt@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/source-academy-wabt/-/source-academy-wabt-1.0.6.tgz#1b221a23fe526a77c79e84fd0ddc102b3d37c15a" + integrity sha512-encnYj7gAYslqdz/DG/JCR3GkBzpo0E78gXmgyfRUZrqpgc7j/scQnxnSrBHXS2XFVF+JjvN/asIhaZ+/peXLQ== + dependencies: + class-transformer "^0.5.1" + lodash "^4.17.21" + reflect-metadata "^0.1.13" + typescript "4" + source-map-support@0.5.13: version "0.5.13" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932" @@ -5572,6 +5597,11 @@ typedoc@^0.23.23: minimatch "^6.1.6" shiki "^0.14.1" +typescript@4: + version "4.9.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" + integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== + typescript@4.8: version "4.8.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6" From 980ba228cacfa0bd109db83cf95ac06673a76d4b Mon Sep 17 00:00:00 2001 From: Dernbu <63487502+Dernbu@users.noreply.github.com> Date: Sun, 9 Apr 2023 12:18:12 +0800 Subject: [PATCH 2/7] Add comments for module methods --- src/bundles/wasm/wabt.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bundles/wasm/wabt.ts b/src/bundles/wasm/wabt.ts index 47dbbfe6ee..a108fd1cfb 100644 --- a/src/bundles/wasm/wabt.ts +++ b/src/bundles/wasm/wabt.ts @@ -1,17 +1,17 @@ -import { getParseTree, compileParseTree, compile } from 'source-academy-wabt'; -import {objectToLinkedList} from 'source-academy-utils'; +import { compile } from 'source-academy-wabt'; +import { objectToLinkedList } from 'source-academy-utils'; /** - * Compile stuff - * @param program - * @returns + * Compile a (hopefully valid) WebAssembly Text module to binary. + * @param program program to compile + * @returns an array of 8-bit unsigned integers. */ export const wcompile = (program: string) => Array.from(compile(program)); /** - * Run stuff - * @param buffer - * @returns + * Run a compiled WebAssembly Binary Buffer. + * @param buffer an array of 8-bit unsigned integers to run + * @returns a linked list of exports that the relevant WebAssembly Module exports */ export const wrun = (buffer: number[] | Uint8Array) => { if (buffer instanceof Array) { From a3c96dc45e1295a511fb759846af990cd75d71aa Mon Sep 17 00:00:00 2001 From: Dernbu <63487502+Dernbu@users.noreply.github.com> Date: Tue, 11 Apr 2023 14:54:07 +0800 Subject: [PATCH 3/7] Add documentation --- src/bundles/wasm/index.ts | 79 ++++++++++++++++++++++++++++++++++++++- src/bundles/wasm/wabt.ts | 2 +- yarn.lock | 12 +++--- 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/src/bundles/wasm/index.ts b/src/bundles/wasm/index.ts index 3358c57a3a..57ff2ba61a 100644 --- a/src/bundles/wasm/index.ts +++ b/src/bundles/wasm/index.ts @@ -1,7 +1,82 @@ /** - * A single sentence summarising the module (this sentence is displayed larger). + * WebAssembly Module for Source Academy, for developing with WebAssembly Text and Binaries. * - * Sentences describing the module. More sentences about the module. + * Examples: + * Simple 'add' library: + * ```wat + * import {wcompile, wrun} from "wasm"; + * + * const program = ` + * (module + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.add) + * (export "add" (func 0)) + * ) + * `; + * + * + * const binary = wcompile(program); + * const exports = wrun(binary); + * + * display(binary); + * display_list(exports); + * + * const add_fn = head(tail(exports)); + * + * display(add_fn(10, 35)); + * ``` + * + * 'Calculator Language': + * ```wat + * // Type your program in here! + * import {wcompile, wrun} from "wasm"; + * + * const program = ` + * (module + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.add) + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.sub) + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.mul) + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.div) + * (export "add" (func 0)) + * (export "sub" (func 1)) + * (export "mul" (func 2)) + * (export "div" (func 3)) + * )`; + * + * + * const encoding = wcompile(program); + * let exports = wrun(encoding); + * + * display_list(exports); + * + * const div = head(tail(exports)); + * exports = tail(tail(exports)); + * const mul = head(tail(exports)); + * exports = tail(tail(exports)); + * const sub = head(tail(exports)); + * exports = tail(tail(exports)); + * const add = head(tail(exports)); + * + * display(div(10, -35)); + * display(mul(10, 12347)); + * display(sub(12347, 12347)); + * display(add(10, 0)); + * ``` + * * * @module wasm * @author Kim Yongbeom diff --git a/src/bundles/wasm/wabt.ts b/src/bundles/wasm/wabt.ts index a108fd1cfb..be65124e87 100644 --- a/src/bundles/wasm/wabt.ts +++ b/src/bundles/wasm/wabt.ts @@ -20,4 +20,4 @@ export const wrun = (buffer: number[] | Uint8Array) => { const exps = new WebAssembly.Instance(new WebAssembly.Module(buffer)).exports; return objectToLinkedList(exps); -}; +}; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 17b7c946ec..45a770e170 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5205,14 +5205,14 @@ socks@^2.6.2: smart-buffer "^4.2.0" source-academy-utils@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/source-academy-utils/-/source-academy-utils-1.0.1.tgz#5fb596c952c86a6751207de6df5f5d01213d1054" - integrity sha512-xcY9kHeS+E5XY/29KPDKxWcdO3858I7Kb/IxuetNSGCrfhkIi3rVE69lsCkY1WwK6x2AwiqX2qHxrq/htfsPRQ== + version "1.0.2" + resolved "https://registry.yarnpkg.com/source-academy-utils/-/source-academy-utils-1.0.2.tgz#fc35a4e21e6e6a14743ed560978a9701af1a8bdc" + integrity sha512-cSx/Rxr0CEOr+KJKILKicOVSVknG82fMEozaituD5mjh92przLW8C4kafzXrfGMjPVb6p7lxFMk5S6QyiYI2/g== source-academy-wabt@^1.0.4: - version "1.0.6" - resolved "https://registry.yarnpkg.com/source-academy-wabt/-/source-academy-wabt-1.0.6.tgz#1b221a23fe526a77c79e84fd0ddc102b3d37c15a" - integrity sha512-encnYj7gAYslqdz/DG/JCR3GkBzpo0E78gXmgyfRUZrqpgc7j/scQnxnSrBHXS2XFVF+JjvN/asIhaZ+/peXLQ== + version "1.0.8" + resolved "https://registry.yarnpkg.com/source-academy-wabt/-/source-academy-wabt-1.0.8.tgz#2c07f4aeba392fe3bf258a1cc1e37d1c47696363" + integrity sha512-gYPLVuBjQ+Qrv9srFq5aRundsJh0hG3ZkJL1YETiIDK/mrSmU79a5rTD3+aFdpNlQOT35ZIe86iD1ZdiOrF62Q== dependencies: class-transformer "^0.5.1" lodash "^4.17.21" From 344abb9a4eb6c209d8f1e05c9bb09200cf5be45a Mon Sep 17 00:00:00 2001 From: Dernbu <63487502+Dernbu@users.noreply.github.com> Date: Thu, 13 Apr 2023 19:29:04 +0800 Subject: [PATCH 4/7] Change line endings to windows --- src/bundles/wasm/index.ts | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/bundles/wasm/index.ts b/src/bundles/wasm/index.ts index 57ff2ba61a..3ba88ac3f5 100644 --- a/src/bundles/wasm/index.ts +++ b/src/bundles/wasm/index.ts @@ -5,7 +5,7 @@ * Simple 'add' library: * ```wat * import {wcompile, wrun} from "wasm"; - * + * * const program = ` * (module * (func (param f64) (param f64) (result f64) @@ -15,24 +15,24 @@ * (export "add" (func 0)) * ) * `; - * - * + * + * * const binary = wcompile(program); * const exports = wrun(binary); - * + * * display(binary); * display_list(exports); - * + * * const add_fn = head(tail(exports)); - * + * * display(add_fn(10, 35)); * ``` - * + * * 'Calculator Language': * ```wat * // Type your program in here! * import {wcompile, wrun} from "wasm"; - * + * * const program = ` * (module * (func (param f64) (param f64) (result f64) @@ -56,13 +56,13 @@ * (export "mul" (func 2)) * (export "div" (func 3)) * )`; - * - * + * + * * const encoding = wcompile(program); * let exports = wrun(encoding); - * + * * display_list(exports); - * + * * const div = head(tail(exports)); * exports = tail(tail(exports)); * const mul = head(tail(exports)); @@ -70,13 +70,13 @@ * const sub = head(tail(exports)); * exports = tail(tail(exports)); * const add = head(tail(exports)); - * + * * display(div(10, -35)); * display(mul(10, 12347)); * display(sub(12347, 12347)); * display(add(10, 0)); * ``` - * + * * * @module wasm * @author Kim Yongbeom From d8ddc16f25e309a8445bed5b74b41b00be58e355 Mon Sep 17 00:00:00 2001 From: Dernbu <63487502+Dernbu@users.noreply.github.com> Date: Thu, 13 Apr 2023 19:35:01 +0800 Subject: [PATCH 5/7] Fix eslint --- src/bundles/wasm/wabt.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bundles/wasm/wabt.ts b/src/bundles/wasm/wabt.ts index be65124e87..a108fd1cfb 100644 --- a/src/bundles/wasm/wabt.ts +++ b/src/bundles/wasm/wabt.ts @@ -20,4 +20,4 @@ export const wrun = (buffer: number[] | Uint8Array) => { const exps = new WebAssembly.Instance(new WebAssembly.Module(buffer)).exports; return objectToLinkedList(exps); -}; \ No newline at end of file +}; From 83128d2937ef1a60d01ffeda7122d7eb5e4c72af Mon Sep 17 00:00:00 2001 From: Dernbu <63487502+Dernbu@users.noreply.github.com> Date: Thu, 13 Apr 2023 19:38:21 +0800 Subject: [PATCH 6/7] Update dependency --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 45a770e170..2a9768ae88 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5210,9 +5210,9 @@ source-academy-utils@^1.0.0: integrity sha512-cSx/Rxr0CEOr+KJKILKicOVSVknG82fMEozaituD5mjh92przLW8C4kafzXrfGMjPVb6p7lxFMk5S6QyiYI2/g== source-academy-wabt@^1.0.4: - version "1.0.8" - resolved "https://registry.yarnpkg.com/source-academy-wabt/-/source-academy-wabt-1.0.8.tgz#2c07f4aeba392fe3bf258a1cc1e37d1c47696363" - integrity sha512-gYPLVuBjQ+Qrv9srFq5aRundsJh0hG3ZkJL1YETiIDK/mrSmU79a5rTD3+aFdpNlQOT35ZIe86iD1ZdiOrF62Q== + version "1.0.10" + resolved "https://registry.yarnpkg.com/source-academy-wabt/-/source-academy-wabt-1.0.10.tgz#4187804a10b8233dc0f3498b49d07523940b4789" + integrity sha512-eRm9Q+wm9rNKpaX3X+ykKjcLyrV2O6elAIG3qmkuOeOLk3f26QEFfroBvNxLtvVokkItWRHek9T/d5Gqrqo5tQ== dependencies: class-transformer "^0.5.1" lodash "^4.17.21" From acddad3f2a7dce3cc23f9307f5679167b08191c8 Mon Sep 17 00:00:00 2001 From: Dernbu <63487502+Dernbu@users.noreply.github.com> Date: Mon, 17 Apr 2023 17:15:19 +0800 Subject: [PATCH 7/7] replace line ending --- src/bundles/wasm/index.ts | 174 +++++++++++++++++++------------------- src/bundles/wasm/wabt.ts | 46 +++++----- 2 files changed, 110 insertions(+), 110 deletions(-) diff --git a/src/bundles/wasm/index.ts b/src/bundles/wasm/index.ts index 3ba88ac3f5..89cbef8e9c 100644 --- a/src/bundles/wasm/index.ts +++ b/src/bundles/wasm/index.ts @@ -1,87 +1,87 @@ -/** - * WebAssembly Module for Source Academy, for developing with WebAssembly Text and Binaries. - * - * Examples: - * Simple 'add' library: - * ```wat - * import {wcompile, wrun} from "wasm"; - * - * const program = ` - * (module - * (func (param f64) (param f64) (result f64) - * local.get 0 - * local.get 1 - * f64.add) - * (export "add" (func 0)) - * ) - * `; - * - * - * const binary = wcompile(program); - * const exports = wrun(binary); - * - * display(binary); - * display_list(exports); - * - * const add_fn = head(tail(exports)); - * - * display(add_fn(10, 35)); - * ``` - * - * 'Calculator Language': - * ```wat - * // Type your program in here! - * import {wcompile, wrun} from "wasm"; - * - * const program = ` - * (module - * (func (param f64) (param f64) (result f64) - * local.get 0 - * local.get 1 - * f64.add) - * (func (param f64) (param f64) (result f64) - * local.get 0 - * local.get 1 - * f64.sub) - * (func (param f64) (param f64) (result f64) - * local.get 0 - * local.get 1 - * f64.mul) - * (func (param f64) (param f64) (result f64) - * local.get 0 - * local.get 1 - * f64.div) - * (export "add" (func 0)) - * (export "sub" (func 1)) - * (export "mul" (func 2)) - * (export "div" (func 3)) - * )`; - * - * - * const encoding = wcompile(program); - * let exports = wrun(encoding); - * - * display_list(exports); - * - * const div = head(tail(exports)); - * exports = tail(tail(exports)); - * const mul = head(tail(exports)); - * exports = tail(tail(exports)); - * const sub = head(tail(exports)); - * exports = tail(tail(exports)); - * const add = head(tail(exports)); - * - * display(div(10, -35)); - * display(mul(10, 12347)); - * display(sub(12347, 12347)); - * display(add(10, 0)); - * ``` - * - * - * @module wasm - * @author Kim Yongbeom - */ -export { - wcompile, - wrun, -} from './wabt'; +/** + * WebAssembly Module for Source Academy, for developing with WebAssembly Text and Binaries. + * + * Examples: + * Simple 'add' library: + * ```wat + * import {wcompile, wrun} from "wasm"; + * + * const program = ` + * (module + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.add) + * (export "add" (func 0)) + * ) + * `; + * + * + * const binary = wcompile(program); + * const exports = wrun(binary); + * + * display(binary); + * display_list(exports); + * + * const add_fn = head(tail(exports)); + * + * display(add_fn(10, 35)); + * ``` + * + * 'Calculator Language': + * ```wat + * // Type your program in here! + * import {wcompile, wrun} from "wasm"; + * + * const program = ` + * (module + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.add) + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.sub) + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.mul) + * (func (param f64) (param f64) (result f64) + * local.get 0 + * local.get 1 + * f64.div) + * (export "add" (func 0)) + * (export "sub" (func 1)) + * (export "mul" (func 2)) + * (export "div" (func 3)) + * )`; + * + * + * const encoding = wcompile(program); + * let exports = wrun(encoding); + * + * display_list(exports); + * + * const div = head(tail(exports)); + * exports = tail(tail(exports)); + * const mul = head(tail(exports)); + * exports = tail(tail(exports)); + * const sub = head(tail(exports)); + * exports = tail(tail(exports)); + * const add = head(tail(exports)); + * + * display(div(10, -35)); + * display(mul(10, 12347)); + * display(sub(12347, 12347)); + * display(add(10, 0)); + * ``` + * + * + * @module wasm + * @author Kim Yongbeom + */ +export { + wcompile, + wrun, +} from './wabt'; diff --git a/src/bundles/wasm/wabt.ts b/src/bundles/wasm/wabt.ts index a108fd1cfb..bdf5d5a0f8 100644 --- a/src/bundles/wasm/wabt.ts +++ b/src/bundles/wasm/wabt.ts @@ -1,23 +1,23 @@ -import { compile } from 'source-academy-wabt'; -import { objectToLinkedList } from 'source-academy-utils'; - -/** - * Compile a (hopefully valid) WebAssembly Text module to binary. - * @param program program to compile - * @returns an array of 8-bit unsigned integers. - */ -export const wcompile = (program: string) => Array.from(compile(program)); - -/** - * Run a compiled WebAssembly Binary Buffer. - * @param buffer an array of 8-bit unsigned integers to run - * @returns a linked list of exports that the relevant WebAssembly Module exports - */ -export const wrun = (buffer: number[] | Uint8Array) => { - if (buffer instanceof Array) { - buffer = new Uint8Array(buffer); - } - - const exps = new WebAssembly.Instance(new WebAssembly.Module(buffer)).exports; - return objectToLinkedList(exps); -}; +import { compile } from 'source-academy-wabt'; +import { objectToLinkedList } from 'source-academy-utils'; + +/** + * Compile a (hopefully valid) WebAssembly Text module to binary. + * @param program program to compile + * @returns an array of 8-bit unsigned integers. + */ +export const wcompile = (program: string) => Array.from(compile(program)); + +/** + * Run a compiled WebAssembly Binary Buffer. + * @param buffer an array of 8-bit unsigned integers to run + * @returns a linked list of exports that the relevant WebAssembly Module exports + */ +export const wrun = (buffer: number[] | Uint8Array) => { + if (buffer instanceof Array) { + buffer = new Uint8Array(buffer); + } + + const exps = new WebAssembly.Instance(new WebAssembly.Module(buffer)).exports; + return objectToLinkedList(exps); +};