@grain/binaryen.ml 0.9.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. {binaryen-archive → binaryen-archive-v0.11.2}/.gitattributes +0 -0
  2. {binaryen-archive → binaryen-archive-v0.11.2}/.gitignore +1 -0
  3. {binaryen-archive → binaryen-archive-v0.11.2}/.gitmodules +0 -0
  4. {binaryen-archive → binaryen-archive-v0.11.2}/CHANGELOG.md +73 -0
  5. {binaryen-archive → binaryen-archive-v0.11.2}/LICENSE +0 -0
  6. {binaryen-archive → binaryen-archive-v0.11.2}/README.md +27 -3
  7. {binaryen-archive → binaryen-archive-v0.11.2}/binaryen.opam +8 -8
  8. {binaryen-archive → binaryen-archive-v0.11.2}/dune +0 -0
  9. {binaryen-archive → binaryen-archive-v0.11.2}/dune-project +0 -0
  10. {binaryen-archive → binaryen-archive-v0.11.2}/dune-workspace +0 -0
  11. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/.gitattributes +0 -0
  12. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/.gitignore +0 -0
  13. binaryen-archive-v0.11.2/esy.lock/index.json +1365 -0
  14. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/astring.0.8.5/opam +0 -0
  15. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/base-threads.base/opam +0 -0
  16. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/base-unix.base/opam +0 -0
  17. {binaryen-archive/esy.lock/opam/base.v0.14.1 → binaryen-archive-v0.11.2/esy.lock/opam/base.v0.14.2}/opam +4 -4
  18. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/biniou.1.2.1/opam +1 -1
  19. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/cmdliner.1.0.4/opam +0 -0
  20. {binaryen-archive/esy.lock/opam/cppo.1.6.7 → binaryen-archive-v0.11.2/esy.lock/opam/cppo.1.6.8}/opam +4 -6
  21. {binaryen-archive/esy.lock/opam/csexp.1.4.0 → binaryen-archive-v0.11.2/esy.lock/opam/csexp.1.5.1}/opam +11 -9
  22. {binaryen-archive/esy.lock/opam/dune-build-info.2.8.2 → binaryen-archive-v0.11.2/esy.lock/opam/dune-build-info.2.9.1}/opam +5 -5
  23. {binaryen-archive/esy.lock/opam/dune-configurator.2.8.2 → binaryen-archive-v0.11.2/esy.lock/opam/dune-configurator.2.9.1}/opam +5 -5
  24. {binaryen-archive/esy.lock/opam/dune.2.8.2 → binaryen-archive-v0.11.2/esy.lock/opam/dune.2.9.1}/opam +4 -4
  25. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/easy-format.1.3.2/opam +1 -1
  26. {binaryen-archive/esy.lock/opam/fix.20201120 → binaryen-archive-v0.11.2/esy.lock/opam/fix.20211231}/opam +7 -5
  27. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/fpath.0.7.3/opam +0 -0
  28. binaryen-archive-v0.11.2/esy.lock/opam/js_of_ocaml-compiler.3.11.0/opam +54 -0
  29. binaryen-archive-v0.11.2/esy.lock/opam/js_of_ocaml-ppx.3.11.0/opam +44 -0
  30. binaryen-archive-v0.11.2/esy.lock/opam/js_of_ocaml.3.11.0/opam +45 -0
  31. {binaryen-archive/esy.lock/opam/menhir.20201216 → binaryen-archive-v0.11.2/esy.lock/opam/menhir.20211128}/opam +8 -6
  32. {binaryen-archive/esy.lock/opam/menhirLib.20201216 → binaryen-archive-v0.11.2/esy.lock/opam/menhirLib.20211128}/opam +8 -6
  33. {binaryen-archive/esy.lock/opam/menhirSdk.20201216 → binaryen-archive-v0.11.2/esy.lock/opam/menhirSdk.20211128}/opam +8 -6
  34. binaryen-archive-v0.11.2/esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam +39 -0
  35. {binaryen-archive/esy.lock/opam/ocaml-lsp-server.1.4.0 → binaryen-archive-v0.11.2/esy.lock/opam/ocaml-lsp-server.1.9.0}/opam +15 -12
  36. {binaryen-archive/esy.lock/opam/ocaml-migrate-parsetree.2.1.0 → binaryen-archive-v0.11.2/esy.lock/opam/ocaml-migrate-parsetree.2.3.0}/opam +13 -10
  37. binaryen-archive-v0.11.2/esy.lock/opam/ocaml-version.3.4.0/opam +49 -0
  38. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/ocamlbuild.0.14.0/opam +1 -1
  39. {binaryen-archive/esy.lock/opam/ocamlfind.1.8.1 → binaryen-archive-v0.11.2/esy.lock/opam/ocamlfind.1.9.1}/opam +19 -39
  40. binaryen-archive-v0.11.2/esy.lock/opam/ocamlformat-rpc-lib.0.19.0/opam +40 -0
  41. binaryen-archive-v0.11.2/esy.lock/opam/ocamlformat.0.18.0/opam +56 -0
  42. {binaryen-archive/esy.lock/opam/odoc.1.5.2 → binaryen-archive-v0.11.2/esy.lock/opam/odoc.1.5.3}/opam +12 -12
  43. binaryen-archive-v0.11.2/esy.lock/opam/pp.1.1.2/opam +58 -0
  44. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/ppx_derivers.1.2.1/opam +1 -1
  45. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/ppx_yojson_conv_lib.v0.14.0/opam +2 -2
  46. {binaryen-archive/esy.lock/opam/ppxlib.0.21.0 → binaryen-archive-v0.11.2/esy.lock/opam/ppxlib.0.22.2}/opam +40 -32
  47. {binaryen-archive/esy.lock/opam/re.1.9.0 → binaryen-archive-v0.11.2/esy.lock/opam/re.1.10.3}/opam +8 -4
  48. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/result.1.5/opam +2 -2
  49. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/seq.base/files/META.seq +0 -0
  50. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/seq.base/files/seq.install +0 -0
  51. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/seq.base/opam +0 -0
  52. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/sexplib0.v0.14.0/opam +2 -2
  53. binaryen-archive-v0.11.2/esy.lock/opam/spawn.v0.15.0/opam +56 -0
  54. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/stdio.v0.14.0/opam +2 -2
  55. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/stdlib-shims.0.3.0/opam +0 -0
  56. {binaryen-archive/esy.lock/opam/topkg.1.0.3 → binaryen-archive-v0.11.2/esy.lock/opam/topkg.1.0.4}/opam +18 -22
  57. binaryen-archive-v0.11.2/esy.lock/opam/tyxml.4.5.0/opam +42 -0
  58. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/uchar.0.0.2/opam +0 -0
  59. binaryen-archive-v0.11.2/esy.lock/opam/uucp.14.0.0/opam +41 -0
  60. {binaryen-archive/esy.lock/opam/uuseg.13.0.0 → binaryen-archive-v0.11.2/esy.lock/opam/uuseg.14.0.0}/opam +22 -28
  61. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/uutf.1.0.2/opam +0 -0
  62. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/yojson.1.7.0/opam +1 -1
  63. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/files/ocamlbuild-0.14.0.patch +0 -0
  64. {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/package.json +0 -0
  65. binaryen-archive/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override/files/findlib-1.8.1.patch → binaryen-archive-v0.11.2/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.1_opam_override/files/findlib-1.9.1.patch +0 -0
  66. {binaryen-archive/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.8.1_opam_override → binaryen-archive-v0.11.2/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.1_opam_override}/package.json +1 -1
  67. binaryen-archive-v0.11.2/js/binaryen.es5.js +5 -0
  68. {binaryen-archive → binaryen-archive-v0.11.2}/js/dune +1 -6
  69. binaryen-archive-v0.11.2/js/element_segment.ml +33 -0
  70. binaryen-archive-v0.11.2/js/export.ml +60 -0
  71. binaryen-archive-v0.11.2/js/expression.ml +944 -0
  72. binaryen-archive-v0.11.2/js/function.ml +60 -0
  73. binaryen-archive-v0.11.2/js/global.ml +48 -0
  74. {binaryen-archive → binaryen-archive-v0.11.2}/js/import.ml +24 -0
  75. {binaryen-archive → binaryen-archive-v0.11.2}/js/literal.ml +0 -0
  76. {binaryen-archive → binaryen-archive-v0.11.2}/js/memory.ml +0 -0
  77. {binaryen-archive → binaryen-archive-v0.11.2}/js/module.ml +42 -46
  78. {binaryen-archive → binaryen-archive-v0.11.2}/js/op.ml +9 -78
  79. binaryen-archive-v0.11.2/js/postlude.js +2 -0
  80. binaryen-archive-v0.11.2/js/prelude.js +11 -0
  81. binaryen-archive-v0.11.2/js/settings.ml +60 -0
  82. {binaryen-archive → binaryen-archive-v0.11.2}/js/stubs.c +0 -0
  83. binaryen-archive-v0.11.2/js/table.ml +29 -0
  84. {binaryen-archive → binaryen-archive-v0.11.2}/js/type.ml +3 -0
  85. binaryen-archive-v0.11.2/package.json +37 -0
  86. {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_exports.c +78 -0
  87. binaryen-archive-v0.11.2/src/binaryen_stubs_expressions.c +1710 -0
  88. {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_features.c +7 -0
  89. {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_functions.c +78 -0
  90. binaryen-archive-v0.11.2/src/binaryen_stubs_globals.c +109 -0
  91. {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_imports.c +29 -0
  92. {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_literals.c +0 -0
  93. {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_memory.c +1 -1
  94. {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_modules.c +0 -122
  95. {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_ops.c +19 -173
  96. binaryen-archive-v0.11.2/src/binaryen_stubs_settings.c +145 -0
  97. binaryen-archive-v0.11.2/src/binaryen_stubs_tables.c +145 -0
  98. {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_types.c +18 -0
  99. binaryen-archive-v0.11.2/src/dune +14 -0
  100. binaryen-archive-v0.11.2/src/element_segment.ml +13 -0
  101. binaryen-archive-v0.11.2/src/export.ml +54 -0
  102. binaryen-archive-v0.11.2/src/expression.ml +844 -0
  103. {binaryen-archive → binaryen-archive-v0.11.2}/src/function.ml +18 -0
  104. binaryen-archive-v0.11.2/src/global.ml +24 -0
  105. {binaryen-archive → binaryen-archive-v0.11.2}/src/import.ml +12 -0
  106. {binaryen-archive → binaryen-archive-v0.11.2}/src/literal.ml +0 -0
  107. {binaryen-archive → binaryen-archive-v0.11.2}/src/memory.ml +0 -0
  108. binaryen-archive-v0.11.2/src/module.ml +115 -0
  109. {binaryen-archive → binaryen-archive-v0.11.2}/src/ocaml_helpers.c +0 -8
  110. {binaryen-archive → binaryen-archive-v0.11.2}/src/ocaml_helpers.h +2 -3
  111. {binaryen-archive → binaryen-archive-v0.11.2}/src/op.ml +18 -131
  112. binaryen-archive-v0.11.2/src/settings.ml +45 -0
  113. binaryen-archive-v0.11.2/src/table.ml +26 -0
  114. {binaryen-archive → binaryen-archive-v0.11.2}/src/type.ml +2 -0
  115. binaryen-archive-v0.11.2/test/config/dune +8 -0
  116. binaryen-archive-v0.11.2/test/config/ocamlopt_flags.ml +16 -0
  117. {binaryen-archive → binaryen-archive-v0.11.2}/test/dune +4 -0
  118. {binaryen-archive → binaryen-archive-v0.11.2}/test/test.expected +38 -5
  119. binaryen-archive-v0.11.2/test/test.ml +147 -0
  120. binaryen-archive-v0.11.2/virtual/dune +6 -0
  121. binaryen-archive-v0.11.2/virtual/element_segment.mli +11 -0
  122. binaryen-archive-v0.11.2/virtual/export.mli +33 -0
  123. binaryen-archive-v0.11.2/virtual/expression.mli +423 -0
  124. {binaryen-archive → binaryen-archive-v0.11.2}/virtual/function.mli +16 -0
  125. binaryen-archive-v0.11.2/virtual/global.mli +19 -0
  126. {binaryen-archive → binaryen-archive-v0.11.2}/virtual/import.mli +8 -0
  127. {binaryen-archive → binaryen-archive-v0.11.2}/virtual/literal.mli +0 -0
  128. {binaryen-archive → binaryen-archive-v0.11.2}/virtual/memory.mli +0 -0
  129. binaryen-archive-v0.11.2/virtual/module.mli +65 -0
  130. {binaryen-archive → binaryen-archive-v0.11.2}/virtual/op.mli +9 -53
  131. binaryen-archive-v0.11.2/virtual/settings.mli +35 -0
  132. binaryen-archive-v0.11.2/virtual/table.mli +19 -0
  133. {binaryen-archive → binaryen-archive-v0.11.2}/virtual/type.mli +2 -0
  134. binaryen-archive/esy.lock/index.json +0 -1288
  135. binaryen-archive/esy.lock/opam/conf-m4.1/opam +0 -22
  136. binaryen-archive/esy.lock/opam/dot-merlin-reader.4.1/opam +0 -30
  137. binaryen-archive/esy.lock/opam/js_of_ocaml-compiler.3.9.1/opam +0 -40
  138. binaryen-archive/esy.lock/opam/js_of_ocaml-ppx.3.9.0/opam +0 -30
  139. binaryen-archive/esy.lock/opam/js_of_ocaml.3.9.0/opam +0 -31
  140. binaryen-archive/esy.lock/opam/ocaml-compiler-libs.v0.12.3/opam +0 -29
  141. binaryen-archive/esy.lock/opam/ocamlfind.1.8.1/files/ocaml-stub +0 -4
  142. binaryen-archive/esy.lock/opam/ocamlfind.1.8.1/files/ocamlfind.install +0 -6
  143. binaryen-archive/esy.lock/opam/ocamlformat.0.15.1/opam +0 -41
  144. binaryen-archive/esy.lock/opam/tyxml.4.4.0/opam +0 -47
  145. binaryen-archive/esy.lock/opam/uucp.13.0.0/opam +0 -44
  146. binaryen-archive/esy.lock/overrides/opam__s__conf_m4_opam__c__1_opam_override/package.json +0 -6
  147. binaryen-archive/js/export.ml +0 -23
  148. binaryen-archive/js/expression.ml +0 -185
  149. binaryen-archive/js/features.ml +0 -27
  150. binaryen-archive/js/function.ml +0 -29
  151. binaryen-archive/js/function_table.ml +0 -13
  152. binaryen-archive/js/global.ml +0 -19
  153. binaryen-archive/js/postlude.js +0 -2
  154. binaryen-archive/js/table.ml +0 -12
  155. binaryen-archive/package.json +0 -43
  156. binaryen-archive/src/binaryen_stubs_expressions.c +0 -410
  157. binaryen-archive/src/binaryen_stubs_function_tables.c +0 -25
  158. binaryen-archive/src/binaryen_stubs_globals.c +0 -46
  159. binaryen-archive/src/binaryen_stubs_tables.c +0 -31
  160. binaryen-archive/src/config/dune +0 -8
  161. binaryen-archive/src/config/library_flags.ml +0 -16
  162. binaryen-archive/src/dune +0 -53
  163. binaryen-archive/src/export.ml +0 -21
  164. binaryen-archive/src/expression.ml +0 -115
  165. binaryen-archive/src/features.ml +0 -49
  166. binaryen-archive/src/function_table.ml +0 -6
  167. binaryen-archive/src/global.ml +0 -10
  168. binaryen-archive/src/module.ml +0 -89
  169. binaryen-archive/src/table.ml +0 -4
  170. binaryen-archive/test/test.ml +0 -83
  171. binaryen-archive/vendor/binaryen-c.h +0 -2647
  172. binaryen-archive/vendor/js/index.es5.js +0 -5
  173. binaryen-archive/vendor/linux/libbinaryen.a +0 -0
  174. binaryen-archive/vendor/linux/libbinaryen.so +0 -0
  175. binaryen-archive/vendor/macosx/libbinaryen.a +0 -0
  176. binaryen-archive/vendor/macosx/libbinaryen.dylib +0 -0
  177. binaryen-archive/vendor/mingw64/libbinaryen.a +0 -0
  178. binaryen-archive/vendor/mingw64/libbinaryen.dll +0 -0
  179. binaryen-archive/vendor/wasm-delegations.h +0 -85
  180. binaryen-archive/virtual/dune +0 -6
  181. binaryen-archive/virtual/export.mli +0 -11
  182. binaryen-archive/virtual/expression.mli +0 -68
  183. binaryen-archive/virtual/features.mli +0 -23
  184. binaryen-archive/virtual/function_table.mli +0 -4
  185. binaryen-archive/virtual/global.mli +0 -7
  186. binaryen-archive/virtual/module.mli +0 -67
  187. binaryen-archive/virtual/table.mli +0 -2
@@ -0,0 +1,60 @@
1
+ open Js_of_ocaml.Js
2
+ open Js_of_ocaml.Js.Unsafe
3
+
4
+ type t
5
+
6
+ let add_function wasm_mod name params results vars body =
7
+ meth_call wasm_mod "addFunction"
8
+ [|
9
+ inject (string name);
10
+ inject params;
11
+ inject results;
12
+ inject (array vars);
13
+ inject body;
14
+ |]
15
+
16
+ let set_start wasm_mod func = meth_call wasm_mod "setStart" [| inject func |]
17
+
18
+ let set_debug_location func expr file line column =
19
+ ignore
20
+ (meth_call global##.binaryen "_BinaryenFunctionSetDebugLocation"
21
+ [| inject func; inject expr; inject file; inject line; inject column |])
22
+
23
+ let get_function wasm_mod name =
24
+ meth_call wasm_mod "getFunction" [| inject (string name) |]
25
+
26
+ let get_function_by_index wasm_mod index =
27
+ meth_call wasm_mod "getFunctionByIndex" [| inject index |]
28
+
29
+ let remove_function wasm_mod name =
30
+ meth_call wasm_mod "removeFunction" [| inject (string name) |]
31
+
32
+ let get_num_functions wasm_mod = meth_call wasm_mod "getNumFunctions" [||]
33
+
34
+ let get_name func =
35
+ to_string
36
+ (meth_call global ##. binaryen ##. Function "getName" [| inject func |])
37
+
38
+ let get_params func =
39
+ meth_call global ##. binaryen ##. Function "getParams" [| inject func |]
40
+
41
+ let get_results func =
42
+ meth_call global ##. binaryen ##. Function "getResults" [| inject func |]
43
+
44
+ let get_num_vars func =
45
+ meth_call global ##. binaryen ##. Function "getNumVars" [| inject func |]
46
+
47
+ let get_var func index =
48
+ meth_call
49
+ global ##. binaryen ##. Function
50
+ "getVar"
51
+ [| inject func; inject index |]
52
+
53
+ let get_body func =
54
+ meth_call global ##. binaryen ##. Function "getBody" [| inject func |]
55
+
56
+ let set_body func body =
57
+ meth_call
58
+ global ##. binaryen ##. Function
59
+ "setBody"
60
+ [| inject func; inject body |]
@@ -0,0 +1,48 @@
1
+ open Js_of_ocaml.Js
2
+ open Js_of_ocaml.Js.Unsafe
3
+
4
+ type t
5
+
6
+ let add_global wasm_mod name typ is_mut init =
7
+ meth_call wasm_mod "addGlobal"
8
+ [|
9
+ inject (string name);
10
+ inject typ;
11
+ inject (if is_mut then 1 else 0);
12
+ inject init;
13
+ |]
14
+
15
+ let get_global wasm_mod name =
16
+ meth_call wasm_mod "getGlobal" [| inject (string name) |]
17
+
18
+ let remove_global wasm_mod name =
19
+ meth_call wasm_mod "removeGlobal" [| inject (string name) |]
20
+
21
+ let get_num_globals wasm_mod = meth_call wasm_mod "getNumGlobals" [||]
22
+
23
+ let get_global_by_index wasm_mod index =
24
+ meth_call wasm_mod "getGlobalByIndex" [| inject index |]
25
+
26
+ let get_name global_ =
27
+ let global_info =
28
+ meth_call global##.binaryen "getGlobalInfo" [| inject global_ |]
29
+ in
30
+ to_string (get global_info "name")
31
+
32
+ let get_type global_ =
33
+ let global_info =
34
+ meth_call global##.binaryen "getGlobalInfo" [| inject global_ |]
35
+ in
36
+ get global_info "type"
37
+
38
+ let is_mutable global_ =
39
+ let global_info =
40
+ meth_call global##.binaryen "getGlobalInfo" [| inject global_ |]
41
+ in
42
+ to_bool (get global_info "mutable")
43
+
44
+ let get_init_expr global_ =
45
+ let global_info =
46
+ meth_call global##.binaryen "getGlobalInfo" [| inject global_ |]
47
+ in
48
+ get global_info "init"
@@ -43,3 +43,27 @@ let add_global_import wasm_mod internal_name external_module_name
43
43
  inject typ;
44
44
  inject (if is_mut then 1 else 0);
45
45
  |]
46
+
47
+ let function_import_get_module func =
48
+ let func_info =
49
+ meth_call global##.binaryen "getFunctionInfo" [| inject func |]
50
+ in
51
+ to_string (get func_info "module")
52
+
53
+ let global_import_get_module global_ =
54
+ let global_info =
55
+ meth_call global##.binaryen "getGlobalInfo" [| inject global_ |]
56
+ in
57
+ to_string (get global_info "module")
58
+
59
+ let function_import_get_base func =
60
+ let func_info =
61
+ meth_call global##.binaryen "getFunctionInfo" [| inject func |]
62
+ in
63
+ to_string (get func_info "base")
64
+
65
+ let global_import_get_base global_ =
66
+ let global_info =
67
+ meth_call global##.binaryen "getGlobalInfo" [| inject global_ |]
68
+ in
69
+ to_string (get global_info "base")
@@ -1,6 +1,36 @@
1
1
  open Js_of_ocaml.Js
2
2
  open Js_of_ocaml.Js.Unsafe
3
3
 
4
+ module Feature = struct
5
+ type t = int
6
+
7
+ let mvp : t = global ##. binaryen ##. Features ##. MVP
8
+
9
+ let atomics : t = global ##. binaryen ##. Features ##. Atomics
10
+
11
+ let bulk_memory : t = global ##. binaryen ##. Features ##. BulkMemory
12
+
13
+ let mutable_globals : t = global ##. binaryen ##. Features ##. MutableGlobals
14
+
15
+ let nontrapping_fp_to_int : t =
16
+ global ##. binaryen ##. Features ##. NontrappingFPToInt
17
+
18
+ let sign_ext : t = global ##. binaryen ##. Features ##. SignExt
19
+
20
+ let simd128 : t = global ##. binaryen ##. Features ##. SIMD128
21
+
22
+ let exception_handling : t =
23
+ global ##. binaryen ##. Features ##. ExceptionHandling
24
+
25
+ let tail_call : t = global ##. binaryen ##. Features ##. TailCall
26
+
27
+ let reference_types : t = global ##. binaryen ##. Features ##. ReferenceTypes
28
+
29
+ let multivalue : t = global ##. binaryen ##. Features ##. Multivalue
30
+
31
+ let all : t = global ##. binaryen ##. Features ##. All
32
+ end
33
+
4
34
  external u8a_to_bytes : 'a -> bytes = "caml_bytes_of_array"
5
35
 
6
36
  (* TODO: Verify this converts to bytes correctly? *)
@@ -36,56 +66,22 @@ let validate wasm_mod = meth_call wasm_mod "validate" [||]
36
66
 
37
67
  let optimize wasm_mod = meth_call wasm_mod "optimize" [||]
38
68
 
69
+ let get_features wasm_mod =
70
+ let features_int = meth_call wasm_mod "getFeatures" [||] in
71
+ let rec split_features = function
72
+ | 0 -> []
73
+ | feature when features_int land feature > 0 ->
74
+ feature :: split_features (feature lsr 1)
75
+ | feature -> split_features (feature lsr 1)
76
+ in
77
+ (* Support 32-bit OCaml where integers are 31 bits *)
78
+ (* This supports up to 31 Binaryen features *)
79
+ split_features 0x40000000
80
+
39
81
  let set_features wasm_mod features =
40
82
  meth_call wasm_mod "setFeatures"
41
83
  [| inject (List.fold_left ( lor ) 0 features) |]
42
84
 
43
- let get_optimize_level () = meth_call global##.binaryen "getOptimizeLevel" [||]
44
-
45
- let set_optimize_level level =
46
- meth_call global##.binaryen "setOptimizeLevel" [| inject level |]
47
-
48
- let get_shrink_level () = meth_call global##.binaryen "getShrinkLevel" [||]
49
-
50
- let set_shrink_level level =
51
- meth_call global##.binaryen "setShrinkLevel" [| inject level |]
52
-
53
- let get_debug_info () = meth_call global##.binaryen "getDebugInfo" [||]
54
-
55
- let set_debug_info on =
56
- meth_call global##.binaryen "setDebugInfo" [| inject on |]
57
-
58
- let get_low_memory_unused () =
59
- meth_call global##.binaryen "getLowMemoryUnused" [||]
60
-
61
- let set_low_memory_unused on =
62
- meth_call global##.binaryen "setLowMemoryUnused" [| inject on |]
63
-
64
- let get_pass_argument key =
65
- meth_call global##.binaryen "getPassArgument" [| inject (string key) |]
66
-
67
- let set_pass_argument key value =
68
- meth_call global##.binaryen "setPassArgument"
69
- [| inject (string key); inject (string value) |]
70
-
71
- let get_always_inline_max_size () =
72
- meth_call global##.binaryen "getAlwaysInlineMaxSize" [||]
73
-
74
- let set_always_inline_max_size size =
75
- meth_call global##.binaryen "setAlwaysInlineMaxSize" [| inject size |]
76
-
77
- let get_flexible_inline_max_size () =
78
- meth_call global##.binaryen "getFlexibleInlineMaxSize" [||]
79
-
80
- let set_flexible_inline_max_size size =
81
- meth_call global##.binaryen "setFlexibleInlineMaxSize" [| inject size |]
82
-
83
- let get_one_caller_inline_max_size () =
84
- meth_call global##.binaryen "getOneCallerInlineMaxSize" [||]
85
-
86
- let set_one_caller_inline_max_size size =
87
- meth_call global##.binaryen "setOneCallerInlineMaxSize" [| inject size |]
88
-
89
85
  let run_passes wasm_mod passes =
90
86
  meth_call wasm_mod "runPasses"
91
87
  [| inject (array (Array.of_list (List.map string passes))) |]
@@ -471,9 +471,6 @@ let abs_vec_i8x16 : t = global ##. binaryen ##. Operations ##. AbsVecI8x16
471
471
 
472
472
  let neg_vec_i8x16 : t = global ##. binaryen ##. Operations ##. NegVecI8x16
473
473
 
474
- let any_true_vec_i8x16 : t =
475
- global ##. binaryen ##. Operations ##. AnyTrueVecI8x16
476
-
477
474
  let all_true_vec_i8x16 : t =
478
475
  global ##. binaryen ##. Operations ##. AllTrueVecI8x16
479
476
 
@@ -502,8 +499,6 @@ let sub_sat_s_vec_i8x16 : t =
502
499
  let sub_sat_u_vec_i8x16 : t =
503
500
  global ##. binaryen ##. Operations ##. SubSatUVecI8x16
504
501
 
505
- let mul_vec_i8x16 : t = global ##. binaryen ##. Operations ##. MulVecI8x16
506
-
507
502
  let min_s_vec_i8x16 : t = global ##. binaryen ##. Operations ##. MinSVecI8x16
508
503
 
509
504
  let min_u_vec_i8x16 : t = global ##. binaryen ##. Operations ##. MinUVecI8x16
@@ -518,9 +513,6 @@ let abs_vec_i16x8 : t = global ##. binaryen ##. Operations ##. AbsVecI16x8
518
513
 
519
514
  let neg_vec_i16x8 : t = global ##. binaryen ##. Operations ##. NegVecI16x8
520
515
 
521
- let any_true_vec_i16x8 : t =
522
- global ##. binaryen ##. Operations ##. AnyTrueVecI16x8
523
-
524
516
  let all_true_vec_i16x8 : t =
525
517
  global ##. binaryen ##. Operations ##. AllTrueVecI16x8
526
518
 
@@ -565,9 +557,6 @@ let abs_vec_i32x4 : t = global ##. binaryen ##. Operations ##. AbsVecI32x4
565
557
 
566
558
  let neg_vec_i32x4 : t = global ##. binaryen ##. Operations ##. NegVecI32x4
567
559
 
568
- let any_true_vec_i32x4 : t =
569
- global ##. binaryen ##. Operations ##. AnyTrueVecI32x4
570
-
571
560
  let all_true_vec_i32x4 : t =
572
561
  global ##. binaryen ##. Operations ##. AllTrueVecI32x4
573
562
 
@@ -617,10 +606,6 @@ let neg_vec_f32x4 : t = global ##. binaryen ##. Operations ##. NegVecF32x4
617
606
 
618
607
  let sqrt_vec_f32x4 : t = global ##. binaryen ##. Operations ##. SqrtVecF32x4
619
608
 
620
- let qfma_vec_f32x4 : t = global ##. binaryen ##. Operations ##. QFMAVecF32x4
621
-
622
- let qfms_vec_f32x4 : t = global ##. binaryen ##. Operations ##. QFMSVecF32x4
623
-
624
609
  let add_vec_f32x4 : t = global ##. binaryen ##. Operations ##. AddVecF32x4
625
610
 
626
611
  let sub_vec_f32x4 : t = global ##. binaryen ##. Operations ##. SubVecF32x4
@@ -652,10 +637,6 @@ let neg_vec_f64x2 : t = global ##. binaryen ##. Operations ##. NegVecF64x2
652
637
 
653
638
  let sqrt_vec_f64x2 : t = global ##. binaryen ##. Operations ##. SqrtVecF64x2
654
639
 
655
- let qfma_vec_f64x2 : t = global ##. binaryen ##. Operations ##. QFMAVecF64x2
656
-
657
- let qfms_vec_f64x2 : t = global ##. binaryen ##. Operations ##. QFMSVecF64x2
658
-
659
640
  let add_vec_f64x2 : t = global ##. binaryen ##. Operations ##. AddVecF64x2
660
641
 
661
642
  let sub_vec_f64x2 : t = global ##. binaryen ##. Operations ##. SubVecF64x2
@@ -687,54 +668,12 @@ let trunc_sat_s_vec_f32x4_to_vec_i32x4 : t =
687
668
  let trunc_sat_u_vec_f32x4_to_vec_i32x4 : t =
688
669
  global ##. binaryen ##. Operations ##. TruncSatUVecF32x4ToVecI32x4
689
670
 
690
- let trunc_sat_s_vec_f64x2_to_vec_i64x2 : t =
691
- global ##. binaryen ##. Operations ##. TruncSatSVecF64x2ToVecI64x2
692
-
693
- let trunc_sat_u_vec_f64x2_to_vec_i64x2 : t =
694
- global ##. binaryen ##. Operations ##. TruncSatUVecF64x2ToVecI64x2
695
-
696
671
  let convert_s_vec_i32x4_to_vec_f32x4 : t =
697
672
  global ##. binaryen ##. Operations ##. ConvertSVecI32x4ToVecF32x4
698
673
 
699
674
  let convert_u_vec_i32x4_to_vec_f32x4 : t =
700
675
  global ##. binaryen ##. Operations ##. ConvertUVecI32x4ToVecF32x4
701
676
 
702
- let convert_s_vec_i64x2_to_vec_f64x2 : t =
703
- global ##. binaryen ##. Operations ##. ConvertSVecI64x2ToVecF64x2
704
-
705
- let convert_u_vec_i64x2_to_vec_f64x2 : t =
706
- global ##. binaryen ##. Operations ##. ConvertUVecI64x2ToVecF64x2
707
-
708
- let load_splat_vec8x16 : t =
709
- global ##. binaryen ##. Operations ##. LoadSplatVec8x16
710
-
711
- let load_splat_vec16x8 : t =
712
- global ##. binaryen ##. Operations ##. LoadSplatVec16x8
713
-
714
- let load_splat_vec32x4 : t =
715
- global ##. binaryen ##. Operations ##. LoadSplatVec32x4
716
-
717
- let load_splat_vec64x2 : t =
718
- global ##. binaryen ##. Operations ##. LoadSplatVec64x2
719
-
720
- let load_ext_s_vec8x8_to_vec_i16x8 : t =
721
- global ##. binaryen ##. Operations ##. LoadExtSVec8x8ToVecI16x8
722
-
723
- let load_ext_u_vec8x8_to_vec_i16x8 : t =
724
- global ##. binaryen ##. Operations ##. LoadExtUVec8x8ToVecI16x8
725
-
726
- let load_ext_s_vec16x4_to_vec_i32x4 : t =
727
- global ##. binaryen ##. Operations ##. LoadExtSVec16x4ToVecI32x4
728
-
729
- let load_ext_u_vec16x4_to_vec_i32x4 : t =
730
- global ##. binaryen ##. Operations ##. LoadExtUVec16x4ToVecI32x4
731
-
732
- let load_ext_s_vec32x2_to_vec_i64x2 : t =
733
- global ##. binaryen ##. Operations ##. LoadExtSVec32x2ToVecI64x2
734
-
735
- let load_ext_u_vec32x2_to_vec_i64x2 : t =
736
- global ##. binaryen ##. Operations ##. LoadExtUVec32x2ToVecI64x2
737
-
738
677
  let narrow_s_vec_i16x8_to_vec_i8x16 : t =
739
678
  global ##. binaryen ##. Operations ##. NarrowSVecI16x8ToVecI8x16
740
679
 
@@ -747,28 +686,20 @@ let narrow_s_vec_i32x4_to_vec_i16x8 : t =
747
686
  let narrow_u_vec_i32x4_to_vec_i16x8 : t =
748
687
  global ##. binaryen ##. Operations ##. NarrowUVecI32x4ToVecI16x8
749
688
 
750
- let widen_low_s_vec_i8x16_to_vec_i16x8 : t =
751
- global ##. binaryen ##. Operations ##. WidenLowSVecI8x16ToVecI16x8
689
+ let swizzle_vec8x16 : t = global ##. binaryen ##. Operations ##. SwizzleVec8x16
752
690
 
753
- let widen_high_s_vec_i8x16_to_vec_i16x8 : t =
754
- global ##. binaryen ##. Operations ##. WidenHighSVecI8x16ToVecI16x8
691
+ let ref_is_null : t = global ##. binaryen ##. Operations ##. RefIsNull
755
692
 
756
- let widen_low_u_vec_i8x16_to_vec_i16x8 : t =
757
- global ##. binaryen ##. Operations ##. WidenLowUVecI8x16ToVecI16x8
693
+ let ref_is_func : t = global ##. binaryen ##. Operations ##. RefIsFunc
758
694
 
759
- let widen_high_u_vec_i8x16_to_vec_i16x8 : t =
760
- global ##. binaryen ##. Operations ##. WidenHighUVecI8x16ToVecI16x8
695
+ let ref_is_data : t = global ##. binaryen ##. Operations ##. RefIsData
761
696
 
762
- let widen_low_s_vec_i16x8_to_vec_i32x4 : t =
763
- global ##. binaryen ##. Operations ##. WidenLowSVecI16x8ToVecI32x4
697
+ let ref_is_i31 : t = global ##. binaryen ##. Operations ##. RefIsI31
764
698
 
765
- let widen_high_s_vec_i16x8_to_vec_i32x4 : t =
766
- global ##. binaryen ##. Operations ##. WidenHighSVecI16x8ToVecI32x4
699
+ let ref_as_non_null : t = global ##. binaryen ##. Operations ##. RefAsNonNull
767
700
 
768
- let widen_low_u_vec_i16x8_to_vec_i32x4 : t =
769
- global ##. binaryen ##. Operations ##. WidenLowUVecI16x8ToVecI32x4
701
+ let ref_as_func : t = global ##. binaryen ##. Operations ##. RefAsFunc
770
702
 
771
- let widen_high_u_vec_i16x8_to_vec_i32x4 : t =
772
- global ##. binaryen ##. Operations ##. WidenHighUVecI16x8ToVecI32x4
703
+ let ref_as_data : t = global ##. binaryen ##. Operations ##. RefAsData
773
704
 
774
- let swizzle_vec8x16 : t = global ##. binaryen ##. Operations ##. SwizzleVec8x16
705
+ let ref_as_i31 : t = global ##. binaryen ##. Operations ##. RefAsI31
@@ -0,0 +1,2 @@
1
+ // Attach binaryen to globalThis because JSOO wraps in an iife
2
+ globalThis.binaryen = module.exports;
@@ -0,0 +1,11 @@
1
+ if (typeof module === 'undefined') {
2
+ module = {};
3
+ }
4
+
5
+ if (typeof exports === 'undefined') {
6
+ exports = {};
7
+ }
8
+
9
+ if (typeof module.exports === 'undefined') {
10
+ module.exports = exports;
11
+ }
@@ -0,0 +1,60 @@
1
+ open Js_of_ocaml.Js
2
+ open Js_of_ocaml.Js.Unsafe
3
+
4
+ let get_optimize_level () = meth_call global##.binaryen "getOptimizeLevel" [||]
5
+
6
+ let set_optimize_level level =
7
+ meth_call global##.binaryen "setOptimizeLevel" [| inject level |]
8
+
9
+ let get_shrink_level () = meth_call global##.binaryen "getShrinkLevel" [||]
10
+
11
+ let set_shrink_level level =
12
+ meth_call global##.binaryen "setShrinkLevel" [| inject level |]
13
+
14
+ (* Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO *)
15
+ let get_debug_info () = meth_call global##.binaryen "_BinaryenGetDebugInfo" [||]
16
+
17
+ (* Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO *)
18
+ let set_debug_info on =
19
+ meth_call global##.binaryen "_BinaryenSetDebugInfo" [| inject on |]
20
+
21
+ (* Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO *)
22
+ let get_low_memory_unused () =
23
+ meth_call global##.binaryen "_BinaryenGetLowMemoryUnused" [||]
24
+
25
+ (* Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO *)
26
+ let set_low_memory_unused on =
27
+ meth_call global##.binaryen "_BinaryenSetLowMemoryUnused" [| inject on |]
28
+
29
+ let get_pass_argument key =
30
+ meth_call global##.binaryen "getPassArgument" [| inject (string key) |]
31
+
32
+ let set_pass_argument key value =
33
+ meth_call global##.binaryen "setPassArgument"
34
+ [| inject (string key); inject (string value) |]
35
+
36
+ let get_always_inline_max_size () =
37
+ meth_call global##.binaryen "getAlwaysInlineMaxSize" [||]
38
+
39
+ let set_always_inline_max_size size =
40
+ meth_call global##.binaryen "setAlwaysInlineMaxSize" [| inject size |]
41
+
42
+ let get_flexible_inline_max_size () =
43
+ meth_call global##.binaryen "getFlexibleInlineMaxSize" [||]
44
+
45
+ let set_flexible_inline_max_size size =
46
+ meth_call global##.binaryen "setFlexibleInlineMaxSize" [| inject size |]
47
+
48
+ let get_one_caller_inline_max_size () =
49
+ meth_call global##.binaryen "getOneCallerInlineMaxSize" [||]
50
+
51
+ let set_one_caller_inline_max_size size =
52
+ meth_call global##.binaryen "setOneCallerInlineMaxSize" [| inject size |]
53
+
54
+ (* Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO *)
55
+ let set_colors_enabled enabled =
56
+ meth_call global##.binaryen "_BinaryenSetColorsEnabled" [| inject enabled |]
57
+
58
+ (* Uses the `_Binaryen` function because then we are working with ints which are also booleans to JSOO *)
59
+ let are_colors_enabled () =
60
+ meth_call global##.binaryen "_BinaryenAreColorsEnabled" [||]
@@ -0,0 +1,29 @@
1
+ open Js_of_ocaml.Js
2
+ open Js_of_ocaml.Js.Unsafe
3
+
4
+ type t = int
5
+
6
+ let add_table wasm_mod name initial maximum =
7
+ meth_call wasm_mod "addTable"
8
+ [| inject (string name); inject initial; inject maximum |]
9
+
10
+ let add_active_element_segment wasm_mod table name funcnames offset =
11
+ meth_call wasm_mod "addActiveElementSegment"
12
+ [|
13
+ inject (string table);
14
+ inject (string name);
15
+ inject (array (Array.of_list (List.map string funcnames)));
16
+ inject offset;
17
+ |]
18
+
19
+ let remove_element_segment wasm_mod name =
20
+ meth_call wasm_mod "removeElementSegment" [| inject (string name) |]
21
+
22
+ let get_num_element_segments wasm_mod =
23
+ meth_call wasm_mod "getNumElementSegments" [||]
24
+
25
+ let get_element_segment wasm_mod name =
26
+ meth_call wasm_mod "getElementSegment" [| inject (string name) |]
27
+
28
+ let get_element_segment_by_index wasm_mod index =
29
+ meth_call wasm_mod "getElementSegmentByIndex" [| inject index |]
@@ -25,3 +25,6 @@ let auto : t = global##.binaryen##.auto
25
25
 
26
26
  let create typs =
27
27
  meth_call global##.binaryen "createType" [| inject (array typs) |]
28
+
29
+ let expand typ =
30
+ to_array (meth_call global##.binaryen "expandType" [| inject typ |])
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@grain/binaryen.ml",
3
+ "version": "0.11.2",
4
+ "description": "OCaml bindings for Binaryen.",
5
+ "author": "Oscar Spencer <oscar@grain-lang.org>",
6
+ "license": "Apache-2.0",
7
+ "dependencies": {
8
+ "ocaml": ">= 4.12.0 < 4.13.0",
9
+ "@grain/libbinaryen": "^101.0.1",
10
+ "@opam/dune": "^2.9.1",
11
+ "@opam/dune-configurator": "^2.9.1",
12
+ "@opam/js_of_ocaml": "^3.10.0",
13
+ "@opam/js_of_ocaml-ppx": "^3.10.0"
14
+ },
15
+ "devDependencies": {
16
+ "@opam/js_of_ocaml-compiler": "^3.10.0",
17
+ "@opam/ocamlformat": "0.18.0",
18
+ "@opam/ocaml-lsp-server": "^1.8.2"
19
+ },
20
+ "esy": {
21
+ "build": "dune build -p binaryen"
22
+ },
23
+ "scripts": {
24
+ "test": "esy b dune runtest",
25
+ "format": "dune build @fmt --auto-promote"
26
+ },
27
+ "installConfig": {
28
+ "pnp": false
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "keywords": [
34
+ "binaryen",
35
+ "ocaml"
36
+ ]
37
+ }
@@ -2,6 +2,7 @@
2
2
  #include <caml/mlvalues.h>
3
3
  #include <caml/fail.h>
4
4
  #include <caml/memory.h>
5
+ #include <caml/alloc.h>
5
6
 
6
7
  #include "binaryen-c.h"
7
8
  #include "ocaml_helpers.h"
@@ -55,6 +56,15 @@ caml_binaryen_add_global_export(value _module, value _internalName, value _exter
55
56
  CAMLreturn(alloc_BinaryenExportRef(exp));
56
57
  }
57
58
 
59
+ CAMLprim value
60
+ caml_binaryen_get_export(value _module, value _externalName) {
61
+ CAMLparam2(_module, _externalName);
62
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
63
+ char* externalName = Safe_String_val(_externalName);
64
+ BinaryenExportRef exp = BinaryenGetExport(module, externalName);
65
+ CAMLreturn(alloc_BinaryenExportRef(exp));
66
+ }
67
+
58
68
  CAMLprim value
59
69
  caml_binaryen_remove_export(value _module, value _externalName) {
60
70
  CAMLparam2(_module, _externalName);
@@ -63,3 +73,71 @@ caml_binaryen_remove_export(value _module, value _externalName) {
63
73
  BinaryenRemoveExport(module, externalName);
64
74
  CAMLreturn(Val_unit);
65
75
  }
76
+
77
+ CAMLprim value
78
+ caml_binaryen_get_num_exports(value _module) {
79
+ CAMLparam1(_module);
80
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
81
+ BinaryenIndex num = BinaryenGetNumExports(module);
82
+ CAMLreturn(Val_int(num));
83
+ }
84
+
85
+ CAMLprim value
86
+ caml_binaryen_get_export_by_index(value _module, value _index) {
87
+ CAMLparam2(_module, _index);
88
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
89
+ BinaryenIndex index = Int_val(_index);
90
+ BinaryenExportRef exp = BinaryenGetExportByIndex(module, index);
91
+ CAMLreturn(alloc_BinaryenExportRef(exp));
92
+ }
93
+
94
+ CAMLprim value
95
+ caml_binaryen_export_get_name(value _exp) {
96
+ CAMLparam1(_exp);
97
+ BinaryenExportRef exp = BinaryenExportRef_val(_exp);
98
+ CAMLreturn(caml_copy_string(BinaryenExportGetName(exp)));
99
+ }
100
+
101
+ CAMLprim value
102
+ caml_binaryen_export_get_value(value _exp) {
103
+ CAMLparam1(_exp);
104
+ BinaryenExportRef exp = BinaryenExportRef_val(_exp);
105
+ CAMLreturn(caml_copy_string(BinaryenExportGetValue(exp)));
106
+ }
107
+
108
+ CAMLprim value
109
+ caml_binaryen_external_function(value _unit) {
110
+ CAMLparam1(_unit);
111
+ CAMLreturn(Val_int(BinaryenExternalFunction()));
112
+ }
113
+
114
+ CAMLprim value
115
+ caml_binaryen_external_table(value _unit) {
116
+ CAMLparam1(_unit);
117
+ CAMLreturn(Val_int(BinaryenExternalTable()));
118
+ }
119
+
120
+ CAMLprim value
121
+ caml_binaryen_external_memory(value _unit) {
122
+ CAMLparam1(_unit);
123
+ CAMLreturn(Val_int(BinaryenExternalMemory()));
124
+ }
125
+
126
+ CAMLprim value
127
+ caml_binaryen_external_global(value _unit) {
128
+ CAMLparam1(_unit);
129
+ CAMLreturn(Val_int(BinaryenExternalGlobal()));
130
+ }
131
+
132
+ CAMLprim value
133
+ caml_binaryen_external_event(value _unit) {
134
+ CAMLparam1(_unit);
135
+ CAMLreturn(Val_int(BinaryenExternalEvent()));
136
+ }
137
+
138
+ CAMLprim value
139
+ caml_binaryen_export_get_kind(value _exp) {
140
+ CAMLparam1(_exp);
141
+ BinaryenExportRef exp = BinaryenExportRef_val(_exp);
142
+ CAMLreturn(Val_int(BinaryenExportGetKind(exp)));
143
+ }