Skip to content

Commit

Permalink
Merge pull request #15 from grain-lang/binaryen-js
Browse files Browse the repository at this point in the history
binaryen.ml.js
  • Loading branch information
phated committed Jul 22, 2020
2 parents d906cd8 + 2671a76 commit b0e19b0
Show file tree
Hide file tree
Showing 29 changed files with 1,684 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -1,3 +1,6 @@
[submodule "src/binaryen"]
path = src/binaryen
url = https://github.com/WebAssembly/binaryen
[submodule "js/binaryen.js"]
path = js/binaryen.js
url = https://github.com/AssemblyScript/binaryen.js
3 changes: 3 additions & 0 deletions binaryen.opam
Expand Up @@ -14,4 +14,7 @@ depends: [
"dune" {>= "2.6"}
"conf-cmake" {build}
"conf-python-3" {build}
"js_of_ocaml" {>= "3.6.0"}
"js_of_ocaml-ppx" {>= "3.6.0"}
"js_of_ocaml-compiler" {>= "3.6.0"}
]
2 changes: 1 addition & 1 deletion dune
@@ -1 +1 @@
(dirs :standard virtual)
(dirs :standard virtual js)
3 changes: 3 additions & 0 deletions esy.json
Expand Up @@ -11,6 +11,9 @@
"devDependencies": {
"@opam/conf-cmake": "*",
"@opam/conf-python-3": "*",
"@opam/js_of_ocaml": ">=3.6.0",
"@opam/js_of_ocaml-ppx": ">=3.6.0",
"@opam/js_of_ocaml-compiler": ">=3.6.0",
"@opam/ocamlformat": "*",
"@opam/ocaml-lsp-server": "ocaml/ocaml-lsp:ocaml-lsp-server.opam#ce1840355541ff60b999e39388835027f89d8798"
},
Expand Down
129 changes: 128 additions & 1 deletion esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions esy.lock/opam/js_of_ocaml-compiler.3.6.0/opam

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions esy.lock/opam/js_of_ocaml-ppx.3.6.0/opam

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions esy.lock/opam/js_of_ocaml.3.6.0/opam

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions esy.lock/opam/ppx_tools_versioned.5.4.0/opam

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/binaryen.js
Submodule binaryen.js added at aed6e3
10 changes: 10 additions & 0 deletions js/dune
@@ -0,0 +1,10 @@
(library
(name binaryen_js)
(public_name binaryen.js)
(implements binaryen)
(libraries js_of_ocaml)
(preprocess
(pps js_of_ocaml-ppx))
(js_of_ocaml
(flags --no-sourcemap)
(javascript_files binaryen.js/index.js postlude.js)))
23 changes: 23 additions & 0 deletions js/export.ml
@@ -0,0 +1,23 @@
open Js_of_ocaml.Js
open Js_of_ocaml.Js.Unsafe

type t

let add_function_export wasm_mod internal_name external_name =
meth_call wasm_mod "addFunctionExport"
[| inject (string internal_name); inject (string external_name) |]

let add_table_export wasm_mod internal_name external_name =
meth_call wasm_mod "addTableExport"
[| inject (string internal_name); inject (string external_name) |]

let add_memory_export wasm_mod internal_name external_name =
meth_call wasm_mod "addMemoryExport"
[| inject (string internal_name); inject (string external_name) |]

let add_global_export wasm_mod internal_name external_name =
meth_call wasm_mod "addGlobalExport"
[| inject (string internal_name); inject (string external_name) |]

let remove_export wasm_mod external_name =
meth_call wasm_mod "removeExport" [| inject (string external_name) |]

0 comments on commit b0e19b0

Please sign in to comment.