@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.
- {binaryen-archive → binaryen-archive-v0.11.2}/.gitattributes +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/.gitignore +1 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/.gitmodules +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/CHANGELOG.md +73 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/LICENSE +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/README.md +27 -3
- {binaryen-archive → binaryen-archive-v0.11.2}/binaryen.opam +8 -8
- {binaryen-archive → binaryen-archive-v0.11.2}/dune +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/dune-project +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/dune-workspace +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/.gitattributes +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/.gitignore +0 -0
- binaryen-archive-v0.11.2/esy.lock/index.json +1365 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/astring.0.8.5/opam +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/base-threads.base/opam +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/base-unix.base/opam +0 -0
- {binaryen-archive/esy.lock/opam/base.v0.14.1 → binaryen-archive-v0.11.2/esy.lock/opam/base.v0.14.2}/opam +4 -4
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/biniou.1.2.1/opam +1 -1
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/cmdliner.1.0.4/opam +0 -0
- {binaryen-archive/esy.lock/opam/cppo.1.6.7 → binaryen-archive-v0.11.2/esy.lock/opam/cppo.1.6.8}/opam +4 -6
- {binaryen-archive/esy.lock/opam/csexp.1.4.0 → binaryen-archive-v0.11.2/esy.lock/opam/csexp.1.5.1}/opam +11 -9
- {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
- {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
- {binaryen-archive/esy.lock/opam/dune.2.8.2 → binaryen-archive-v0.11.2/esy.lock/opam/dune.2.9.1}/opam +4 -4
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/easy-format.1.3.2/opam +1 -1
- {binaryen-archive/esy.lock/opam/fix.20201120 → binaryen-archive-v0.11.2/esy.lock/opam/fix.20211231}/opam +7 -5
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/fpath.0.7.3/opam +0 -0
- binaryen-archive-v0.11.2/esy.lock/opam/js_of_ocaml-compiler.3.11.0/opam +54 -0
- binaryen-archive-v0.11.2/esy.lock/opam/js_of_ocaml-ppx.3.11.0/opam +44 -0
- binaryen-archive-v0.11.2/esy.lock/opam/js_of_ocaml.3.11.0/opam +45 -0
- {binaryen-archive/esy.lock/opam/menhir.20201216 → binaryen-archive-v0.11.2/esy.lock/opam/menhir.20211128}/opam +8 -6
- {binaryen-archive/esy.lock/opam/menhirLib.20201216 → binaryen-archive-v0.11.2/esy.lock/opam/menhirLib.20211128}/opam +8 -6
- {binaryen-archive/esy.lock/opam/menhirSdk.20201216 → binaryen-archive-v0.11.2/esy.lock/opam/menhirSdk.20211128}/opam +8 -6
- binaryen-archive-v0.11.2/esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam +39 -0
- {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
- {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
- binaryen-archive-v0.11.2/esy.lock/opam/ocaml-version.3.4.0/opam +49 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/ocamlbuild.0.14.0/opam +1 -1
- {binaryen-archive/esy.lock/opam/ocamlfind.1.8.1 → binaryen-archive-v0.11.2/esy.lock/opam/ocamlfind.1.9.1}/opam +19 -39
- binaryen-archive-v0.11.2/esy.lock/opam/ocamlformat-rpc-lib.0.19.0/opam +40 -0
- binaryen-archive-v0.11.2/esy.lock/opam/ocamlformat.0.18.0/opam +56 -0
- {binaryen-archive/esy.lock/opam/odoc.1.5.2 → binaryen-archive-v0.11.2/esy.lock/opam/odoc.1.5.3}/opam +12 -12
- binaryen-archive-v0.11.2/esy.lock/opam/pp.1.1.2/opam +58 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/ppx_derivers.1.2.1/opam +1 -1
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/ppx_yojson_conv_lib.v0.14.0/opam +2 -2
- {binaryen-archive/esy.lock/opam/ppxlib.0.21.0 → binaryen-archive-v0.11.2/esy.lock/opam/ppxlib.0.22.2}/opam +40 -32
- {binaryen-archive/esy.lock/opam/re.1.9.0 → binaryen-archive-v0.11.2/esy.lock/opam/re.1.10.3}/opam +8 -4
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/result.1.5/opam +2 -2
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/seq.base/files/META.seq +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/seq.base/files/seq.install +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/seq.base/opam +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/sexplib0.v0.14.0/opam +2 -2
- binaryen-archive-v0.11.2/esy.lock/opam/spawn.v0.15.0/opam +56 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/stdio.v0.14.0/opam +2 -2
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/stdlib-shims.0.3.0/opam +0 -0
- {binaryen-archive/esy.lock/opam/topkg.1.0.3 → binaryen-archive-v0.11.2/esy.lock/opam/topkg.1.0.4}/opam +18 -22
- binaryen-archive-v0.11.2/esy.lock/opam/tyxml.4.5.0/opam +42 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/uchar.0.0.2/opam +0 -0
- binaryen-archive-v0.11.2/esy.lock/opam/uucp.14.0.0/opam +41 -0
- {binaryen-archive/esy.lock/opam/uuseg.13.0.0 → binaryen-archive-v0.11.2/esy.lock/opam/uuseg.14.0.0}/opam +22 -28
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/uutf.1.0.2/opam +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/opam/yojson.1.7.0/opam +1 -1
- {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
- {binaryen-archive → binaryen-archive-v0.11.2}/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/package.json +0 -0
- 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
- {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
- binaryen-archive-v0.11.2/js/binaryen.es5.js +5 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/js/dune +1 -6
- binaryen-archive-v0.11.2/js/element_segment.ml +33 -0
- binaryen-archive-v0.11.2/js/export.ml +60 -0
- binaryen-archive-v0.11.2/js/expression.ml +944 -0
- binaryen-archive-v0.11.2/js/function.ml +60 -0
- binaryen-archive-v0.11.2/js/global.ml +48 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/js/import.ml +24 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/js/literal.ml +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/js/memory.ml +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/js/module.ml +42 -46
- {binaryen-archive → binaryen-archive-v0.11.2}/js/op.ml +9 -78
- binaryen-archive-v0.11.2/js/postlude.js +2 -0
- binaryen-archive-v0.11.2/js/prelude.js +11 -0
- binaryen-archive-v0.11.2/js/settings.ml +60 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/js/stubs.c +0 -0
- binaryen-archive-v0.11.2/js/table.ml +29 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/js/type.ml +3 -0
- binaryen-archive-v0.11.2/package.json +37 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_exports.c +78 -0
- binaryen-archive-v0.11.2/src/binaryen_stubs_expressions.c +1710 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_features.c +7 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_functions.c +78 -0
- binaryen-archive-v0.11.2/src/binaryen_stubs_globals.c +109 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_imports.c +29 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_literals.c +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_memory.c +1 -1
- {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_modules.c +0 -122
- {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_ops.c +19 -173
- binaryen-archive-v0.11.2/src/binaryen_stubs_settings.c +145 -0
- binaryen-archive-v0.11.2/src/binaryen_stubs_tables.c +145 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/binaryen_stubs_types.c +18 -0
- binaryen-archive-v0.11.2/src/dune +14 -0
- binaryen-archive-v0.11.2/src/element_segment.ml +13 -0
- binaryen-archive-v0.11.2/src/export.ml +54 -0
- binaryen-archive-v0.11.2/src/expression.ml +844 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/function.ml +18 -0
- binaryen-archive-v0.11.2/src/global.ml +24 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/import.ml +12 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/literal.ml +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/memory.ml +0 -0
- binaryen-archive-v0.11.2/src/module.ml +115 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/ocaml_helpers.c +0 -8
- {binaryen-archive → binaryen-archive-v0.11.2}/src/ocaml_helpers.h +2 -3
- {binaryen-archive → binaryen-archive-v0.11.2}/src/op.ml +18 -131
- binaryen-archive-v0.11.2/src/settings.ml +45 -0
- binaryen-archive-v0.11.2/src/table.ml +26 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/src/type.ml +2 -0
- binaryen-archive-v0.11.2/test/config/dune +8 -0
- binaryen-archive-v0.11.2/test/config/ocamlopt_flags.ml +16 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/test/dune +4 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/test/test.expected +38 -5
- binaryen-archive-v0.11.2/test/test.ml +147 -0
- binaryen-archive-v0.11.2/virtual/dune +6 -0
- binaryen-archive-v0.11.2/virtual/element_segment.mli +11 -0
- binaryen-archive-v0.11.2/virtual/export.mli +33 -0
- binaryen-archive-v0.11.2/virtual/expression.mli +423 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/virtual/function.mli +16 -0
- binaryen-archive-v0.11.2/virtual/global.mli +19 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/virtual/import.mli +8 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/virtual/literal.mli +0 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/virtual/memory.mli +0 -0
- binaryen-archive-v0.11.2/virtual/module.mli +65 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/virtual/op.mli +9 -53
- binaryen-archive-v0.11.2/virtual/settings.mli +35 -0
- binaryen-archive-v0.11.2/virtual/table.mli +19 -0
- {binaryen-archive → binaryen-archive-v0.11.2}/virtual/type.mli +2 -0
- binaryen-archive/esy.lock/index.json +0 -1288
- binaryen-archive/esy.lock/opam/conf-m4.1/opam +0 -22
- binaryen-archive/esy.lock/opam/dot-merlin-reader.4.1/opam +0 -30
- binaryen-archive/esy.lock/opam/js_of_ocaml-compiler.3.9.1/opam +0 -40
- binaryen-archive/esy.lock/opam/js_of_ocaml-ppx.3.9.0/opam +0 -30
- binaryen-archive/esy.lock/opam/js_of_ocaml.3.9.0/opam +0 -31
- binaryen-archive/esy.lock/opam/ocaml-compiler-libs.v0.12.3/opam +0 -29
- binaryen-archive/esy.lock/opam/ocamlfind.1.8.1/files/ocaml-stub +0 -4
- binaryen-archive/esy.lock/opam/ocamlfind.1.8.1/files/ocamlfind.install +0 -6
- binaryen-archive/esy.lock/opam/ocamlformat.0.15.1/opam +0 -41
- binaryen-archive/esy.lock/opam/tyxml.4.4.0/opam +0 -47
- binaryen-archive/esy.lock/opam/uucp.13.0.0/opam +0 -44
- binaryen-archive/esy.lock/overrides/opam__s__conf_m4_opam__c__1_opam_override/package.json +0 -6
- binaryen-archive/js/export.ml +0 -23
- binaryen-archive/js/expression.ml +0 -185
- binaryen-archive/js/features.ml +0 -27
- binaryen-archive/js/function.ml +0 -29
- binaryen-archive/js/function_table.ml +0 -13
- binaryen-archive/js/global.ml +0 -19
- binaryen-archive/js/postlude.js +0 -2
- binaryen-archive/js/table.ml +0 -12
- binaryen-archive/package.json +0 -43
- binaryen-archive/src/binaryen_stubs_expressions.c +0 -410
- binaryen-archive/src/binaryen_stubs_function_tables.c +0 -25
- binaryen-archive/src/binaryen_stubs_globals.c +0 -46
- binaryen-archive/src/binaryen_stubs_tables.c +0 -31
- binaryen-archive/src/config/dune +0 -8
- binaryen-archive/src/config/library_flags.ml +0 -16
- binaryen-archive/src/dune +0 -53
- binaryen-archive/src/export.ml +0 -21
- binaryen-archive/src/expression.ml +0 -115
- binaryen-archive/src/features.ml +0 -49
- binaryen-archive/src/function_table.ml +0 -6
- binaryen-archive/src/global.ml +0 -10
- binaryen-archive/src/module.ml +0 -89
- binaryen-archive/src/table.ml +0 -4
- binaryen-archive/test/test.ml +0 -83
- binaryen-archive/vendor/binaryen-c.h +0 -2647
- binaryen-archive/vendor/js/index.es5.js +0 -5
- binaryen-archive/vendor/linux/libbinaryen.a +0 -0
- binaryen-archive/vendor/linux/libbinaryen.so +0 -0
- binaryen-archive/vendor/macosx/libbinaryen.a +0 -0
- binaryen-archive/vendor/macosx/libbinaryen.dylib +0 -0
- binaryen-archive/vendor/mingw64/libbinaryen.a +0 -0
- binaryen-archive/vendor/mingw64/libbinaryen.dll +0 -0
- binaryen-archive/vendor/wasm-delegations.h +0 -85
- binaryen-archive/virtual/dune +0 -6
- binaryen-archive/virtual/export.mli +0 -11
- binaryen-archive/virtual/expression.mli +0 -68
- binaryen-archive/virtual/features.mli +0 -23
- binaryen-archive/virtual/function_table.mli +0 -4
- binaryen-archive/virtual/global.mli +0 -7
- binaryen-archive/virtual/module.mli +0 -67
- binaryen-archive/virtual/table.mli +0 -2
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
open Js_of_ocaml.Js
|
|
2
|
+
open Js_of_ocaml.Js.Unsafe
|
|
3
|
+
|
|
4
|
+
type t = int
|
|
5
|
+
|
|
6
|
+
type kind =
|
|
7
|
+
| Invalid
|
|
8
|
+
| Nop
|
|
9
|
+
| Block
|
|
10
|
+
| If
|
|
11
|
+
| Loop
|
|
12
|
+
| Break
|
|
13
|
+
| Switch
|
|
14
|
+
| Call
|
|
15
|
+
| CallIndirect
|
|
16
|
+
| LocalGet
|
|
17
|
+
| LocalSet
|
|
18
|
+
| GlobalGet
|
|
19
|
+
| GlobalSet
|
|
20
|
+
| Load
|
|
21
|
+
| Store
|
|
22
|
+
| AtomicRMW
|
|
23
|
+
| AtomicCmpxchg
|
|
24
|
+
| AtomicWait
|
|
25
|
+
| AtomicNotify
|
|
26
|
+
| AtomicFence
|
|
27
|
+
| SIMDExtract
|
|
28
|
+
| SIMDReplace
|
|
29
|
+
| SIMDShuffle
|
|
30
|
+
| SIMDTernary
|
|
31
|
+
| SIMDShift
|
|
32
|
+
| SIMDLoad
|
|
33
|
+
| SIMDLoadStoreLane
|
|
34
|
+
| MemoryInit
|
|
35
|
+
| DataDrop
|
|
36
|
+
| MemoryCopy
|
|
37
|
+
| MemoryFill
|
|
38
|
+
| Const
|
|
39
|
+
| Unary
|
|
40
|
+
| Binary
|
|
41
|
+
| Select
|
|
42
|
+
| Drop
|
|
43
|
+
| Return
|
|
44
|
+
| MemorySize
|
|
45
|
+
| MemoryGrow
|
|
46
|
+
| Unreachable
|
|
47
|
+
| Pop
|
|
48
|
+
| RefNull
|
|
49
|
+
| RefIs
|
|
50
|
+
| RefFunc
|
|
51
|
+
| RefEq
|
|
52
|
+
| Try
|
|
53
|
+
| Throw
|
|
54
|
+
| Rethrow
|
|
55
|
+
| TupleMake
|
|
56
|
+
| TupleExtract
|
|
57
|
+
| I31New
|
|
58
|
+
| I31Get
|
|
59
|
+
| CallRef
|
|
60
|
+
| RefTest
|
|
61
|
+
| RefCast
|
|
62
|
+
| BrOn
|
|
63
|
+
| RttCanon
|
|
64
|
+
| RttSub
|
|
65
|
+
| StructNew
|
|
66
|
+
| StructGet
|
|
67
|
+
| StructSet
|
|
68
|
+
| ArrayNew
|
|
69
|
+
| ArrayGet
|
|
70
|
+
| ArraySet
|
|
71
|
+
| ArrayLen
|
|
72
|
+
| RefAs
|
|
73
|
+
|
|
74
|
+
let expression_to_option x = if x = 0 then None else Some x
|
|
75
|
+
|
|
76
|
+
let get_kind expr =
|
|
77
|
+
match meth_call global##.binaryen "getExpressionId" [| inject expr |] with
|
|
78
|
+
| n when n = global ##. binaryen ##. InvalidId -> Invalid
|
|
79
|
+
| n when n = global ##. binaryen ##. NopId -> Nop
|
|
80
|
+
| n when n = global ##. binaryen ##. BlockId -> Block
|
|
81
|
+
| n when n = global ##. binaryen ##. IfId -> If
|
|
82
|
+
| n when n = global ##. binaryen ##. LoopId -> Loop
|
|
83
|
+
| n when n = global ##. binaryen ##. BreakId -> Break
|
|
84
|
+
| n when n = global ##. binaryen ##. SwitchId -> Switch
|
|
85
|
+
| n when n = global ##. binaryen ##. CallId -> Call
|
|
86
|
+
| n when n = global ##. binaryen ##. CallIndirectId -> CallIndirect
|
|
87
|
+
| n when n = global ##. binaryen ##. LocalGetId -> LocalGet
|
|
88
|
+
| n when n = global ##. binaryen ##. LocalSetId -> LocalSet
|
|
89
|
+
| n when n = global ##. binaryen ##. GlobalGetId -> GlobalGet
|
|
90
|
+
| n when n = global ##. binaryen ##. GlobalSetId -> GlobalSet
|
|
91
|
+
| n when n = global ##. binaryen ##. LoadId -> Load
|
|
92
|
+
| n when n = global ##. binaryen ##. StoreId -> Store
|
|
93
|
+
| n when n = global ##. binaryen ##. AtomicRMWId -> AtomicRMW
|
|
94
|
+
| n when n = global ##. binaryen ##. AtomicCmpxchgId -> AtomicCmpxchg
|
|
95
|
+
| n when n = global ##. binaryen ##. AtomicWaitId -> AtomicWait
|
|
96
|
+
| n when n = global ##. binaryen ##. AtomicNotifyId -> AtomicNotify
|
|
97
|
+
| n when n = global ##. binaryen ##. AtomicFenceId -> AtomicFence
|
|
98
|
+
| n when n = global ##. binaryen ##. SIMDExtractId -> SIMDExtract
|
|
99
|
+
| n when n = global ##. binaryen ##. SIMDReplaceId -> SIMDReplace
|
|
100
|
+
| n when n = global ##. binaryen ##. SIMDShuffleId -> SIMDShuffle
|
|
101
|
+
| n when n = global ##. binaryen ##. SIMDTernaryId -> SIMDTernary
|
|
102
|
+
| n when n = global ##. binaryen ##. SIMDShiftId -> SIMDShift
|
|
103
|
+
| n when n = global ##. binaryen ##. SIMDLoadId -> SIMDLoad
|
|
104
|
+
| n when n = global ##. binaryen ##. SIMDLoadStoreLaneId -> SIMDLoadStoreLane
|
|
105
|
+
| n when n = global ##. binaryen ##. MemoryInitId -> MemoryInit
|
|
106
|
+
| n when n = global ##. binaryen ##. DataDropId -> DataDrop
|
|
107
|
+
| n when n = global ##. binaryen ##. MemoryCopyId -> MemoryCopy
|
|
108
|
+
| n when n = global ##. binaryen ##. MemoryFillId -> MemoryFill
|
|
109
|
+
| n when n = global ##. binaryen ##. ConstId -> Const
|
|
110
|
+
| n when n = global ##. binaryen ##. UnaryId -> Unary
|
|
111
|
+
| n when n = global ##. binaryen ##. BinaryId -> Binary
|
|
112
|
+
| n when n = global ##. binaryen ##. SelectId -> Select
|
|
113
|
+
| n when n = global ##. binaryen ##. DropId -> Drop
|
|
114
|
+
| n when n = global ##. binaryen ##. ReturnId -> Return
|
|
115
|
+
| n when n = global ##. binaryen ##. MemorySizeId -> MemorySize
|
|
116
|
+
| n when n = global ##. binaryen ##. MemoryGrowId -> MemoryGrow
|
|
117
|
+
| n when n = global ##. binaryen ##. UnreachableId -> Unreachable
|
|
118
|
+
| n when n = global ##. binaryen ##. PopId -> Pop
|
|
119
|
+
| n when n = global ##. binaryen ##. RefNullId -> RefNull
|
|
120
|
+
| n when n = global ##. binaryen ##. RefIsId -> RefIs
|
|
121
|
+
| n when n = global ##. binaryen ##. RefFuncId -> RefFunc
|
|
122
|
+
| n when n = global ##. binaryen ##. RefEqId -> RefEq
|
|
123
|
+
| n when n = global ##. binaryen ##. TryId -> Try
|
|
124
|
+
| n when n = global ##. binaryen ##. ThrowId -> Throw
|
|
125
|
+
| n when n = global ##. binaryen ##. RethrowId -> Rethrow
|
|
126
|
+
| n when n = global ##. binaryen ##. TupleMakeId -> TupleMake
|
|
127
|
+
| n when n = global ##. binaryen ##. TupleExtractId -> TupleExtract
|
|
128
|
+
| n when n = global ##. binaryen ##. I31NewId -> I31New
|
|
129
|
+
| n when n = global ##. binaryen ##. I31GetId -> I31Get
|
|
130
|
+
| n when n = global ##. binaryen ##. CallRefId -> CallRef
|
|
131
|
+
| n when n = global ##. binaryen ##. RefTestId -> RefTest
|
|
132
|
+
| n when n = global ##. binaryen ##. RefCastId -> RefCast
|
|
133
|
+
| n when n = global ##. binaryen ##. BrOnId -> BrOn
|
|
134
|
+
| n when n = global ##. binaryen ##. RttCanonId -> RttCanon
|
|
135
|
+
| n when n = global ##. binaryen ##. RttSubId -> RttSub
|
|
136
|
+
| n when n = global ##. binaryen ##. StructNewId -> StructNew
|
|
137
|
+
| n when n = global ##. binaryen ##. StructGetId -> StructGet
|
|
138
|
+
| n when n = global ##. binaryen ##. StructSetId -> StructSet
|
|
139
|
+
| n when n = global ##. binaryen ##. ArrayNewId -> ArrayNew
|
|
140
|
+
| n when n = global ##. binaryen ##. ArrayGetId -> ArrayGet
|
|
141
|
+
| n when n = global ##. binaryen ##. ArraySetId -> ArraySet
|
|
142
|
+
| n when n = global ##. binaryen ##. ArrayLenId -> ArrayLen
|
|
143
|
+
| n when n = global ##. binaryen ##. RefAsId -> RefAs
|
|
144
|
+
| _ -> failwith "unknown expression kind"
|
|
145
|
+
|
|
146
|
+
let print expr =
|
|
147
|
+
let text = meth_call global##.binaryen "emitText" [| inject expr |] in
|
|
148
|
+
print_string (to_string text)
|
|
149
|
+
|
|
150
|
+
let finalize exp =
|
|
151
|
+
meth_call global ##. binaryen ##. Expression "finalize" [| inject exp |]
|
|
152
|
+
|
|
153
|
+
let copy exp wasm_mod = meth_call wasm_mod "copyExpression" [| inject exp |]
|
|
154
|
+
|
|
155
|
+
module Block = struct
|
|
156
|
+
let make ?(return_type = Type.auto) wasm_mod name children =
|
|
157
|
+
meth_call wasm_mod "block"
|
|
158
|
+
[|
|
|
159
|
+
inject (string name);
|
|
160
|
+
inject (array (Array.of_list children));
|
|
161
|
+
inject return_type;
|
|
162
|
+
|]
|
|
163
|
+
|
|
164
|
+
let get_name exp =
|
|
165
|
+
Option.map to_string
|
|
166
|
+
(Opt.to_option
|
|
167
|
+
(meth_call global ##. binaryen ##. Block "getName" [| inject exp |]))
|
|
168
|
+
|
|
169
|
+
let set_name exp name =
|
|
170
|
+
meth_call
|
|
171
|
+
global ##. binaryen ##. Block
|
|
172
|
+
"setName"
|
|
173
|
+
[| inject exp; inject (string name) |]
|
|
174
|
+
|
|
175
|
+
let get_num_children exp =
|
|
176
|
+
meth_call global ##. binaryen ##. Block "getNumChildren" [| inject exp |]
|
|
177
|
+
|
|
178
|
+
let get_child_at exp index =
|
|
179
|
+
meth_call
|
|
180
|
+
global ##. binaryen ##. Block
|
|
181
|
+
"getChildAt"
|
|
182
|
+
[| inject exp; inject index |]
|
|
183
|
+
|
|
184
|
+
let set_child_at exp index child =
|
|
185
|
+
meth_call
|
|
186
|
+
global ##. binaryen ##. Block
|
|
187
|
+
"setChildAt"
|
|
188
|
+
[| inject exp; inject index; inject child |]
|
|
189
|
+
|
|
190
|
+
let append_child exp child =
|
|
191
|
+
meth_call
|
|
192
|
+
global ##. binaryen ##. Block
|
|
193
|
+
"appendChild"
|
|
194
|
+
[| inject exp; inject child |]
|
|
195
|
+
|
|
196
|
+
let insert_child_at exp index child =
|
|
197
|
+
meth_call
|
|
198
|
+
global ##. binaryen ##. Block
|
|
199
|
+
"insertChildAt"
|
|
200
|
+
[| inject exp; inject index; inject child |]
|
|
201
|
+
|
|
202
|
+
let remove_child_at exp index =
|
|
203
|
+
meth_call
|
|
204
|
+
global ##. binaryen ##. Block
|
|
205
|
+
"removeChildAt"
|
|
206
|
+
[| inject exp; inject index |]
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
module If = struct
|
|
210
|
+
let make wasm_mod cond if_true if_false =
|
|
211
|
+
meth_call wasm_mod "if" [| inject cond; inject if_true; inject if_false |]
|
|
212
|
+
|
|
213
|
+
let get_condition exp =
|
|
214
|
+
meth_call global ##. binaryen ##. If "getCondition" [| inject exp |]
|
|
215
|
+
|
|
216
|
+
let set_condition exp cond =
|
|
217
|
+
meth_call
|
|
218
|
+
global ##. binaryen ##. If
|
|
219
|
+
"setCondition"
|
|
220
|
+
[| inject exp; inject cond |]
|
|
221
|
+
|
|
222
|
+
let get_if_true exp =
|
|
223
|
+
meth_call global ##. binaryen ##. If "getIfTrue" [| inject exp |]
|
|
224
|
+
|
|
225
|
+
let set_if_true exp child =
|
|
226
|
+
meth_call
|
|
227
|
+
global ##. binaryen ##. If
|
|
228
|
+
"setIfTrue"
|
|
229
|
+
[| inject exp; inject child |]
|
|
230
|
+
|
|
231
|
+
let get_if_false exp =
|
|
232
|
+
expression_to_option
|
|
233
|
+
(meth_call global ##. binaryen ##. If "getIfFalse" [| inject exp |])
|
|
234
|
+
|
|
235
|
+
let set_if_false exp child =
|
|
236
|
+
meth_call
|
|
237
|
+
global ##. binaryen ##. If
|
|
238
|
+
"setIfFalse"
|
|
239
|
+
[| inject exp; inject child |]
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
module Loop = struct
|
|
243
|
+
let make wasm_mod name body =
|
|
244
|
+
meth_call wasm_mod "loop" [| inject (string name); inject body |]
|
|
245
|
+
|
|
246
|
+
let get_name exp =
|
|
247
|
+
to_string
|
|
248
|
+
(meth_call global ##. binaryen ##. Loop "getName" [| inject exp |])
|
|
249
|
+
|
|
250
|
+
let set_name exp name =
|
|
251
|
+
meth_call
|
|
252
|
+
global ##. binaryen ##. Loop
|
|
253
|
+
"setName"
|
|
254
|
+
[| inject exp; inject (string name) |]
|
|
255
|
+
|
|
256
|
+
let get_body exp =
|
|
257
|
+
meth_call global ##. binaryen ##. Loop "getBody" [| inject exp |]
|
|
258
|
+
|
|
259
|
+
let set_body exp child =
|
|
260
|
+
meth_call
|
|
261
|
+
global ##. binaryen ##. Loop
|
|
262
|
+
"setBody"
|
|
263
|
+
[| inject exp; inject child |]
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
module Break = struct
|
|
267
|
+
let make wasm_mod name cond res =
|
|
268
|
+
meth_call wasm_mod "br" [| inject (string name); inject cond; inject res |]
|
|
269
|
+
|
|
270
|
+
let get_name exp =
|
|
271
|
+
to_string
|
|
272
|
+
(meth_call global ##. binaryen ##. Break "getName" [| inject exp |])
|
|
273
|
+
|
|
274
|
+
let set_name exp name =
|
|
275
|
+
meth_call
|
|
276
|
+
global ##. binaryen ##. Break
|
|
277
|
+
"setName"
|
|
278
|
+
[| inject exp; inject (string name) |]
|
|
279
|
+
|
|
280
|
+
let get_condition exp =
|
|
281
|
+
expression_to_option
|
|
282
|
+
(meth_call global ##. binaryen ##. Break "getCondition" [| inject exp |])
|
|
283
|
+
|
|
284
|
+
let set_condition exp child =
|
|
285
|
+
meth_call
|
|
286
|
+
global ##. binaryen ##. Break
|
|
287
|
+
"setCondition"
|
|
288
|
+
[| inject exp; inject child |]
|
|
289
|
+
|
|
290
|
+
let get_value exp =
|
|
291
|
+
expression_to_option
|
|
292
|
+
(meth_call global ##. binaryen ##. Break "getValue" [| inject exp |])
|
|
293
|
+
|
|
294
|
+
let set_value exp child =
|
|
295
|
+
meth_call
|
|
296
|
+
global ##. binaryen ##. Break
|
|
297
|
+
"setValue"
|
|
298
|
+
[| inject exp; inject child |]
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
module Switch = struct
|
|
302
|
+
let make wasm_mod names default_name cond value =
|
|
303
|
+
meth_call wasm_mod "switch"
|
|
304
|
+
[|
|
|
305
|
+
inject (array (Array.of_list (List.map string names)));
|
|
306
|
+
inject (string default_name);
|
|
307
|
+
inject cond;
|
|
308
|
+
inject value;
|
|
309
|
+
|]
|
|
310
|
+
|
|
311
|
+
let get_num_names exp =
|
|
312
|
+
meth_call global ##. binaryen ##. Switch "getNumNames" [| inject exp |]
|
|
313
|
+
|
|
314
|
+
let get_name_at exp index =
|
|
315
|
+
to_string
|
|
316
|
+
(meth_call
|
|
317
|
+
global ##. binaryen ##. Switch
|
|
318
|
+
"getNameAt"
|
|
319
|
+
[| inject exp; inject index |])
|
|
320
|
+
|
|
321
|
+
let set_name_at exp index name =
|
|
322
|
+
meth_call
|
|
323
|
+
global ##. binaryen ##. Switch
|
|
324
|
+
"setNameAt"
|
|
325
|
+
[| inject exp; inject index; inject (string name) |]
|
|
326
|
+
|
|
327
|
+
let append_name exp name =
|
|
328
|
+
meth_call
|
|
329
|
+
global ##. binaryen ##. Switch
|
|
330
|
+
"appendName"
|
|
331
|
+
[| inject exp; inject (string name) |]
|
|
332
|
+
|
|
333
|
+
let insert_name_at exp index name =
|
|
334
|
+
meth_call
|
|
335
|
+
global ##. binaryen ##. Switch
|
|
336
|
+
"insertNameAt"
|
|
337
|
+
[| inject exp; inject index; inject (string name) |]
|
|
338
|
+
|
|
339
|
+
let remove_name_at exp index =
|
|
340
|
+
to_string
|
|
341
|
+
(meth_call
|
|
342
|
+
global ##. binaryen ##. Switch
|
|
343
|
+
"removeNameAt"
|
|
344
|
+
[| inject exp; inject index |])
|
|
345
|
+
|
|
346
|
+
let get_default_name exp =
|
|
347
|
+
Option.map to_string
|
|
348
|
+
(Opt.to_option
|
|
349
|
+
(meth_call
|
|
350
|
+
global ##. binaryen ##. Switch
|
|
351
|
+
"getDefaultName"
|
|
352
|
+
[| inject exp |]))
|
|
353
|
+
|
|
354
|
+
let set_default_name exp name =
|
|
355
|
+
meth_call
|
|
356
|
+
global ##. binaryen ##. Switch
|
|
357
|
+
"setDefaultName"
|
|
358
|
+
[| inject exp; inject (string name) |]
|
|
359
|
+
|
|
360
|
+
let get_condition exp =
|
|
361
|
+
meth_call global ##. binaryen ##. Switch "getCondition" [| inject exp |]
|
|
362
|
+
|
|
363
|
+
let set_condition exp child =
|
|
364
|
+
meth_call
|
|
365
|
+
global ##. binaryen ##. Switch
|
|
366
|
+
"setCondition"
|
|
367
|
+
[| inject exp; inject child |]
|
|
368
|
+
|
|
369
|
+
let get_value exp =
|
|
370
|
+
expression_to_option
|
|
371
|
+
(meth_call global ##. binaryen ##. Switch "getValue" [| inject exp |])
|
|
372
|
+
|
|
373
|
+
let set_value exp child =
|
|
374
|
+
meth_call
|
|
375
|
+
global ##. binaryen ##. Switch
|
|
376
|
+
"setValue"
|
|
377
|
+
[| inject exp; inject child |]
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
module Call = struct
|
|
381
|
+
let make wasm_mod name params return_typ =
|
|
382
|
+
meth_call wasm_mod "call"
|
|
383
|
+
[|
|
|
384
|
+
inject (string name);
|
|
385
|
+
inject (array (Array.of_list params));
|
|
386
|
+
inject return_typ;
|
|
387
|
+
|]
|
|
388
|
+
|
|
389
|
+
let make_return wasm_mod name params return_typ =
|
|
390
|
+
meth_call wasm_mod "return_call"
|
|
391
|
+
[|
|
|
392
|
+
inject (string name);
|
|
393
|
+
inject (array (Array.of_list params));
|
|
394
|
+
inject return_typ;
|
|
395
|
+
|]
|
|
396
|
+
|
|
397
|
+
let get_target exp =
|
|
398
|
+
to_string
|
|
399
|
+
(meth_call global ##. binaryen ##. Call "getTarget" [| inject exp |])
|
|
400
|
+
|
|
401
|
+
let set_target exp name =
|
|
402
|
+
meth_call
|
|
403
|
+
global ##. binaryen ##. Call
|
|
404
|
+
"setTarget"
|
|
405
|
+
[| inject exp; inject (string name) |]
|
|
406
|
+
|
|
407
|
+
let get_num_operands exp =
|
|
408
|
+
meth_call global ##. binaryen ##. Call "getNumOperands" [| inject exp |]
|
|
409
|
+
|
|
410
|
+
let get_operand_at exp index =
|
|
411
|
+
meth_call
|
|
412
|
+
global ##. binaryen ##. Call
|
|
413
|
+
"getOperandAt"
|
|
414
|
+
[| inject exp; inject index |]
|
|
415
|
+
|
|
416
|
+
let set_operand_at exp index operand =
|
|
417
|
+
meth_call
|
|
418
|
+
global ##. binaryen ##. Call
|
|
419
|
+
"setOperandAt"
|
|
420
|
+
[| inject exp; inject index; inject operand |]
|
|
421
|
+
|
|
422
|
+
let append_operand exp operand =
|
|
423
|
+
meth_call
|
|
424
|
+
global ##. binaryen ##. Call
|
|
425
|
+
"appendOperand"
|
|
426
|
+
[| inject exp; inject operand |]
|
|
427
|
+
|
|
428
|
+
let insert_operand_at exp index operand =
|
|
429
|
+
meth_call
|
|
430
|
+
global ##. binaryen ##. Call
|
|
431
|
+
"insertOperandAt"
|
|
432
|
+
[| inject exp; inject index; inject operand |]
|
|
433
|
+
|
|
434
|
+
let remove_operand_at exp index =
|
|
435
|
+
meth_call
|
|
436
|
+
global ##. binaryen ##. Call
|
|
437
|
+
"removeOperandAt"
|
|
438
|
+
[| inject exp; inject index |]
|
|
439
|
+
|
|
440
|
+
let is_return exp =
|
|
441
|
+
to_bool (meth_call global ##. binaryen ##. Call "isReturn" [| inject exp |])
|
|
442
|
+
|
|
443
|
+
let set_return exp isReturn =
|
|
444
|
+
meth_call
|
|
445
|
+
global ##. binaryen ##. Call
|
|
446
|
+
"setReturn"
|
|
447
|
+
[| inject exp; inject (bool isReturn) |]
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
module Call_indirect = struct
|
|
451
|
+
let make wasm_mod table target params params_typ return_typ =
|
|
452
|
+
meth_call wasm_mod "call_indirect"
|
|
453
|
+
[|
|
|
454
|
+
inject (string table);
|
|
455
|
+
inject target;
|
|
456
|
+
inject (array (Array.of_list params));
|
|
457
|
+
inject params_typ;
|
|
458
|
+
inject return_typ;
|
|
459
|
+
|]
|
|
460
|
+
|
|
461
|
+
let make_return wasm_mod table target params params_typ return_typ =
|
|
462
|
+
meth_call wasm_mod "return_call_indirect"
|
|
463
|
+
[|
|
|
464
|
+
inject (string table);
|
|
465
|
+
inject target;
|
|
466
|
+
inject (array (Array.of_list params));
|
|
467
|
+
inject params_typ;
|
|
468
|
+
inject return_typ;
|
|
469
|
+
|]
|
|
470
|
+
|
|
471
|
+
let get_target exp =
|
|
472
|
+
meth_call global ##. binaryen ##. CallIndirect "getTarget" [| inject exp |]
|
|
473
|
+
|
|
474
|
+
let set_target exp target =
|
|
475
|
+
meth_call
|
|
476
|
+
global ##. binaryen ##. CallIndirect
|
|
477
|
+
"setTarget"
|
|
478
|
+
[| inject exp; inject target |]
|
|
479
|
+
|
|
480
|
+
let get_table exp =
|
|
481
|
+
to_string
|
|
482
|
+
(meth_call
|
|
483
|
+
global ##. binaryen ##. CallIndirect
|
|
484
|
+
"getTable"
|
|
485
|
+
[| inject exp |])
|
|
486
|
+
|
|
487
|
+
let set_table exp name =
|
|
488
|
+
meth_call
|
|
489
|
+
global ##. binaryen ##. CallIndirect
|
|
490
|
+
"setTable"
|
|
491
|
+
[| inject exp; inject (string name) |]
|
|
492
|
+
|
|
493
|
+
let get_num_operands exp =
|
|
494
|
+
meth_call
|
|
495
|
+
global ##. binaryen ##. CallIndirect
|
|
496
|
+
"getNumOperands"
|
|
497
|
+
[| inject exp |]
|
|
498
|
+
|
|
499
|
+
let get_operand_at exp index =
|
|
500
|
+
meth_call
|
|
501
|
+
global ##. binaryen ##. CallIndirect
|
|
502
|
+
"getOperandAt"
|
|
503
|
+
[| inject exp; inject index |]
|
|
504
|
+
|
|
505
|
+
let set_operand_at exp index operand =
|
|
506
|
+
meth_call
|
|
507
|
+
global ##. binaryen ##. CallIndirect
|
|
508
|
+
"setOperandAt"
|
|
509
|
+
[| inject exp; inject index; inject operand |]
|
|
510
|
+
|
|
511
|
+
let append_operand exp operand =
|
|
512
|
+
meth_call
|
|
513
|
+
global ##. binaryen ##. CallIndirect
|
|
514
|
+
"appendOperand"
|
|
515
|
+
[| inject exp; inject operand |]
|
|
516
|
+
|
|
517
|
+
let insert_operand_at exp index operand =
|
|
518
|
+
meth_call
|
|
519
|
+
global ##. binaryen ##. CallIndirect
|
|
520
|
+
"insertOperandAt"
|
|
521
|
+
[| inject exp; inject index; inject operand |]
|
|
522
|
+
|
|
523
|
+
let remove_operand_at exp index =
|
|
524
|
+
meth_call
|
|
525
|
+
global ##. binaryen ##. CallIndirect
|
|
526
|
+
"removeOperandAt"
|
|
527
|
+
[| inject exp; inject index |]
|
|
528
|
+
|
|
529
|
+
let is_return exp =
|
|
530
|
+
to_bool
|
|
531
|
+
(meth_call
|
|
532
|
+
global ##. binaryen ##. CallIndirect
|
|
533
|
+
"isReturn"
|
|
534
|
+
[| inject exp |])
|
|
535
|
+
|
|
536
|
+
let set_return exp isReturn =
|
|
537
|
+
meth_call
|
|
538
|
+
global ##. binaryen ##. CallIndirect
|
|
539
|
+
"setReturn"
|
|
540
|
+
[| inject exp; inject (bool isReturn) |]
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
module Local_get = struct
|
|
544
|
+
let make wasm_mod slot typ =
|
|
545
|
+
let scope = get wasm_mod "local" in
|
|
546
|
+
meth_call scope "get" [| inject slot; inject typ |]
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
module Local_set = struct
|
|
550
|
+
let make wasm_mod slot value =
|
|
551
|
+
let scope = get wasm_mod "local" in
|
|
552
|
+
meth_call scope "set" [| inject slot; inject value |]
|
|
553
|
+
|
|
554
|
+
let get_value exp =
|
|
555
|
+
meth_call global ##. binaryen ##. LocalSet "getValue" [| inject exp |]
|
|
556
|
+
|
|
557
|
+
let set_value exp value =
|
|
558
|
+
meth_call
|
|
559
|
+
global ##. binaryen ##. LocalSet
|
|
560
|
+
"setValue"
|
|
561
|
+
[| inject exp; inject value |]
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
module Local_tee = struct
|
|
565
|
+
let make wasm_mod slot value typ =
|
|
566
|
+
let scope = get wasm_mod "local" in
|
|
567
|
+
meth_call scope "tee" [| inject slot; inject value; inject typ |]
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
module Global_get = struct
|
|
571
|
+
let make wasm_mod name typ =
|
|
572
|
+
let scope = get wasm_mod "global" in
|
|
573
|
+
meth_call scope "get" [| inject (string name); inject typ |]
|
|
574
|
+
|
|
575
|
+
let get_name exp =
|
|
576
|
+
to_string
|
|
577
|
+
(meth_call global ##. binaryen ##. GlobalGet "getName" [| inject exp |])
|
|
578
|
+
|
|
579
|
+
let set_name exp name =
|
|
580
|
+
meth_call
|
|
581
|
+
global ##. binaryen ##. GlobalGet
|
|
582
|
+
"setName"
|
|
583
|
+
[| inject exp; inject (string name) |]
|
|
584
|
+
end
|
|
585
|
+
|
|
586
|
+
module Global_set = struct
|
|
587
|
+
let make wasm_mod name value =
|
|
588
|
+
let scope = get wasm_mod "global" in
|
|
589
|
+
meth_call scope "set" [| inject (string name); inject value |]
|
|
590
|
+
|
|
591
|
+
let get_name exp =
|
|
592
|
+
to_string
|
|
593
|
+
(meth_call global ##. binaryen ##. GlobalSet "getName" [| inject exp |])
|
|
594
|
+
|
|
595
|
+
let set_name exp name =
|
|
596
|
+
meth_call
|
|
597
|
+
global ##. binaryen ##. GlobalSet
|
|
598
|
+
"setName"
|
|
599
|
+
[| inject exp; inject (string name) |]
|
|
600
|
+
|
|
601
|
+
let get_value exp =
|
|
602
|
+
meth_call global ##. binaryen ##. GlobalSet "getValue" [| inject exp |]
|
|
603
|
+
|
|
604
|
+
let set_value exp value =
|
|
605
|
+
meth_call
|
|
606
|
+
global ##. binaryen ##. GlobalSet
|
|
607
|
+
"setValue"
|
|
608
|
+
[| inject exp; inject value |]
|
|
609
|
+
end
|
|
610
|
+
|
|
611
|
+
module Load = struct
|
|
612
|
+
let make wasm_mod byts ?(signed = false) offset align typ ptr =
|
|
613
|
+
meth_call global##.binaryen "_BinaryenLoad"
|
|
614
|
+
[|
|
|
615
|
+
inject wasm_mod;
|
|
616
|
+
inject byts;
|
|
617
|
+
inject signed;
|
|
618
|
+
inject offset;
|
|
619
|
+
inject align;
|
|
620
|
+
inject typ;
|
|
621
|
+
inject ptr;
|
|
622
|
+
|]
|
|
623
|
+
|
|
624
|
+
let get_ptr exp =
|
|
625
|
+
meth_call global ##. binaryen ##. Load "getPtr" [| inject exp |]
|
|
626
|
+
|
|
627
|
+
let set_ptr exp ptr =
|
|
628
|
+
meth_call global ##. binaryen ##. Load "setPtr" [| inject exp; inject ptr |]
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
module Store = struct
|
|
632
|
+
let make wasm_mod byts offset align ptr value typ =
|
|
633
|
+
meth_call global##.binaryen "_BinaryenStore"
|
|
634
|
+
[|
|
|
635
|
+
inject wasm_mod;
|
|
636
|
+
inject byts;
|
|
637
|
+
inject offset;
|
|
638
|
+
inject align;
|
|
639
|
+
inject ptr;
|
|
640
|
+
inject value;
|
|
641
|
+
inject typ;
|
|
642
|
+
|]
|
|
643
|
+
|
|
644
|
+
let get_ptr exp =
|
|
645
|
+
meth_call global ##. binaryen ##. Store "getPtr" [| inject exp |]
|
|
646
|
+
|
|
647
|
+
let set_ptr exp ptr =
|
|
648
|
+
meth_call
|
|
649
|
+
global ##. binaryen ##. Store
|
|
650
|
+
"setPtr"
|
|
651
|
+
[| inject exp; inject ptr |]
|
|
652
|
+
|
|
653
|
+
let get_value exp =
|
|
654
|
+
meth_call global ##. binaryen ##. Store "getValue" [| inject exp |]
|
|
655
|
+
|
|
656
|
+
let set_value exp value =
|
|
657
|
+
meth_call
|
|
658
|
+
global ##. binaryen ##. Store
|
|
659
|
+
"setValue"
|
|
660
|
+
[| inject exp; inject value |]
|
|
661
|
+
end
|
|
662
|
+
|
|
663
|
+
module Const = struct
|
|
664
|
+
let make wasm_mod lit =
|
|
665
|
+
let lit_hack = Literal.to_jsoo lit in
|
|
666
|
+
match lit_hack with
|
|
667
|
+
| Int32 value ->
|
|
668
|
+
let scope = get wasm_mod "i32" in
|
|
669
|
+
meth_call scope "const" [| inject value |]
|
|
670
|
+
| Int64 (low, high) ->
|
|
671
|
+
let scope = get wasm_mod "i64" in
|
|
672
|
+
meth_call scope "const" [| inject low; inject high |]
|
|
673
|
+
| Float32Bits value ->
|
|
674
|
+
let scope = get wasm_mod "f32" in
|
|
675
|
+
meth_call scope "const_bits" [| inject value |]
|
|
676
|
+
| Float64Bits (low, high) ->
|
|
677
|
+
let scope = get wasm_mod "f64" in
|
|
678
|
+
meth_call scope "const_bits" [| inject low; inject high |]
|
|
679
|
+
| Float32 value ->
|
|
680
|
+
let scope = get wasm_mod "f32" in
|
|
681
|
+
meth_call scope "const" [| inject value |]
|
|
682
|
+
| Float64 value ->
|
|
683
|
+
let scope = get wasm_mod "f64" in
|
|
684
|
+
meth_call scope "const" [| inject value |]
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
module Unary = struct
|
|
688
|
+
let make wasm_mod op p =
|
|
689
|
+
meth_call global##.binaryen "_BinaryenUnary"
|
|
690
|
+
[| inject wasm_mod; inject op; inject p |]
|
|
691
|
+
|
|
692
|
+
let get_value exp =
|
|
693
|
+
meth_call global ##. binaryen ##. Unary "getValue" [| inject exp |]
|
|
694
|
+
|
|
695
|
+
let set_value exp value =
|
|
696
|
+
meth_call
|
|
697
|
+
global ##. binaryen ##. Unary
|
|
698
|
+
"setValue"
|
|
699
|
+
[| inject exp; inject value |]
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
module Binary = struct
|
|
703
|
+
let make wasm_mod op a b =
|
|
704
|
+
meth_call global##.binaryen "_BinaryenBinary"
|
|
705
|
+
[| inject wasm_mod; inject op; inject a; inject b |]
|
|
706
|
+
|
|
707
|
+
let get_left exp =
|
|
708
|
+
meth_call global ##. binaryen ##. Binary "getLeft" [| inject exp |]
|
|
709
|
+
|
|
710
|
+
let set_left exp value =
|
|
711
|
+
meth_call
|
|
712
|
+
global ##. binaryen ##. Binary
|
|
713
|
+
"setLeft"
|
|
714
|
+
[| inject exp; inject value |]
|
|
715
|
+
|
|
716
|
+
let get_right exp =
|
|
717
|
+
meth_call global ##. binaryen ##. Binary "getRight" [| inject exp |]
|
|
718
|
+
|
|
719
|
+
let set_right exp value =
|
|
720
|
+
meth_call
|
|
721
|
+
global ##. binaryen ##. Binary
|
|
722
|
+
"setRight"
|
|
723
|
+
[| inject exp; inject value |]
|
|
724
|
+
end
|
|
725
|
+
|
|
726
|
+
module Select = struct
|
|
727
|
+
let make wasm_mod cond if_true if_false =
|
|
728
|
+
meth_call wasm_mod "select"
|
|
729
|
+
[| inject cond; inject if_true; inject if_false; inject Type.auto |]
|
|
730
|
+
|
|
731
|
+
let get_if_true exp =
|
|
732
|
+
meth_call global ##. binaryen ##. Select "getIfTrue" [| inject exp |]
|
|
733
|
+
|
|
734
|
+
let set_if_true exp value =
|
|
735
|
+
meth_call
|
|
736
|
+
global ##. binaryen ##. Select
|
|
737
|
+
"setIfTrue"
|
|
738
|
+
[| inject exp; inject value |]
|
|
739
|
+
|
|
740
|
+
let get_if_false exp =
|
|
741
|
+
meth_call global ##. binaryen ##. Select "getIfFalse" [| inject exp |]
|
|
742
|
+
|
|
743
|
+
let set_if_false exp value =
|
|
744
|
+
meth_call
|
|
745
|
+
global ##. binaryen ##. Select
|
|
746
|
+
"setIfFalse"
|
|
747
|
+
[| inject exp; inject value |]
|
|
748
|
+
|
|
749
|
+
let get_condition exp =
|
|
750
|
+
meth_call global ##. binaryen ##. Select "getCondition" [| inject exp |]
|
|
751
|
+
|
|
752
|
+
let set_condition exp value =
|
|
753
|
+
meth_call
|
|
754
|
+
global ##. binaryen ##. Select
|
|
755
|
+
"setCondition"
|
|
756
|
+
[| inject exp; inject value |]
|
|
757
|
+
end
|
|
758
|
+
|
|
759
|
+
module Drop = struct
|
|
760
|
+
let make wasm_mod value = meth_call wasm_mod "drop" [| inject value |]
|
|
761
|
+
|
|
762
|
+
let get_value exp =
|
|
763
|
+
meth_call global ##. binaryen ##. Drop "getValue" [| inject exp |]
|
|
764
|
+
|
|
765
|
+
let set_value exp value =
|
|
766
|
+
meth_call
|
|
767
|
+
global ##. binaryen ##. Drop
|
|
768
|
+
"setValue"
|
|
769
|
+
[| inject exp; inject value |]
|
|
770
|
+
end
|
|
771
|
+
|
|
772
|
+
module Return = struct
|
|
773
|
+
let make wasm_mod value = meth_call wasm_mod "return" [| inject value |]
|
|
774
|
+
|
|
775
|
+
let get_value exp =
|
|
776
|
+
meth_call global ##. binaryen ##. Return "getValue" [| inject exp |]
|
|
777
|
+
|
|
778
|
+
let set_value exp value =
|
|
779
|
+
meth_call
|
|
780
|
+
global ##. binaryen ##. Return
|
|
781
|
+
"setValue"
|
|
782
|
+
[| inject exp; inject value |]
|
|
783
|
+
end
|
|
784
|
+
|
|
785
|
+
module Memory_size = struct
|
|
786
|
+
let make wasm_mod =
|
|
787
|
+
let scope = get wasm_mod "memory" in
|
|
788
|
+
meth_call scope "size" [||]
|
|
789
|
+
end
|
|
790
|
+
|
|
791
|
+
module Memory_grow = struct
|
|
792
|
+
let make wasm_mod value =
|
|
793
|
+
let scope = get wasm_mod "memory" in
|
|
794
|
+
meth_call scope "grow" [| inject value |]
|
|
795
|
+
|
|
796
|
+
let get_delta exp =
|
|
797
|
+
meth_call global ##. binaryen ##. MemoryGrow "getDelta" [| inject exp |]
|
|
798
|
+
|
|
799
|
+
let set_delta exp delta =
|
|
800
|
+
meth_call
|
|
801
|
+
global ##. binaryen ##. MemoryGrow
|
|
802
|
+
"setDelta"
|
|
803
|
+
[| inject exp; inject delta |]
|
|
804
|
+
end
|
|
805
|
+
|
|
806
|
+
module Memory_copy = struct
|
|
807
|
+
let make wasm_mod dest source size =
|
|
808
|
+
let scope = get wasm_mod "memory" in
|
|
809
|
+
meth_call scope "copy" [| inject dest; inject source; inject size |]
|
|
810
|
+
|
|
811
|
+
let get_dest exp =
|
|
812
|
+
meth_call global ##. binaryen ##. MemoryCopy "getDest" [| inject exp |]
|
|
813
|
+
|
|
814
|
+
let set_dest exp value =
|
|
815
|
+
meth_call
|
|
816
|
+
global ##. binaryen ##. MemoryCopy
|
|
817
|
+
"setDest"
|
|
818
|
+
[| inject exp; inject value |]
|
|
819
|
+
|
|
820
|
+
let get_source exp =
|
|
821
|
+
meth_call global ##. binaryen ##. MemoryCopy "getSource" [| inject exp |]
|
|
822
|
+
|
|
823
|
+
let set_source exp value =
|
|
824
|
+
meth_call
|
|
825
|
+
global ##. binaryen ##. MemoryCopy
|
|
826
|
+
"setSource"
|
|
827
|
+
[| inject exp; inject value |]
|
|
828
|
+
|
|
829
|
+
let get_size exp =
|
|
830
|
+
meth_call global ##. binaryen ##. MemoryCopy "getSize" [| inject exp |]
|
|
831
|
+
|
|
832
|
+
let set_size exp value =
|
|
833
|
+
meth_call
|
|
834
|
+
global ##. binaryen ##. MemoryCopy
|
|
835
|
+
"setSize"
|
|
836
|
+
[| inject exp; inject value |]
|
|
837
|
+
end
|
|
838
|
+
|
|
839
|
+
module Memory_fill = struct
|
|
840
|
+
let make wasm_mod dest value size =
|
|
841
|
+
let scope = get wasm_mod "memory" in
|
|
842
|
+
meth_call scope "fill" [| inject dest; inject value; inject size |]
|
|
843
|
+
|
|
844
|
+
let get_dest exp =
|
|
845
|
+
meth_call global ##. binaryen ##. MemoryFill "getDest" [| inject exp |]
|
|
846
|
+
|
|
847
|
+
let set_dest exp value =
|
|
848
|
+
meth_call
|
|
849
|
+
global ##. binaryen ##. MemoryFill
|
|
850
|
+
"setDest"
|
|
851
|
+
[| inject exp; inject value |]
|
|
852
|
+
|
|
853
|
+
let get_value exp =
|
|
854
|
+
meth_call global ##. binaryen ##. MemoryFill "getValue" [| inject exp |]
|
|
855
|
+
|
|
856
|
+
let set_value exp value =
|
|
857
|
+
meth_call
|
|
858
|
+
global ##. binaryen ##. MemoryFill
|
|
859
|
+
"setValue"
|
|
860
|
+
[| inject exp; inject value |]
|
|
861
|
+
|
|
862
|
+
let get_size exp =
|
|
863
|
+
meth_call global ##. binaryen ##. MemoryFill "getSize" [| inject exp |]
|
|
864
|
+
|
|
865
|
+
let set_size exp value =
|
|
866
|
+
meth_call
|
|
867
|
+
global ##. binaryen ##. MemoryFill
|
|
868
|
+
"setSize"
|
|
869
|
+
[| inject exp; inject value |]
|
|
870
|
+
end
|
|
871
|
+
|
|
872
|
+
module Tuple_make = struct
|
|
873
|
+
let make wasm_mod operands =
|
|
874
|
+
let scope = get wasm_mod "tuple" in
|
|
875
|
+
meth_call scope "make" [| inject (array (Array.of_list operands)) |]
|
|
876
|
+
|
|
877
|
+
let get_num_operands exp =
|
|
878
|
+
meth_call
|
|
879
|
+
global ##. binaryen ##. TupleMake
|
|
880
|
+
"getNumOperands"
|
|
881
|
+
[| inject exp |]
|
|
882
|
+
|
|
883
|
+
let get_operand_at exp index =
|
|
884
|
+
meth_call
|
|
885
|
+
global ##. binaryen ##. TupleMake
|
|
886
|
+
"getOperandAt"
|
|
887
|
+
[| inject exp; inject index |]
|
|
888
|
+
|
|
889
|
+
let set_operand_at exp index operand =
|
|
890
|
+
meth_call
|
|
891
|
+
global ##. binaryen ##. TupleMake
|
|
892
|
+
"setOperandAt"
|
|
893
|
+
[| inject exp; inject index; inject operand |]
|
|
894
|
+
|
|
895
|
+
let append_operand exp operand =
|
|
896
|
+
meth_call
|
|
897
|
+
global ##. binaryen ##. TupleMake
|
|
898
|
+
"appendOperand"
|
|
899
|
+
[| inject exp; inject operand |]
|
|
900
|
+
|
|
901
|
+
let insert_operand_at exp index operand =
|
|
902
|
+
meth_call
|
|
903
|
+
global ##. binaryen ##. TupleMake
|
|
904
|
+
"insertOperandAt"
|
|
905
|
+
[| inject exp; inject index; inject operand |]
|
|
906
|
+
|
|
907
|
+
let remove_operand_at exp index =
|
|
908
|
+
meth_call
|
|
909
|
+
global ##. binaryen ##. TupleMake
|
|
910
|
+
"removeOperandAt"
|
|
911
|
+
[| inject exp; inject index |]
|
|
912
|
+
end
|
|
913
|
+
|
|
914
|
+
module Tuple_extract = struct
|
|
915
|
+
let make wasm_mod tuple index =
|
|
916
|
+
let scope = get wasm_mod "tuple" in
|
|
917
|
+
meth_call scope "extract" [| inject tuple; inject index |]
|
|
918
|
+
|
|
919
|
+
let get_tuple exp =
|
|
920
|
+
meth_call global ##. binaryen ##. TupleExtract "getTuple" [| inject exp |]
|
|
921
|
+
|
|
922
|
+
let set_tuple exp value =
|
|
923
|
+
meth_call
|
|
924
|
+
global ##. binaryen ##. TupleExtract
|
|
925
|
+
"setTuple"
|
|
926
|
+
[| inject exp; inject value |]
|
|
927
|
+
end
|
|
928
|
+
|
|
929
|
+
module Nop = struct
|
|
930
|
+
let make wasm_mod = meth_call wasm_mod "nop" [||]
|
|
931
|
+
end
|
|
932
|
+
|
|
933
|
+
module Unreachable = struct
|
|
934
|
+
let make wasm_mod = meth_call wasm_mod "unreachable" [||]
|
|
935
|
+
end
|
|
936
|
+
|
|
937
|
+
module Pop = struct
|
|
938
|
+
let make wasm_mod typ =
|
|
939
|
+
meth_call global##.binaryen "_BinaryenPop" [| inject wasm_mod; inject typ |]
|
|
940
|
+
end
|
|
941
|
+
|
|
942
|
+
module Null = struct
|
|
943
|
+
let make () = pure_js_expr "null"
|
|
944
|
+
end
|