@grain/binaryen.ml 0.35.0 → 0.36.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 +20 -0
  2. binaryen-archive/binaryen.opam +3 -3
  3. binaryen-archive/esy.lock/index.json +338 -462
  4. binaryen-archive/esy.lock/opam/base.v0.17.3/opam +1 -1
  5. binaryen-archive/esy.lock/opam/{chrome-trace.3.21.1 → chrome-trace.3.24.1}/opam +6 -8
  6. binaryen-archive/esy.lock/opam/{cmdliner.1.3.0 → cmdliner.2.1.1}/opam +26 -10
  7. binaryen-archive/esy.lock/opam/{dune-build-info.3.21.1 → dune-build-info.3.24.2}/opam +6 -8
  8. binaryen-archive/esy.lock/opam/{dune-configurator.3.21.1 → dune-configurator.3.24.2}/opam +6 -8
  9. binaryen-archive/esy.lock/opam/{dune-rpc.3.21.1 → dune-rpc.3.20.2}/opam +5 -5
  10. binaryen-archive/esy.lock/opam/{dune.3.21.1 → dune.3.24.2}/opam +13 -9
  11. binaryen-archive/esy.lock/opam/{dyn.3.21.1 → dyn.3.20.2}/opam +6 -6
  12. binaryen-archive/esy.lock/opam/fix.20250919/opam +1 -0
  13. binaryen-archive/esy.lock/opam/js_of_ocaml-compiler.6.4.1/opam +67 -0
  14. binaryen-archive/esy.lock/opam/ocaml-lsp-server.1.23.1/opam +2 -2
  15. binaryen-archive/esy.lock/opam/{ocaml-version.4.0.3 → ocaml-version.4.1.3}/opam +3 -3
  16. binaryen-archive/esy.lock/opam/{ocaml_intrinsics_kernel.v0.17.1 → ocaml_intrinsics_kernel.v0.17.2}/opam +3 -5
  17. binaryen-archive/esy.lock/opam/ocamlbuild.0.16.1/opam +1 -0
  18. binaryen-archive/esy.lock/opam/{ocamlc-loc.3.21.1 → ocamlc-loc.3.20.2}/opam +6 -6
  19. binaryen-archive/esy.lock/opam/ocamlfind.1.9.8/opam +2 -1
  20. binaryen-archive/esy.lock/opam/{ocamlformat-lib.0.27.0 → ocamlformat-lib.0.29.0}/opam +7 -6
  21. binaryen-archive/esy.lock/opam/{ocamlformat-rpc-lib.0.28.1 → ocamlformat-rpc-lib.0.29.0}/opam +4 -4
  22. binaryen-archive/esy.lock/opam/{ocamlformat.0.27.0 → ocamlformat.0.29.0}/opam +6 -5
  23. binaryen-archive/esy.lock/opam/{ocp-indent.1.7.0 → ocp-indent.1.9.0}/opam +10 -9
  24. binaryen-archive/esy.lock/opam/{ordering.3.21.1 → ordering.3.20.2}/opam +6 -6
  25. binaryen-archive/esy.lock/opam/{ppxlib.0.37.0 → ppxlib.0.39.0~5.6preview}/opam +12 -13
  26. binaryen-archive/esy.lock/opam/{stdune.3.21.1 → stdune.3.20.2}/opam +7 -9
  27. binaryen-archive/esy.lock/opam/{xdg.3.21.1 → xdg.3.24.2}/opam +6 -8
  28. binaryen-archive/package.json +9 -5
  29. binaryen-archive/src/dune +4 -1
  30. binaryen-archive/src/expression.c +345 -0
  31. binaryen-archive/src/expression.js +241 -7
  32. binaryen-archive/src/expression.ml +106 -0
  33. binaryen-archive/src/expression.mli +72 -0
  34. binaryen-archive/src/heap_type.c +19 -0
  35. binaryen-archive/src/heap_type.js +12 -0
  36. binaryen-archive/src/heap_type.ml +10 -1
  37. binaryen-archive/src/heap_type.mli +8 -1
  38. binaryen-archive/src/memory.c +6 -1
  39. binaryen-archive/src/memory.js +2 -2
  40. binaryen-archive/src/memory.ml +1 -1
  41. binaryen-archive/src/memory.mli +1 -1
  42. binaryen-archive/src/module.js +7 -20
  43. binaryen-archive/src/module.ml +4 -0
  44. binaryen-archive/src/module.mli +1 -0
  45. binaryen-archive/src/module_feature.c +6 -0
  46. binaryen-archive/src/module_feature.js +6 -0
  47. binaryen-archive/src/ocaml_helpers.c +9 -0
  48. binaryen-archive/src/ocaml_helpers.h +5 -0
  49. binaryen-archive/src/ocaml_helpers.js +11 -0
  50. binaryen-archive/src/passes.ml +10 -4
  51. binaryen-archive/src/passes.mli +11 -5
  52. binaryen-archive/src/type.c +5 -3
  53. binaryen-archive/src/type.js +2 -3
  54. binaryen-archive/src/type.ml +4 -1
  55. binaryen-archive/src/type.mli +1 -1
  56. binaryen-archive/src/type_builder.c +180 -0
  57. binaryen-archive/src/type_builder.js +116 -0
  58. binaryen-archive/src/type_builder.ml +67 -0
  59. binaryen-archive/src/type_builder.mli +28 -0
  60. binaryen-archive/test/test.expected +188 -25
  61. binaryen-archive/test/test.ml +131 -4
  62. binaryen-archive/esy.lock/opam/base-bytes.base/opam +0 -10
  63. binaryen-archive/esy.lock/opam/fs-io.3.21.1/opam +0 -41
  64. binaryen-archive/esy.lock/opam/js_of_ocaml-compiler.6.2.0/opam +0 -56
  65. binaryen-archive/esy.lock/opam/stdlib-shims.0.3.0/opam +0 -31
  66. binaryen-archive/esy.lock/opam/top-closure.3.21.1/opam +0 -40
@@ -20,16 +20,14 @@ doc: "https://ocaml-ppx.github.io/ppxlib/"
20
20
  bug-reports: "https://github.com/ocaml-ppx/ppxlib/issues"
21
21
  depends: [
22
22
  "dune" {>= "3.8"}
23
- "ocaml" {>= "4.08.0" & < "5.5.0"}
23
+ "ocaml" {>= "4.08.0" & < "5.7.0"}
24
24
  "ocaml-compiler-libs" {>= "v0.11.0"}
25
25
  "ppx_derivers" {>= "1.0"}
26
- "sexplib0" {>= "v0.12"}
27
- "sexplib0" {with-test & >= "v0.15"}
28
- "stdlib-shims"
26
+ "sexplib0" {>= "v0.15"}
29
27
  "ocamlfind" {with-test}
30
28
  "re" {with-test & >= "1.9.0"}
31
29
  "cinaps" {with-test & >= "v0.12.1"}
32
- "ocamlformat" {with-dev-setup & = "0.26.2"}
30
+ "ocamlformat" {with-dev-setup & = "0.28.1"}
33
31
  "odoc" {with-doc}
34
32
  ]
35
33
  conflicts: [
@@ -53,12 +51,13 @@ build: [
53
51
  ]
54
52
  dev-repo: "git+https://github.com/ocaml-ppx/ppxlib.git"
55
53
  x-maintenance-intent: ["(latest)"]
54
+ flags: avoid-version
55
+ available: opam-version >= "2.1.0"
56
56
  url {
57
- src:
58
- "https://github.com/ocaml-ppx/ppxlib/releases/download/0.37.0/ppxlib-0.37.0.tbz"
59
- checksum: [
60
- "sha256=2e223837e7cecc3bc84a432432c0a72f4e1d5be9165c9c33772f156db85db0b3"
61
- "sha512=78c62c6de7a641b950de9b4b744841c8823918c545046693e291077adfcd069a812094c11d8d51f792c0b5f340307d38f452ff0a92520df63ed17a3ca9922e2e"
62
- ]
63
- }
64
- x-commit-hash: "df39675d8ff0c3490ece8157c681691cfb67fdaf"
57
+ src: "https://github.com/ocaml-ppx/ppxlib/archive/2e150834476230e99e48dfdf34c5e4a1ea6e749b.tar.gz"
58
+ checksum: [
59
+ "sha256=591d694609fed01783c9f360602e8660ae0e49eb33b7074c1317a261e00c6cdb"
60
+ "sha512=e15e956a114ab3f61dfa8f7eceed088082a116f3b6fc832b901729f611258af3b39bda748b2046b4886f429617aa64802f90e0520db82302443ecbba461970b2"
61
+ ]
62
+ }
63
+
@@ -9,19 +9,17 @@ homepage: "https://github.com/ocaml/dune"
9
9
  doc: "https://dune.readthedocs.io/"
10
10
  bug-reports: "https://github.com/ocaml/dune/issues"
11
11
  depends: [
12
- "dune" {>= "3.21"}
12
+ "dune" {>= "3.20"}
13
13
  "ocaml" {>= "4.08.0"}
14
14
  "base-unix"
15
- "csexp" {>= "1.5.0"}
16
15
  "dyn" {= version}
17
- "fs-io" {= version}
18
16
  "ordering" {= version}
19
17
  "pp" {>= "2.0.0"}
20
- "top-closure" {= version}
18
+ "csexp" {>= "1.5.0"}
21
19
  "odoc" {with-doc}
22
20
  ]
23
21
  dev-repo: "git+https://github.com/ocaml/dune.git"
24
- x-maintenance-intent: ["none"]
22
+ x-maintenance-intent: ["(latest)"]
25
23
  build: [
26
24
  ["dune" "subst"] {dev}
27
25
  ["rm" "-rf" "vendor/csexp"]
@@ -39,10 +37,10 @@ build: [
39
37
  ]
40
38
  url {
41
39
  src:
42
- "https://github.com/ocaml/dune/releases/download/3.21.1/dune-3.21.1.tbz"
40
+ "https://github.com/ocaml/dune/releases/download/3.20.2/dune-3.20.2.tbz"
43
41
  checksum: [
44
- "sha256=84f7a82c6d80a7124f3847e9a489e80cfbeafb7bed3573ac01286ef56fd08d94"
45
- "sha512=d9fa44e24036d2593adfe59e52e0ad64f3e7e973d23f84af57fc79e38fa210630b0cb55590f314d6ef455333b96a8e0ce188c2720eaae44576222541ba78efb3"
42
+ "sha256=b1a86b2d60bdb4a8b9bb6861bdf2f9f28a6e7cb5d833ce81afecceb9ef9ca549"
43
+ "sha512=ed14df9163e487d4ae7d0a2427eaab7823ef1f0ef2d93f0b783e6f163bbd5b44ba73f055d60b84e76f476fe11d38e794013628a1da776d9ec13cca9666e7b7ff"
46
44
  ]
47
45
  }
48
- x-commit-hash: "0b5863d9be475453b3cc2bd321fde222af2544d4"
46
+ x-commit-hash: "1e54fd3f450aae7fb41ffb6b7c8b7a5aed754777"
@@ -9,16 +9,14 @@ homepage: "https://github.com/ocaml/dune"
9
9
  doc: "https://dune.readthedocs.io/"
10
10
  bug-reports: "https://github.com/ocaml/dune/issues"
11
11
  depends: [
12
- "dune" {>= "3.21"}
13
- "ocaml" {>= "4.08"}
12
+ "dune" {>= "3.24"}
13
+ "ocaml" {>= "4.14"}
14
14
  "odoc" {with-doc}
15
15
  ]
16
16
  dev-repo: "git+https://github.com/ocaml/dune.git"
17
17
  x-maintenance-intent: ["(latest)"]
18
18
  build: [
19
19
  ["dune" "subst"] {dev}
20
- ["rm" "-rf" "vendor/csexp"]
21
- ["rm" "-rf" "vendor/pp"]
22
20
  [
23
21
  "dune"
24
22
  "build"
@@ -32,10 +30,10 @@ build: [
32
30
  ]
33
31
  url {
34
32
  src:
35
- "https://github.com/ocaml/dune/releases/download/3.21.1/dune-3.21.1.tbz"
33
+ "https://github.com/ocaml/dune/releases/download/3.24.2/dune-3.24.2.tbz"
36
34
  checksum: [
37
- "sha256=84f7a82c6d80a7124f3847e9a489e80cfbeafb7bed3573ac01286ef56fd08d94"
38
- "sha512=d9fa44e24036d2593adfe59e52e0ad64f3e7e973d23f84af57fc79e38fa210630b0cb55590f314d6ef455333b96a8e0ce188c2720eaae44576222541ba78efb3"
35
+ "sha256=472798691b0216daf538709f0f4703b3617ef24ad0866c9096068baaba4d762a"
36
+ "sha512=13082a66a28e940d4b3c9f78b556f6c1455987cd522355ba4502e01e60a3d002d3101b51284726ae21aa87494efa2dc54d016173f05b616bbc5dad714d5714a3"
39
37
  ]
40
38
  }
41
- x-commit-hash: "0b5863d9be475453b3cc2bd321fde222af2544d4"
39
+ x-commit-hash: "ce734ac25ffb06994a4530426bb06ee8cda19e50"
@@ -1,22 +1,26 @@
1
1
  {
2
2
  "name": "@grain/binaryen.ml",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "description": "OCaml bindings for Binaryen.",
5
5
  "author": "Oscar Spencer <oscar@grain-lang.org>",
6
6
  "license": "Apache-2.0",
7
+ "installConfig": {
8
+ "pnp": false
9
+ },
7
10
  "dependencies": {
8
11
  "ocaml": ">= 4.13.0 < 5.4.0",
9
- "@grain/libbinaryen": ">= 125.0.0 < 126.0.0",
12
+ "@grain/libbinaryen": ">= 126.0.0 < 127.0.0",
10
13
  "@opam/dune": ">= 3.0.0",
11
14
  "@opam/dune-configurator": ">= 3.0.0"
12
15
  },
13
16
  "devDependencies": {
14
- "@opam/js_of_ocaml-compiler": ">= 6.0.0 < 7.0.0",
15
- "@opam/ocamlformat": "0.27.0",
17
+ "@opam/js_of_ocaml-compiler": ">= 6.4.0 < 7.0.0",
18
+ "@opam/ocamlformat": "0.29.0",
16
19
  "@opam/ocaml-lsp-server": ">= 1.9.1 < 2.0.0"
17
20
  },
18
21
  "resolutions": {
19
- "@opam/ocp-indent": "1.7.0"
22
+ "@opam/ocp-indent": "1.9.0",
23
+ "@opam/ocamlfind": "1.9.8"
20
24
  },
21
25
  "esy": {
22
26
  "build": "dune build -p binaryen"
binaryen-archive/src/dune CHANGED
@@ -24,6 +24,7 @@
24
24
  heap_type
25
25
  signature_type
26
26
  struct_type
27
+ type_builder
27
28
  ocaml_helpers)
28
29
  (flags :standard -O2 -Wall -Wextra))
29
30
  (js_of_ocaml
@@ -46,4 +47,6 @@
46
47
  packed_type.js
47
48
  heap_type.js
48
49
  signature_type.js
49
- struct_type.js)))
50
+ type_builder.js
51
+ struct_type.js
52
+ ocaml_helpers.js)))
@@ -124,6 +124,38 @@ caml_binaryen_call_indirect__bytecode(value * argv) {
124
124
  return caml_binaryen_call_indirect(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
125
125
  }
126
126
 
127
+ CAMLprim value
128
+ caml_binaryen_call_ref(value _module, value _target, value _params, value _ty) {
129
+ CAMLparam4(_module, _target, _params, _ty);
130
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
131
+ BinaryenExpressionRef target = BinaryenExpressionRef_val(_target);
132
+ _params = array_of_list(_params);
133
+ int paramsLen = array_length(_params);
134
+ BinaryenExpressionRef params[paramsLen];
135
+ for (int i = 0; i < paramsLen; i++) {
136
+ params[i] = BinaryenExpressionRef_val(Field(_params, i));
137
+ }
138
+ BinaryenType ty = BinaryenType_val(_ty);
139
+ BinaryenExpressionRef exp = BinaryenCallRef(module, target, params, paramsLen, ty);
140
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
141
+ }
142
+
143
+ CAMLprim value
144
+ caml_binaryen_return_call_ref(value _module, value _target, value _params, value _ty) {
145
+ CAMLparam4(_module, _target, _params, _ty);
146
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
147
+ BinaryenExpressionRef target = BinaryenExpressionRef_val(_target);
148
+ _params = array_of_list(_params);
149
+ int paramsLen = array_length(_params);
150
+ BinaryenExpressionRef params[paramsLen];
151
+ for (int i = 0; i < paramsLen; i++) {
152
+ params[i] = BinaryenExpressionRef_val(Field(_params, i));
153
+ }
154
+ BinaryenType ty = BinaryenType_val(_ty);
155
+ BinaryenExpressionRef exp = BinaryenReturnCallRef(module, target, params, paramsLen, ty);
156
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
157
+ }
158
+
127
159
  CAMLprim value
128
160
  caml_binaryen_return_call(value _module, value _name, value _params, value _retty) {
129
161
  CAMLparam4(_module, _name, _params, _retty);
@@ -459,6 +491,38 @@ caml_binaryen_i31_get(value _module, value _val, value _signed) {
459
491
  CAMLreturn(alloc_BinaryenExpressionRef(exp));
460
492
  }
461
493
 
494
+ CAMLprim value
495
+ caml_binaryen_ref_test(value _module, value _ref, value _castType) {
496
+ CAMLparam3(_module, _ref, _castType);
497
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
498
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
499
+ BinaryenType castType = BinaryenType_val(_castType);
500
+ BinaryenExpressionRef exp = BinaryenRefTest(module, ref, castType);
501
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
502
+ }
503
+
504
+ CAMLprim value
505
+ caml_binaryen_ref_cast(value _module, value _ref, value _castType) {
506
+ CAMLparam3(_module, _ref, _castType);
507
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
508
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
509
+ BinaryenType castType = BinaryenType_val(_castType);
510
+ BinaryenExpressionRef exp = BinaryenRefCast(module, ref, castType);
511
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
512
+ }
513
+
514
+ CAMLprim value
515
+ caml_binaryen_br_on(value _module, value _op, value _name, value _ref, value _castType) {
516
+ CAMLparam5(_module, _op, _name, _ref, _castType);
517
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
518
+ BinaryenOp op = BinaryenOp_val(_op);
519
+ char* name = Safe_String_val(_name);
520
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
521
+ BinaryenType castType = BinaryenType_val(_castType);
522
+ BinaryenExpressionRef exp = BinaryenBrOn(module, op, name, ref, castType);
523
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
524
+ }
525
+
462
526
  CAMLprim value
463
527
  caml_binaryen_expression_id_invalid(value unit) {
464
528
  CAMLparam1(unit);
@@ -1328,6 +1392,90 @@ caml_binaryen_call_indirect_set_return(value _exp, value _isReturn) {
1328
1392
  CAMLreturn(Val_unit);
1329
1393
  }
1330
1394
 
1395
+ CAMLprim value
1396
+ caml_binaryen_call_ref_get_target(value _exp) {
1397
+ CAMLparam1(_exp);
1398
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1399
+ BinaryenExpressionRef target = BinaryenCallRefGetTarget(exp);
1400
+ CAMLreturn(alloc_BinaryenExpressionRef(target));
1401
+ }
1402
+
1403
+ CAMLprim value
1404
+ caml_binaryen_call_ref_set_target(value _exp, value _target) {
1405
+ CAMLparam2(_exp, _target);
1406
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1407
+ BinaryenExpressionRef target = BinaryenExpressionRef_val(_target);
1408
+ BinaryenCallRefSetTarget(exp, target);
1409
+ CAMLreturn(Val_unit);
1410
+ }
1411
+
1412
+ CAMLprim value
1413
+ caml_binaryen_call_ref_get_num_operands(value _exp) {
1414
+ CAMLparam1(_exp);
1415
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1416
+ CAMLreturn(Val_int(BinaryenCallRefGetNumOperands(exp)));
1417
+ }
1418
+
1419
+ CAMLprim value
1420
+ caml_binaryen_call_ref_get_operand_at(value _exp, value _index) {
1421
+ CAMLparam2(_exp, _index);
1422
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1423
+ BinaryenIndex index = Int_val(_index);
1424
+ CAMLreturn(alloc_BinaryenExpressionRef(BinaryenCallRefGetOperandAt(exp, index)));
1425
+ }
1426
+
1427
+ CAMLprim value
1428
+ caml_binaryen_call_ref_set_operand_at(value _exp, value _index, value _operand) {
1429
+ CAMLparam3(_exp, _index, _operand);
1430
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1431
+ BinaryenIndex index = Int_val(_index);
1432
+ BinaryenExpressionRef operand = BinaryenExpressionRef_val(_operand);
1433
+ BinaryenCallRefSetOperandAt(exp, index, operand);
1434
+ CAMLreturn(Val_unit);
1435
+ }
1436
+
1437
+ CAMLprim value
1438
+ caml_binaryen_call_ref_append_operand(value _exp, value _operand) {
1439
+ CAMLparam2(_exp, _operand);
1440
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1441
+ BinaryenExpressionRef operand = BinaryenExpressionRef_val(_operand);
1442
+ CAMLreturn(Val_int(BinaryenCallRefAppendOperand(exp, operand)));
1443
+ }
1444
+
1445
+ CAMLprim value
1446
+ caml_binaryen_call_ref_insert_operand_at(value _exp, value _index, value _operand) {
1447
+ CAMLparam3(_exp, _index, _operand);
1448
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1449
+ BinaryenIndex index = Int_val(_index);
1450
+ BinaryenExpressionRef operand = BinaryenExpressionRef_val(_operand);
1451
+ BinaryenCallRefInsertOperandAt(exp, index, operand);
1452
+ CAMLreturn(Val_unit);
1453
+ }
1454
+
1455
+ CAMLprim value
1456
+ caml_binaryen_call_ref_remove_operand_at(value _exp, value _index) {
1457
+ CAMLparam2(_exp, _index);
1458
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1459
+ BinaryenIndex index = Int_val(_index);
1460
+ CAMLreturn(alloc_BinaryenExpressionRef(BinaryenCallRefRemoveOperandAt(exp, index)));
1461
+ }
1462
+
1463
+ CAMLprim value
1464
+ caml_binaryen_call_ref_is_return(value _exp) {
1465
+ CAMLparam1(_exp);
1466
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1467
+ CAMLreturn(Val_bool(BinaryenCallRefIsReturn(exp)));
1468
+ }
1469
+
1470
+ CAMLprim value
1471
+ caml_binaryen_call_ref_set_return(value _exp, value _isReturn) {
1472
+ CAMLparam2(_exp, _isReturn);
1473
+ BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
1474
+ int isReturn = Bool_val(_isReturn);
1475
+ BinaryenCallRefSetReturn(exp, isReturn);
1476
+ CAMLreturn(Val_unit);
1477
+ }
1478
+
1331
1479
  CAMLprim value
1332
1480
  caml_binaryen_local_set_get_value(value _exp) {
1333
1481
  CAMLparam1(_exp);
@@ -1883,6 +2031,203 @@ caml_binaryen_ref_eq(value _module, value _left, value _right) {
1883
2031
  CAMLreturn(alloc_BinaryenExpressionRef(exp));
1884
2032
  }
1885
2033
 
2034
+ // Struct operations
2035
+
2036
+ CAMLprim value
2037
+ caml_binaryen_struct_new(value _module, value _operands, value _type) {
2038
+ CAMLparam3(_module, _operands, _type);
2039
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2040
+ BinaryenHeapType type = BinaryenHeapType_val(_type);
2041
+ if (Is_some(_operands)) {
2042
+ _operands = array_of_list(Some_val(_operands));
2043
+ int operandsLen = array_length(_operands);
2044
+ BinaryenExpressionRef operands[operandsLen];
2045
+ for (int i = 0; i < operandsLen; i++) {
2046
+ operands[i] = BinaryenExpressionRef_val(Field(_operands, i));
2047
+ }
2048
+ BinaryenExpressionRef exp = BinaryenStructNew(module, operands, operandsLen, type);
2049
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2050
+ } else {
2051
+ BinaryenExpressionRef exp = BinaryenStructNew(module, NULL, 0, type);
2052
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2053
+ }
2054
+ }
2055
+
2056
+ CAMLprim value
2057
+ caml_binaryen_struct_get(value _module, value _index, value _ref, value _type, value _signed) {
2058
+ CAMLparam5(_module, _index, _ref, _type, _signed);
2059
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2060
+ BinaryenIndex index = Int_val(_index);
2061
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
2062
+ BinaryenType type = BinaryenType_val(_type);
2063
+ bool signed_ = Bool_val(_signed);
2064
+ BinaryenExpressionRef exp = BinaryenStructGet(module, index, ref, type, signed_);
2065
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2066
+ }
2067
+
2068
+ CAMLprim value
2069
+ caml_binaryen_struct_set(value _module, value _index, value _ref, value _value) {
2070
+ CAMLparam4(_module, _index, _ref, _value);
2071
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2072
+ BinaryenIndex index = Int_val(_index);
2073
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
2074
+ BinaryenExpressionRef value_ = BinaryenExpressionRef_val(_value);
2075
+ BinaryenExpressionRef exp = BinaryenStructSet(module, index, ref, value_);
2076
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2077
+ }
2078
+
2079
+ // Array operations
2080
+
2081
+ CAMLprim value
2082
+ caml_binaryen_array_new(value _module, value _type, value _size, value _init) {
2083
+ CAMLparam4(_module, _type, _size, _init);
2084
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2085
+ BinaryenHeapType type = BinaryenHeapType_val(_type);
2086
+ BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
2087
+ BinaryenExpressionRef init = BinaryenExpressionRef_val(_init);
2088
+ BinaryenExpressionRef exp = BinaryenArrayNew(module, type, size, init);
2089
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2090
+ }
2091
+
2092
+ CAMLprim value
2093
+ caml_binaryen_array_new_data(value _module, value _type, value _name, value _offset, value _size) {
2094
+ CAMLparam5(_module, _type, _name, _offset, _size);
2095
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2096
+ BinaryenHeapType type = BinaryenHeapType_val(_type);
2097
+ char* name = Safe_String_val(_name);
2098
+ BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
2099
+ BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
2100
+ BinaryenExpressionRef exp = BinaryenArrayNewData(module, type, name, offset, size);
2101
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2102
+ }
2103
+
2104
+ CAMLprim value
2105
+ caml_binaryen_array_new_elem(value _module, value _type, value _seg, value _offset, value _size) {
2106
+ CAMLparam5(_module, _type, _seg, _offset, _size);
2107
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2108
+ BinaryenHeapType type = BinaryenHeapType_val(_type);
2109
+ char* seg = Safe_String_val(_seg);
2110
+ BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
2111
+ BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
2112
+ BinaryenExpressionRef exp = BinaryenArrayNewElem(module, type, seg, offset, size);
2113
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2114
+ }
2115
+
2116
+ CAMLprim value
2117
+ caml_binaryen_array_new_fixed(value _module, value _type, value _values) {
2118
+ CAMLparam3(_module, _type, _values);
2119
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2120
+ BinaryenHeapType type = BinaryenHeapType_val(_type);
2121
+ _values = array_of_list(_values);
2122
+ int valuesLen = array_length(_values);
2123
+ BinaryenExpressionRef values[valuesLen];
2124
+ for (int i = 0; i < valuesLen; i++) {
2125
+ values[i] = BinaryenExpressionRef_val(Field(_values, i));
2126
+ }
2127
+ BinaryenExpressionRef exp = BinaryenArrayNewFixed(module, type, values, valuesLen);
2128
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2129
+ }
2130
+
2131
+ CAMLprim value
2132
+ caml_binaryen_array_get(value _module, value _ref, value _index, value _type, value _signed) {
2133
+ CAMLparam5(_module, _ref, _index, _type, _signed);
2134
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2135
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
2136
+ BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
2137
+ BinaryenType type = BinaryenType_val(_type);
2138
+ bool signed_ = Bool_val(_signed);
2139
+ BinaryenExpressionRef exp = BinaryenArrayGet(module, ref, index, type, signed_);
2140
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2141
+ }
2142
+
2143
+ CAMLprim value
2144
+ caml_binaryen_array_set(value _module, value _ref, value _index, value _value) {
2145
+ CAMLparam4(_module, _ref, _index, _value);
2146
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2147
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
2148
+ BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
2149
+ BinaryenExpressionRef value_ = BinaryenExpressionRef_val(_value);
2150
+ BinaryenExpressionRef exp = BinaryenArraySet(module, ref, index, value_);
2151
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2152
+ }
2153
+
2154
+ CAMLprim value
2155
+ caml_binaryen_array_len(value _module, value _ref) {
2156
+ CAMLparam2(_module, _ref);
2157
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2158
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
2159
+ BinaryenExpressionRef exp = BinaryenArrayLen(module, ref);
2160
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2161
+ }
2162
+
2163
+ CAMLprim value
2164
+ caml_binaryen_array_copy(value _module, value _destRef, value _destIndex, value _srcRef, value _srcIndex, value _length) {
2165
+ CAMLparam5(_module, _destRef, _destIndex, _srcRef, _srcIndex);
2166
+ CAMLxparam1(_length);
2167
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2168
+ BinaryenExpressionRef destRef = BinaryenExpressionRef_val(_destRef);
2169
+ BinaryenExpressionRef destIndex = BinaryenExpressionRef_val(_destIndex);
2170
+ BinaryenExpressionRef srcRef = BinaryenExpressionRef_val(_srcRef);
2171
+ BinaryenExpressionRef srcIndex = BinaryenExpressionRef_val(_srcIndex);
2172
+ BinaryenExpressionRef length = BinaryenExpressionRef_val(_length);
2173
+ BinaryenExpressionRef exp = BinaryenArrayCopy(module, destRef, destIndex, srcRef, srcIndex, length);
2174
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2175
+ }
2176
+ CAMLprim value
2177
+ caml_binaryen_array_copy__bytecode(value * argv) {
2178
+ return caml_binaryen_array_copy(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
2179
+ }
2180
+
2181
+ CAMLprim value
2182
+ caml_binaryen_array_fill(value _module, value _ref, value _index, value _value, value _size) {
2183
+ CAMLparam5(_module, _ref, _index, _value, _size);
2184
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2185
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
2186
+ BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
2187
+ BinaryenExpressionRef val = BinaryenExpressionRef_val(_value);
2188
+ BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
2189
+ BinaryenExpressionRef exp = BinaryenArrayFill(module, ref, index, val, size);
2190
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2191
+ }
2192
+
2193
+ CAMLprim value
2194
+ caml_binaryen_array_init_data(value _module, value _name, value _ref, value _index, value _offset, value _size) {
2195
+ CAMLparam5(_module, _name, _ref, _index, _offset);
2196
+ CAMLxparam1(_size);
2197
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2198
+ char* name = Safe_String_val(_name);
2199
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
2200
+ BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
2201
+ BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
2202
+ BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
2203
+ BinaryenExpressionRef exp = BinaryenArrayInitData(module, name, ref, index, offset, size);
2204
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2205
+ }
2206
+
2207
+ CAMLprim value
2208
+ caml_binaryen_array_init_data__bytecode(value * argv) {
2209
+ return caml_binaryen_array_init_data(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
2210
+ }
2211
+
2212
+ CAMLprim value
2213
+ caml_binaryen_array_init_elem(value _module, value _seg, value _ref, value _index, value _offset, value _size) {
2214
+ CAMLparam5(_module, _seg, _ref, _index, _offset);
2215
+ CAMLxparam1(_size);
2216
+ BinaryenModuleRef module = BinaryenModuleRef_val(_module);
2217
+ char* seg = Safe_String_val(_seg);
2218
+ BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
2219
+ BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
2220
+ BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
2221
+ BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
2222
+ BinaryenExpressionRef exp = BinaryenArrayInitElem(module, seg, ref, index, offset, size);
2223
+ CAMLreturn(alloc_BinaryenExpressionRef(exp));
2224
+ }
2225
+
2226
+ CAMLprim value
2227
+ caml_binaryen_array_init_elem__bytecode(value * argv) {
2228
+ return caml_binaryen_array_init_elem(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
2229
+ }
2230
+
1886
2231
  // Exception handling operations
1887
2232
  CAMLprim value
1888
2233
  caml_binaryen_try(value _module, value _name, value _body, value _catchTags, value _catchBodies, value _delegateTarget) {