@grain/binaryen.ml 0.14.1 → 0.15.0

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 (66) hide show
  1. binaryen-archive/CHANGELOG.md +26 -0
  2. binaryen-archive/README.md +16 -0
  3. binaryen-archive/binaryen.opam +2 -4
  4. binaryen-archive/dune +1 -1
  5. binaryen-archive/esy.lock/index.json +6 -94
  6. binaryen-archive/package.json +3 -5
  7. binaryen-archive/src/binaryen_stubs_exports.js +110 -0
  8. binaryen-archive/src/binaryen_stubs_expressions.js +1613 -0
  9. binaryen-archive/src/binaryen_stubs_features.js +105 -0
  10. binaryen-archive/src/binaryen_stubs_functions.js +92 -0
  11. binaryen-archive/src/binaryen_stubs_globals.js +62 -0
  12. binaryen-archive/src/binaryen_stubs_imports.js +86 -0
  13. binaryen-archive/src/binaryen_stubs_literals.js +29 -0
  14. binaryen-archive/src/binaryen_stubs_memory.js +25 -0
  15. binaryen-archive/src/binaryen_stubs_modules.js +121 -0
  16. binaryen-archive/src/binaryen_stubs_ops.js +1895 -0
  17. binaryen-archive/src/binaryen_stubs_settings.js +120 -0
  18. binaryen-archive/src/binaryen_stubs_tables.c +2 -0
  19. binaryen-archive/src/binaryen_stubs_tables.js +84 -0
  20. binaryen-archive/src/binaryen_stubs_types.js +73 -0
  21. binaryen-archive/src/dune +11 -4
  22. binaryen-archive/{virtual → src}/element_segment.mli +0 -0
  23. binaryen-archive/{virtual → src}/export.mli +0 -0
  24. binaryen-archive/{virtual → src}/expression.mli +0 -0
  25. binaryen-archive/{virtual → src}/function.mli +0 -0
  26. binaryen-archive/{virtual → src}/global.mli +0 -0
  27. binaryen-archive/{virtual → src}/import.mli +0 -0
  28. binaryen-archive/src/literal.ml +0 -13
  29. binaryen-archive/src/literal.mli +8 -0
  30. binaryen-archive/src/memory.ml +6 -6
  31. binaryen-archive/{virtual → src}/memory.mli +1 -1
  32. binaryen-archive/src/module.ml +1 -1
  33. binaryen-archive/{virtual → src}/module.mli +1 -1
  34. binaryen-archive/{virtual → src}/op.mli +0 -0
  35. binaryen-archive/src/passes.ml +345 -0
  36. binaryen-archive/src/passes.mli +343 -0
  37. binaryen-archive/{virtual → src}/settings.mli +0 -0
  38. binaryen-archive/{virtual → src}/table.mli +0 -0
  39. binaryen-archive/{virtual → src}/type.mli +0 -0
  40. binaryen-archive/test/dune +2 -22
  41. binaryen-archive/test/test.expected +8 -4
  42. binaryen-archive/test/test.ml +33 -10
  43. binaryen-archive/esy.lock/opam/js_of_ocaml-ppx.3.11.0/opam +0 -44
  44. binaryen-archive/esy.lock/opam/js_of_ocaml.3.11.0/opam +0 -45
  45. binaryen-archive/esy.lock/opam/uchar.0.0.2/opam +0 -36
  46. binaryen-archive/esy.lock/overrides/opam__s__uchar_opam__c__0.0.2_opam_override/files/winpatch.patch +0 -11
  47. binaryen-archive/esy.lock/overrides/opam__s__uchar_opam__c__0.0.2_opam_override/package.json +0 -11
  48. binaryen-archive/js/binaryen.es5.js +0 -363
  49. binaryen-archive/js/dune +0 -13
  50. binaryen-archive/js/element_segment.ml +0 -33
  51. binaryen-archive/js/export.ml +0 -57
  52. binaryen-archive/js/expression.ml +0 -1105
  53. binaryen-archive/js/function.ml +0 -60
  54. binaryen-archive/js/global.ml +0 -48
  55. binaryen-archive/js/import.ml +0 -69
  56. binaryen-archive/js/literal.ml +0 -28
  57. binaryen-archive/js/memory.ml +0 -39
  58. binaryen-archive/js/module.ml +0 -116
  59. binaryen-archive/js/op.ml +0 -482
  60. binaryen-archive/js/prelude.js +0 -2
  61. binaryen-archive/js/settings.ml +0 -60
  62. binaryen-archive/js/stubs.c +0 -15
  63. binaryen-archive/js/table.ml +0 -29
  64. binaryen-archive/js/type.ml +0 -21
  65. binaryen-archive/virtual/dune +0 -6
  66. binaryen-archive/virtual/literal.mli +0 -19
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.15.0](https://github.com/grain-lang/binaryen.ml/compare/v0.14.1...v0.15.0) (2022-03-16)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * Rename segment name to data (#146)
9
+ * Add Passes module & require `Passes.t` in `Module.run_passes` (#145)
10
+ * Remove virtual modules
11
+ * Remove the "jsoo hack" API
12
+ * Update libbinaryen to v105 (#142)
13
+
14
+ ### Features
15
+
16
+ * Add Passes module & require `Passes.t` in `Module.run_passes` ([#145](https://github.com/grain-lang/binaryen.ml/issues/145)) ([c3e751c](https://github.com/grain-lang/binaryen.ml/commit/c3e751c4f869b9481e18c85a525100fbdcfa9072))
17
+ * Remove the "jsoo hack" API ([3c81209](https://github.com/grain-lang/binaryen.ml/commit/3c81209763e3d09d51a5ab68ebd705582fe02c54))
18
+ * Remove unneeded js_of_ocaml & js_of_ocaml-ppx deps ([3c81209](https://github.com/grain-lang/binaryen.ml/commit/3c81209763e3d09d51a5ab68ebd705582fe02c54))
19
+ * Remove virtual modules ([3c81209](https://github.com/grain-lang/binaryen.ml/commit/3c81209763e3d09d51a5ab68ebd705582fe02c54))
20
+ * Rename segment name to data ([#146](https://github.com/grain-lang/binaryen.ml/issues/146)) ([d55e577](https://github.com/grain-lang/binaryen.ml/commit/d55e5773d39fd5f21f556e0f5493d6c60bbc2198))
21
+ * Rewrite JS bindings as js_of_ocaml externals ([3c81209](https://github.com/grain-lang/binaryen.ml/commit/3c81209763e3d09d51a5ab68ebd705582fe02c54))
22
+ * Update libbinaryen to v105 ([#142](https://github.com/grain-lang/binaryen.ml/issues/142)) ([3c81209](https://github.com/grain-lang/binaryen.ml/commit/3c81209763e3d09d51a5ab68ebd705582fe02c54))
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * Make memory segments work with js_of_ocaml ([3c81209](https://github.com/grain-lang/binaryen.ml/commit/3c81209763e3d09d51a5ab68ebd705582fe02c54))
28
+
3
29
  ### [0.14.1](https://github.com/grain-lang/binaryen.ml/compare/v0.14.0...v0.14.1) (2022-03-08)
4
30
 
5
31
 
@@ -106,6 +106,22 @@ If you are planning to create portable binaries for Windows, it will try to find
106
106
 
107
107
  These flags might not work on other operating systems (like MacOS), so you'll probably need to use `dune-configurator` to vary the flags per platform.
108
108
 
109
+ ## JavaScript
110
+
111
+ When compiling to JavaScript with `js_of_ocaml`, you'll need to add the `--disable share` flag. This is needed until we can depend on the bug fix from [ocsigen/js_of_ocaml#1249](https://github.com/ocsigen/js_of_ocaml/pull/1249). In the meantime, you can change your dune file:
112
+
113
+ ```diff
114
+ (executable
115
+ (name example)
116
+ (public_name example)
117
+ (modes
118
+ (byte js))
119
+ + (js_of_ocaml
120
+ + (flags --disable share))
121
+ (modules example)
122
+ (libraries binaryen))
123
+ ```
124
+
109
125
  ## Contributing
110
126
 
111
127
  You'll need Node.js and [`esy`](https://esy.sh/docs/en/getting-started.html#install-esy) to build this project.
@@ -1,5 +1,5 @@
1
1
  opam-version: "2.0"
2
- version: "0.14.1"
2
+ version: "0.15.0"
3
3
  synopsis: "OCaml bindings for Binaryen"
4
4
  maintainer: "oscar@grain-lang.org"
5
5
  author: "Oscar Spencer"
@@ -15,8 +15,6 @@ depends: [
15
15
  "ocaml" {>= "4.12"}
16
16
  "dune" {>= "2.9.1" < "3.0.0"}
17
17
  "dune-configurator" {>= "2.9.1" < "3.0.0"}
18
- "js_of_ocaml" {>= "3.10.0" < "4.0.0"}
19
- "js_of_ocaml-ppx" {>= "3.10.0" < "4.0.0"}
20
18
  "js_of_ocaml-compiler" {>= "3.10.0" < "4.0.0"}
21
- "libbinaryen" {>= "104.0.0" < "105.0.0"}
19
+ "libbinaryen" {>= "105.1.0" < "106.0.0"}
22
20
  ]
binaryen-archive/dune CHANGED
@@ -1 +1 @@
1
- (dirs :standard virtual js)
1
+ (dirs :standard)
@@ -1,5 +1,5 @@
1
1
  {
2
- "checksum": "4cdd2a2ff2fda55cbe5e06c8f5171acc",
2
+ "checksum": "3afbecb7a1e1a32cb100ffcb7796a67a",
3
3
  "root": "@grain/binaryen.ml@link-dev:./package.json",
4
4
  "node": {
5
5
  "ocaml@4.13.1000@d41d8cd9": {
@@ -126,34 +126,6 @@
126
126
  ],
127
127
  "devDependencies": [ "ocaml@4.13.1000@d41d8cd9" ]
128
128
  },
129
- "@opam/uchar@opam:0.0.2@aedf91f9": {
130
- "id": "@opam/uchar@opam:0.0.2@aedf91f9",
131
- "name": "@opam/uchar",
132
- "version": "opam:0.0.2",
133
- "source": {
134
- "type": "install",
135
- "source": [
136
- "archive:https://opam.ocaml.org/cache/md5/c9/c9ba2c738d264c420c642f7bb1cf4a36#md5:c9ba2c738d264c420c642f7bb1cf4a36",
137
- "archive:https://github.com/ocaml/uchar/releases/download/v0.0.2/uchar-0.0.2.tbz#md5:c9ba2c738d264c420c642f7bb1cf4a36"
138
- ],
139
- "opam": {
140
- "name": "uchar",
141
- "version": "0.0.2",
142
- "path": "esy.lock/opam/uchar.0.0.2"
143
- }
144
- },
145
- "overrides": [
146
- {
147
- "opamoverride":
148
- "esy.lock/overrides/opam__s__uchar_opam__c__0.0.2_opam_override"
149
- }
150
- ],
151
- "dependencies": [
152
- "ocaml@4.13.1000@d41d8cd9", "@opam/ocamlbuild@opam:0.14.1@ead10f40",
153
- "@esy-ocaml/substs@0.0.1@d41d8cd9"
154
- ],
155
- "devDependencies": [ "ocaml@4.13.1000@d41d8cd9" ]
156
- },
157
129
  "@opam/topkg@opam:1.0.5@0aa59f51": {
158
130
  "id": "@opam/topkg@opam:1.0.5@0aa59f51",
159
131
  "name": "@opam/topkg",
@@ -822,34 +794,6 @@
822
794
  "@opam/dune@opam:2.9.3@f57a6d69"
823
795
  ]
824
796
  },
825
- "@opam/js_of_ocaml-ppx@opam:3.11.0@4edaf441": {
826
- "id": "@opam/js_of_ocaml-ppx@opam:3.11.0@4edaf441",
827
- "name": "@opam/js_of_ocaml-ppx",
828
- "version": "opam:3.11.0",
829
- "source": {
830
- "type": "install",
831
- "source": [
832
- "archive:https://opam.ocaml.org/cache/sha256/15/158dafe7271ac79157981d1c3f5f177ec78a0099c38f861ae14e7ac06bd29c3a#sha256:158dafe7271ac79157981d1c3f5f177ec78a0099c38f861ae14e7ac06bd29c3a",
833
- "archive:https://github.com/ocsigen/js_of_ocaml/releases/download/3.11.0/js_of_ocaml-3.11.0.tbz#sha256:158dafe7271ac79157981d1c3f5f177ec78a0099c38f861ae14e7ac06bd29c3a"
834
- ],
835
- "opam": {
836
- "name": "js_of_ocaml-ppx",
837
- "version": "3.11.0",
838
- "path": "esy.lock/opam/js_of_ocaml-ppx.3.11.0"
839
- }
840
- },
841
- "overrides": [],
842
- "dependencies": [
843
- "ocaml@4.13.1000@d41d8cd9", "@opam/ppxlib@opam:0.25.0@8553d2e8",
844
- "@opam/js_of_ocaml@opam:3.11.0@93e18d4d",
845
- "@opam/dune@opam:2.9.3@f57a6d69", "@esy-ocaml/substs@0.0.1@d41d8cd9"
846
- ],
847
- "devDependencies": [
848
- "ocaml@4.13.1000@d41d8cd9", "@opam/ppxlib@opam:0.25.0@8553d2e8",
849
- "@opam/js_of_ocaml@opam:3.11.0@93e18d4d",
850
- "@opam/dune@opam:2.9.3@f57a6d69"
851
- ]
852
- },
853
797
  "@opam/js_of_ocaml-compiler@opam:3.11.0@6004d7b8": {
854
798
  "id": "@opam/js_of_ocaml-compiler@opam:3.11.0@6004d7b8",
855
799
  "name": "@opam/js_of_ocaml-compiler",
@@ -888,36 +832,6 @@
888
832
  "@opam/cmdliner@opam:1.1.0@643a0e00"
889
833
  ]
890
834
  },
891
- "@opam/js_of_ocaml@opam:3.11.0@93e18d4d": {
892
- "id": "@opam/js_of_ocaml@opam:3.11.0@93e18d4d",
893
- "name": "@opam/js_of_ocaml",
894
- "version": "opam:3.11.0",
895
- "source": {
896
- "type": "install",
897
- "source": [
898
- "archive:https://opam.ocaml.org/cache/sha256/15/158dafe7271ac79157981d1c3f5f177ec78a0099c38f861ae14e7ac06bd29c3a#sha256:158dafe7271ac79157981d1c3f5f177ec78a0099c38f861ae14e7ac06bd29c3a",
899
- "archive:https://github.com/ocsigen/js_of_ocaml/releases/download/3.11.0/js_of_ocaml-3.11.0.tbz#sha256:158dafe7271ac79157981d1c3f5f177ec78a0099c38f861ae14e7ac06bd29c3a"
900
- ],
901
- "opam": {
902
- "name": "js_of_ocaml",
903
- "version": "3.11.0",
904
- "path": "esy.lock/opam/js_of_ocaml.3.11.0"
905
- }
906
- },
907
- "overrides": [],
908
- "dependencies": [
909
- "ocaml@4.13.1000@d41d8cd9", "@opam/uchar@opam:0.0.2@aedf91f9",
910
- "@opam/ppxlib@opam:0.25.0@8553d2e8",
911
- "@opam/js_of_ocaml-compiler@opam:3.11.0@6004d7b8",
912
- "@opam/dune@opam:2.9.3@f57a6d69", "@esy-ocaml/substs@0.0.1@d41d8cd9"
913
- ],
914
- "devDependencies": [
915
- "ocaml@4.13.1000@d41d8cd9", "@opam/uchar@opam:0.0.2@aedf91f9",
916
- "@opam/ppxlib@opam:0.25.0@8553d2e8",
917
- "@opam/js_of_ocaml-compiler@opam:3.11.0@6004d7b8",
918
- "@opam/dune@opam:2.9.3@f57a6d69"
919
- ]
920
- },
921
835
  "@opam/fpath@opam:0.7.3@674d8125": {
922
836
  "id": "@opam/fpath@opam:0.7.3@674d8125",
923
837
  "name": "@opam/fpath",
@@ -1319,14 +1233,14 @@
1319
1233
  ],
1320
1234
  "devDependencies": [ "ocaml@4.13.1000@d41d8cd9" ]
1321
1235
  },
1322
- "@grain/libbinaryen@104.0.0@d41d8cd9": {
1323
- "id": "@grain/libbinaryen@104.0.0@d41d8cd9",
1236
+ "@grain/libbinaryen@105.1.0@d41d8cd9": {
1237
+ "id": "@grain/libbinaryen@105.1.0@d41d8cd9",
1324
1238
  "name": "@grain/libbinaryen",
1325
- "version": "104.0.0",
1239
+ "version": "105.1.0",
1326
1240
  "source": {
1327
1241
  "type": "install",
1328
1242
  "source": [
1329
- "archive:https://registry.npmjs.org/@grain/libbinaryen/-/libbinaryen-104.0.0.tgz#sha1:822bade4f4c6dc9cedbb642e9ead6456be4503bb"
1243
+ "archive:https://registry.npmjs.org/@grain/libbinaryen/-/libbinaryen-105.1.0.tgz#sha1:ed69f20fbe6dee06eb3fd02c2ffb2e2df7c36115"
1330
1244
  ]
1331
1245
  },
1332
1246
  "overrides": [],
@@ -1351,11 +1265,9 @@
1351
1265
  "overrides": [],
1352
1266
  "dependencies": [
1353
1267
  "ocaml@4.13.1000@d41d8cd9",
1354
- "@opam/js_of_ocaml-ppx@opam:3.11.0@4edaf441",
1355
- "@opam/js_of_ocaml@opam:3.11.0@93e18d4d",
1356
1268
  "@opam/dune-configurator@opam:2.9.3@174e411b",
1357
1269
  "@opam/dune@opam:2.9.3@f57a6d69",
1358
- "@grain/libbinaryen@104.0.0@d41d8cd9"
1270
+ "@grain/libbinaryen@105.1.0@d41d8cd9"
1359
1271
  ],
1360
1272
  "devDependencies": [
1361
1273
  "@opam/ocamlformat@opam:0.20.1@30a05b69",
@@ -1,16 +1,14 @@
1
1
  {
2
2
  "name": "@grain/binaryen.ml",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "description": "OCaml bindings for Binaryen.",
5
5
  "author": "Oscar Spencer <oscar@grain-lang.org>",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
8
8
  "ocaml": ">= 4.12.0",
9
- "@grain/libbinaryen": ">= 104.0.0 < 105.0.0",
9
+ "@grain/libbinaryen": ">= 105.1.0 < 106.0.0",
10
10
  "@opam/dune": ">= 2.9.1 < 3.0.0",
11
- "@opam/dune-configurator": ">= 2.9.1 < 3.0.0",
12
- "@opam/js_of_ocaml": ">= 3.10.0 < 4.0.0",
13
- "@opam/js_of_ocaml-ppx": ">= 3.10.0 < 4.0.0"
11
+ "@opam/dune-configurator": ">= 2.9.1 < 3.0.0"
14
12
  },
15
13
  "devDependencies": {
16
14
  "@opam/js_of_ocaml-compiler": ">= 3.10.0 < 4.0.0",
@@ -0,0 +1,110 @@
1
+ //Provides: caml_binaryen_add_function_export
2
+ //Requires: caml_jsstring_of_string
3
+ function caml_binaryen_add_function_export(wasm_mod, internal_name, external_name) {
4
+ return wasm_mod.addFunctionExport(
5
+ caml_jsstring_of_string(internal_name),
6
+ caml_jsstring_of_string(external_name)
7
+ );
8
+ }
9
+
10
+ //Provides: caml_binaryen_add_table_export
11
+ //Requires: caml_jsstring_of_string
12
+ function caml_binaryen_add_table_export(wasm_mod, internal_name, external_name) {
13
+ return wasm_mod.addTableExport(
14
+ caml_jsstring_of_string(internal_name),
15
+ caml_jsstring_of_string(external_name)
16
+ );
17
+ }
18
+
19
+ //Provides: caml_binaryen_add_memory_export
20
+ //Requires: caml_jsstring_of_string
21
+ function caml_binaryen_add_memory_export(wasm_mod, internal_name, external_name) {
22
+ return wasm_mod.addMemoryExport(
23
+ caml_jsstring_of_string(internal_name),
24
+ caml_jsstring_of_string(external_name)
25
+ );
26
+ }
27
+
28
+ //Provides: caml_binaryen_add_global_export
29
+ //Requires: caml_jsstring_of_string
30
+ function caml_binaryen_add_global_export(wasm_mod, internal_name, external_name) {
31
+ return wasm_mod.addGlobalExport(
32
+ caml_jsstring_of_string(internal_name),
33
+ caml_jsstring_of_string(external_name)
34
+ );
35
+ }
36
+
37
+ //Provides: caml_binaryen_get_export
38
+ //Requires: caml_jsstring_of_string
39
+ function caml_binaryen_get_export(wasm_mod, external_name) {
40
+ return wasm_mod.getExport(caml_jsstring_of_string(external_name));
41
+ }
42
+
43
+ //Provides: caml_binaryen_remove_export
44
+ //Requires: caml_jsstring_of_string
45
+ function caml_binaryen_remove_export(wasm_mod, external_name) {
46
+ return wasm_mod.removeExport(caml_jsstring_of_string(external_name));
47
+ }
48
+
49
+ //Provides: caml_binaryen_get_num_exports
50
+ function caml_binaryen_get_num_exports(wasm_mod) {
51
+ return wasm_mod.getNumExports();
52
+ }
53
+
54
+ //Provides: caml_binaryen_get_export_by_index
55
+ function caml_binaryen_get_export_by_index(wasm_mod, index) {
56
+ return wasm_mod.getExportByIndex(index);
57
+ }
58
+
59
+ //Provides: caml_binaryen_export_get_name
60
+ //Requires: binaryen
61
+ //Requires: caml_string_of_jsstring
62
+ function caml_binaryen_export_get_name(exp) {
63
+ var export_info = binaryen.getExportInfo(exp);
64
+ return caml_string_of_jsstring(export_info.name);
65
+ }
66
+
67
+ //Provides: caml_binaryen_export_get_value
68
+ //Requires: binaryen
69
+ //Requires: caml_string_of_jsstring
70
+ function caml_binaryen_export_get_value(exp) {
71
+ var export_info = binaryen.getExportInfo(exp);
72
+ return caml_string_of_jsstring(export_info.value);
73
+ }
74
+
75
+ //Provides: caml_binaryen_external_function
76
+ //Requires: binaryen
77
+ function caml_binaryen_external_function() {
78
+ return binaryen._BinaryenExternalFunction();
79
+ }
80
+
81
+ //Provides: caml_binaryen_external_table
82
+ //Requires: binaryen
83
+ function caml_binaryen_external_table() {
84
+ return binaryen._BinaryenExternalTable();
85
+ }
86
+
87
+ //Provides: caml_binaryen_external_memory
88
+ //Requires: binaryen
89
+ function caml_binaryen_external_memory() {
90
+ return binaryen._BinaryenExternalMemory();
91
+ }
92
+
93
+ //Provides: caml_binaryen_external_global
94
+ //Requires: binaryen
95
+ function caml_binaryen_external_global() {
96
+ return binaryen._BinaryenExternalGlobal();
97
+ }
98
+
99
+ //Provides: caml_binaryen_external_tag
100
+ //Requires: binaryen
101
+ function caml_binaryen_external_tag() {
102
+ return binaryen._BinaryenExternalTag();
103
+ }
104
+
105
+ //Provides: caml_binaryen_export_get_kind
106
+ //Requires: binaryen
107
+ function caml_binaryen_export_get_kind(exp) {
108
+ var export_info = binaryen.getExportInfo(exp);
109
+ return export_info.kind;
110
+ }