@grain/binaryen.ml 0.18.0 → 0.20.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.
- binaryen-archive/CHANGELOG.md +54 -0
- binaryen-archive/README.md +0 -16
- binaryen-archive/binaryen.opam +5 -5
- binaryen-archive/dune-project +1 -1
- binaryen-archive/dune-workspace +1 -1
- binaryen-archive/esy.lock/index.json +422 -372
- binaryen-archive/esy.lock/opam/{base.v0.14.3 → base.v0.15.1}/opam +4 -4
- binaryen-archive/esy.lock/opam/camlp-streams.5.0.1/opam +59 -0
- binaryen-archive/esy.lock/opam/chrome-trace.3.6.1/opam +39 -0
- binaryen-archive/esy.lock/opam/{dune-build-info.3.3.1 → dune-build-info.3.6.1}/opam +6 -6
- binaryen-archive/esy.lock/opam/{dune-configurator.3.3.1 → dune-configurator.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-rpc.3.3.1 → dune-rpc.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune.3.3.1 → dune.3.6.1}/opam +6 -6
- binaryen-archive/esy.lock/opam/{dyn.3.3.1 → dyn.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{fiber.3.3.1 → fiber.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{js_of_ocaml-compiler.4.0.0 → js_of_ocaml-compiler.4.1.0}/opam +9 -10
- binaryen-archive/esy.lock/opam/menhir.20220210/opam +1 -1
- binaryen-archive/esy.lock/opam/menhirLib.20220210/opam +1 -1
- binaryen-archive/esy.lock/opam/menhirSdk.20220210/opam +1 -1
- binaryen-archive/esy.lock/opam/{ocaml-lsp-server.1.12.2 → ocaml-lsp-server.1.12.4}/opam +7 -6
- binaryen-archive/esy.lock/opam/{ocaml-version.3.4.0 → ocaml-version.3.5.0}/opam +4 -4
- binaryen-archive/esy.lock/opam/{ocamlbuild.0.14.1 → ocamlbuild.0.14.2}/opam +3 -3
- binaryen-archive/esy.lock/opam/ocamlfind.1.9.5/files/0001-Fix-bug-when-installing-with-a-system-compiler.patch +26 -0
- binaryen-archive/esy.lock/opam/ocamlfind.1.9.5/opam +2 -0
- binaryen-archive/esy.lock/opam/{ocamlformat-rpc-lib.0.22.4 → ocamlformat-rpc-lib.0.24.1}/opam +4 -4
- binaryen-archive/esy.lock/opam/{ocamlformat.0.20.1 → ocamlformat.0.24.1}/opam +12 -12
- binaryen-archive/esy.lock/opam/{odoc-parser.1.0.0 → odoc-parser.2.0.0}/opam +6 -5
- binaryen-archive/esy.lock/opam/omd.1.3.2/opam +50 -0
- binaryen-archive/esy.lock/opam/{ordering.3.3.1 → ordering.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{ppxlib.0.27.0 → ppxlib.0.28.0}/opam +5 -5
- binaryen-archive/esy.lock/opam/{sexplib0.v0.14.0 → sexplib0.v0.15.1}/opam +3 -3
- binaryen-archive/esy.lock/opam/{stdio.v0.14.0 → stdio.v0.15.0}/opam +4 -4
- binaryen-archive/esy.lock/opam/{stdune.3.3.1 → stdune.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{topkg.1.0.5 → topkg.1.0.6}/opam +22 -19
- binaryen-archive/esy.lock/opam/uucp.15.0.0/opam +55 -0
- binaryen-archive/esy.lock/opam/{uuseg.14.0.0 → uuseg.15.0.0}/opam +39 -25
- binaryen-archive/esy.lock/opam/{xdg.3.3.1 → xdg.3.6.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{yojson.2.0.0 → yojson.2.0.2}/opam +5 -5
- binaryen-archive/esy.lock/overrides/{opam__s__ocamlbuild_opam__c__0.14.1_opam_override → opam__s__ocamlbuild_opam__c__0.14.2_opam_override}/files/winpatch.patch +0 -0
- binaryen-archive/esy.lock/overrides/{opam__s__ocamlbuild_opam__c__0.14.1_opam_override → opam__s__ocamlbuild_opam__c__0.14.2_opam_override}/package.json +0 -0
- binaryen-archive/package.json +8 -8
- binaryen-archive/src/binaryen_stubs_expressions.c +43 -33
- binaryen-archive/src/binaryen_stubs_expressions.js +221 -42
- binaryen-archive/src/binaryen_stubs_features.c +6 -0
- binaryen-archive/src/binaryen_stubs_features.js +6 -0
- binaryen-archive/src/binaryen_stubs_heap_types.c +95 -0
- binaryen-archive/src/binaryen_stubs_heap_types.js +65 -0
- binaryen-archive/src/binaryen_stubs_imports.c +16 -0
- binaryen-archive/src/binaryen_stubs_imports.js +14 -0
- binaryen-archive/src/binaryen_stubs_memory.c +83 -4
- binaryen-archive/src/binaryen_stubs_memory.js +95 -5
- binaryen-archive/src/binaryen_stubs_modules.c +22 -0
- binaryen-archive/src/binaryen_stubs_modules.js +17 -0
- binaryen-archive/src/binaryen_stubs_packed_types.c +26 -0
- binaryen-archive/src/binaryen_stubs_packed_types.js +17 -0
- binaryen-archive/src/binaryen_stubs_type_system.c +40 -0
- binaryen-archive/src/binaryen_stubs_type_system.js +29 -0
- binaryen-archive/src/binaryen_stubs_types.c +44 -0
- binaryen-archive/src/binaryen_stubs_types.js +36 -0
- binaryen-archive/src/dune +35 -12
- binaryen-archive/src/expression.ml +21 -24
- binaryen-archive/src/expression.mli +9 -9
- binaryen-archive/src/heap_type.ml +15 -0
- binaryen-archive/src/heap_type.mli +12 -0
- binaryen-archive/src/import.ml +6 -0
- binaryen-archive/src/import.mli +2 -0
- binaryen-archive/src/memory.ml +24 -0
- binaryen-archive/src/memory.mli +10 -1
- binaryen-archive/src/module.ml +12 -0
- binaryen-archive/src/module.mli +3 -0
- binaryen-archive/src/ocaml_helpers.h +1 -0
- binaryen-archive/src/packed_type.ml +13 -0
- binaryen-archive/src/packed_type.mli +5 -0
- binaryen-archive/src/passes.ml +6 -0
- binaryen-archive/src/passes.mli +6 -0
- binaryen-archive/src/type.ml +19 -0
- binaryen-archive/src/type.mli +7 -0
- binaryen-archive/src/type_system.ml +7 -0
- binaryen-archive/src/type_system.mli +7 -0
- binaryen-archive/test/dune +19 -20
- binaryen-archive/test/test.expected +64 -4
- binaryen-archive/test/test.ml +49 -5
- binaryen-archive/esy.lock/opam/omd.1.3.1/opam +0 -39
- binaryen-archive/esy.lock/opam/uucp.14.0.0/opam +0 -41
- binaryen-archive/esy.lock/overrides/opam__s__js__of__ocaml_compiler_opam__c__4.0.0_opam_override/package.json +0 -3
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
//Provides: caml_binaryen_set_memory
|
|
2
2
|
//Requires: caml_list_to_js_array, caml_convert_bytes_to_array
|
|
3
3
|
//Requires: caml_jsstring_of_string, caml_js_from_bool
|
|
4
|
-
function caml_binaryen_set_memory(
|
|
4
|
+
function caml_binaryen_set_memory(
|
|
5
|
+
wasm_mod,
|
|
6
|
+
initial,
|
|
7
|
+
maximum,
|
|
8
|
+
exportName,
|
|
9
|
+
segments,
|
|
10
|
+
segmentPassives,
|
|
11
|
+
segmentOffsets,
|
|
12
|
+
segmentSizes,
|
|
13
|
+
shared,
|
|
14
|
+
memoryName
|
|
15
|
+
) {
|
|
5
16
|
var passives = caml_list_to_js_array(segmentPassives);
|
|
6
17
|
var offsets = caml_list_to_js_array(segmentOffsets);
|
|
7
18
|
var segs = caml_list_to_js_array(segments).map(function (segment, idx) {
|
|
8
19
|
return {
|
|
9
20
|
data: caml_convert_bytes_to_array(segment),
|
|
10
21
|
passive: caml_js_from_bool(passives[idx]),
|
|
11
|
-
offset: offsets[idx]
|
|
12
|
-
}
|
|
22
|
+
offset: offsets[idx],
|
|
23
|
+
};
|
|
13
24
|
});
|
|
14
25
|
|
|
15
26
|
return wasm_mod.setMemory(
|
|
@@ -17,11 +28,90 @@ function caml_binaryen_set_memory(wasm_mod, initial, maximum, exportName, segmen
|
|
|
17
28
|
maximum,
|
|
18
29
|
caml_jsstring_of_string(exportName),
|
|
19
30
|
segs,
|
|
20
|
-
caml_js_from_bool(shared)
|
|
31
|
+
caml_js_from_bool(shared),
|
|
32
|
+
caml_jsstring_of_string(memoryName)
|
|
21
33
|
);
|
|
22
34
|
}
|
|
23
35
|
//Provides: caml_binaryen_set_memory__bytecode
|
|
24
36
|
//Requires: caml_binaryen_set_memory
|
|
25
37
|
function caml_binaryen_set_memory__bytecode() {
|
|
26
|
-
return caml_binaryen_set_memory(
|
|
38
|
+
return caml_binaryen_set_memory(
|
|
39
|
+
arguments[0],
|
|
40
|
+
arguments[1],
|
|
41
|
+
arguments[2],
|
|
42
|
+
arguments[3],
|
|
43
|
+
arguments[4],
|
|
44
|
+
arguments[5],
|
|
45
|
+
arguments[6],
|
|
46
|
+
arguments[7],
|
|
47
|
+
arguments[8],
|
|
48
|
+
arguments[9]
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//Provides: caml_binaryen_has_memory
|
|
53
|
+
//Requires: caml_js_to_bool
|
|
54
|
+
function caml_binaryen_has_memory(mod) {
|
|
55
|
+
return caml_js_to_bool(mod.hasMemory());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//Provides: caml_binaryen_memory_get_initial
|
|
59
|
+
//Requires: caml_jsstring_of_string
|
|
60
|
+
function caml_binaryen_memory_get_initial(mod, memoryName) {
|
|
61
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
62
|
+
return memory_info.initial;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//Provides: caml_binaryen_memory_has_max
|
|
66
|
+
//Requires: caml_js_to_bool, caml_jsstring_of_string
|
|
67
|
+
function caml_binaryen_memory_has_max(mod, memoryName) {
|
|
68
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
69
|
+
if (memory_info.max != null) {
|
|
70
|
+
return caml_js_to_bool(true);
|
|
71
|
+
} else {
|
|
72
|
+
return caml_js_to_bool(false);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//Provides: caml_binaryen_memory_get_max
|
|
77
|
+
//Requires: caml_jsstring_of_string
|
|
78
|
+
function caml_binaryen_memory_get_max(mod, memoryName) {
|
|
79
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
80
|
+
if (memory_info.max != null) {
|
|
81
|
+
return memory_info.max;
|
|
82
|
+
} else {
|
|
83
|
+
// This ensures that our return is equal to Memory.unlimited
|
|
84
|
+
return -1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//Provides: caml_binaryen_memory_is_shared
|
|
89
|
+
//Requires: caml_js_to_bool, caml_jsstring_of_string
|
|
90
|
+
function caml_binaryen_memory_is_shared(mod, memoryName) {
|
|
91
|
+
var memory_info = mod.getMemoryInfo(caml_jsstring_of_string(memoryName));
|
|
92
|
+
return caml_js_to_bool(memory_info.shared);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//Provides: caml_binaryen_get_num_memory_segments
|
|
96
|
+
function caml_binaryen_get_num_memory_segments(wasm_mod) {
|
|
97
|
+
return wasm_mod.getNumMemorySegments();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//Provides: caml_binaryen_get_memory_segment_byte_offset
|
|
101
|
+
function caml_binaryen_get_memory_segment_byte_offset(wasm_mod, idx) {
|
|
102
|
+
var info = wasm_mod.getMemorySegmentInfoByIndex(idx);
|
|
103
|
+
return info.offset;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
//Provides: caml_binaryen_get_memory_segment_passive
|
|
107
|
+
function caml_binaryen_get_memory_segment_passive(wasm_mod, idx) {
|
|
108
|
+
var info = wasm_mod.getMemorySegmentInfoByIndex(idx);
|
|
109
|
+
return info.passive;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//Provides: caml_binaryen_get_memory_segment_data
|
|
113
|
+
//Requires: caml_bytes_of_array
|
|
114
|
+
function caml_binaryen_get_memory_segment_data(wasm_mod, idx) {
|
|
115
|
+
var info = wasm_mod.getMemorySegmentInfoByIndex(idx);
|
|
116
|
+
return caml_bytes_of_array(info.data);
|
|
27
117
|
}
|
|
@@ -52,6 +52,14 @@ caml_binaryen_module_print_asmjs(value module) {
|
|
|
52
52
|
CAMLreturn(Val_unit);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
CAMLprim value
|
|
56
|
+
caml_binaryen_module_print_stack_ir(value module, value _optimize) {
|
|
57
|
+
CAMLparam2(module, _optimize);
|
|
58
|
+
bool optimize = Bool_val(_optimize);
|
|
59
|
+
BinaryenModulePrintStackIR(BinaryenModuleRef_val(module), optimize);
|
|
60
|
+
CAMLreturn(Val_unit);
|
|
61
|
+
}
|
|
62
|
+
|
|
55
63
|
CAMLprim value
|
|
56
64
|
caml_binaryen_module_validate(value module) {
|
|
57
65
|
CAMLparam1(module);
|
|
@@ -125,6 +133,20 @@ caml_binaryen_module_write_text(value _module) {
|
|
|
125
133
|
CAMLreturn(text);
|
|
126
134
|
}
|
|
127
135
|
|
|
136
|
+
// There is something weird with this function that causes a bunch of newlines to
|
|
137
|
+
// be printed on stdout when calling it. Not sure if that's a bug in Binaryen.
|
|
138
|
+
CAMLprim value
|
|
139
|
+
caml_binaryen_module_write_stack_ir(value _module, value _optimize) {
|
|
140
|
+
CAMLparam2(_module, _optimize);
|
|
141
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
142
|
+
bool optimize = Bool_val(_optimize);
|
|
143
|
+
char* result = BinaryenModuleAllocateAndWriteStackIR(module, optimize);
|
|
144
|
+
CAMLlocal1(text);
|
|
145
|
+
text = caml_copy_string(result);
|
|
146
|
+
free(result);
|
|
147
|
+
CAMLreturn(text);
|
|
148
|
+
}
|
|
149
|
+
|
|
128
150
|
CAMLprim value
|
|
129
151
|
caml_binaryen_module_read(value _bytes) {
|
|
130
152
|
CAMLparam1(_bytes);
|
|
@@ -36,6 +36,16 @@ function caml_binaryen_module_print_asmjs(wasm_mod) {
|
|
|
36
36
|
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
//Provides: caml_binaryen_module_print_stack_ir
|
|
40
|
+
//Requires: caml_string_of_jsstring, caml_js_from_bool
|
|
41
|
+
//Requires: caml_ml_output, caml_ml_string_length
|
|
42
|
+
function caml_binaryen_module_print_stack_ir(wasm_mod, optimize) {
|
|
43
|
+
var stackir = wasm_mod.emitStackIR(caml_js_from_bool(optimize));
|
|
44
|
+
var chanid = 1; // stdout
|
|
45
|
+
var s = caml_string_of_jsstring(stackir);
|
|
46
|
+
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
47
|
+
}
|
|
48
|
+
|
|
39
49
|
//Provides: caml_binaryen_module_validate
|
|
40
50
|
function caml_binaryen_module_validate(wasm_mod) {
|
|
41
51
|
return wasm_mod.validate();
|
|
@@ -82,6 +92,13 @@ function caml_binaryen_module_write_text(wasm_mod) {
|
|
|
82
92
|
return caml_string_of_jsstring(text);
|
|
83
93
|
}
|
|
84
94
|
|
|
95
|
+
//Provides: caml_binaryen_module_write_stack_ir
|
|
96
|
+
//Requires: caml_string_of_jsstring, caml_js_from_bool
|
|
97
|
+
function caml_binaryen_module_write_stack_ir(wasm_mod, optimize) {
|
|
98
|
+
var text = wasm_mod.emitStackIR(caml_js_from_bool(optimize));
|
|
99
|
+
return caml_string_of_jsstring(text);
|
|
100
|
+
}
|
|
101
|
+
|
|
85
102
|
//Provides: caml_binaryen_module_read
|
|
86
103
|
//Requires: Binaryen
|
|
87
104
|
//Requires: caml_array_of_bytes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#define CAML_NAME_SPACE
|
|
2
|
+
#include <caml/mlvalues.h>
|
|
3
|
+
#include <caml/fail.h>
|
|
4
|
+
#include <caml/memory.h>
|
|
5
|
+
|
|
6
|
+
#include "binaryen-c.h"
|
|
7
|
+
#include "ocaml_helpers.h"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
CAMLprim value
|
|
11
|
+
caml_binaryen_packed_type_not_packed(value unit) {
|
|
12
|
+
CAMLparam1(unit);
|
|
13
|
+
CAMLreturn(Val_int(BinaryenPackedTypeNotPacked()));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
CAMLprim value
|
|
17
|
+
caml_binaryen_packed_type_int8(value unit) {
|
|
18
|
+
CAMLparam1(unit);
|
|
19
|
+
CAMLreturn(Val_int(BinaryenPackedTypeInt8()));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
CAMLprim value
|
|
23
|
+
caml_binaryen_packed_type_int16(value unit) {
|
|
24
|
+
CAMLparam1(unit);
|
|
25
|
+
CAMLreturn(Val_int(BinaryenPackedTypeInt16()));
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//Provides: caml_binaryen_packed_type_not_packed
|
|
2
|
+
//Requires: Binaryen
|
|
3
|
+
function caml_binaryen_packed_type_not_packed() {
|
|
4
|
+
return Binaryen._BinaryenPackedTypeNotPacked();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//Provides: caml_binaryen_packed_type_int8
|
|
8
|
+
//Requires: Binaryen
|
|
9
|
+
function caml_binaryen_packed_type_int8() {
|
|
10
|
+
return Binaryen._BinaryenPackedTypeInt8();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//Provides: caml_binaryen_packed_type_int16
|
|
14
|
+
//Requires: Binaryen
|
|
15
|
+
function caml_binaryen_packed_type_int16() {
|
|
16
|
+
return Binaryen._BinaryenPackedTypeInt16();
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#define CAML_NAME_SPACE
|
|
2
|
+
#include <caml/mlvalues.h>
|
|
3
|
+
#include <caml/fail.h>
|
|
4
|
+
#include <caml/memory.h>
|
|
5
|
+
|
|
6
|
+
#include "binaryen-c.h"
|
|
7
|
+
#include "ocaml_helpers.h"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
CAMLprim value
|
|
11
|
+
caml_binaryen_type_system_equirecursive(value unit) {
|
|
12
|
+
CAMLparam1(unit);
|
|
13
|
+
CAMLreturn(Val_int(BinaryenTypeSystemEquirecursive()));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
CAMLprim value
|
|
17
|
+
caml_binaryen_type_system_nominal(value unit) {
|
|
18
|
+
CAMLparam1(unit);
|
|
19
|
+
CAMLreturn(Val_int(BinaryenTypeSystemNominal()));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
CAMLprim value
|
|
23
|
+
caml_binaryen_type_system_isorecursive(value unit) {
|
|
24
|
+
CAMLparam1(unit);
|
|
25
|
+
CAMLreturn(Val_int(BinaryenTypeSystemIsorecursive()));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
CAMLprim value
|
|
29
|
+
caml_binaryen_get_type_system(value unit) {
|
|
30
|
+
CAMLparam1(unit);
|
|
31
|
+
CAMLreturn(Val_int(BinaryenGetTypeSystem()));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
CAMLprim value
|
|
35
|
+
caml_binaryen_set_type_system(value _typeSystem) {
|
|
36
|
+
CAMLparam1(_typeSystem);
|
|
37
|
+
BinaryenTypeSystem typeSystem = Int_val(_typeSystem);
|
|
38
|
+
BinaryenSetTypeSystem(typeSystem);
|
|
39
|
+
CAMLreturn(Val_unit);
|
|
40
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//Provides: caml_binaryen_type_system_equirecursive
|
|
2
|
+
//Requires: Binaryen
|
|
3
|
+
function caml_binaryen_type_system_equirecursive() {
|
|
4
|
+
return Binaryen._BinaryenTypeSystemEquirecursive();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//Provides: caml_binaryen_type_system_nominal
|
|
8
|
+
//Requires: Binaryen
|
|
9
|
+
function caml_binaryen_type_system_nominal() {
|
|
10
|
+
return Binaryen._BinaryenTypeSystemNominal();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//Provides: caml_binaryen_type_system_isorecursive
|
|
14
|
+
//Requires: Binaryen
|
|
15
|
+
function caml_binaryen_type_system_isorecursive() {
|
|
16
|
+
return Binaryen._BinaryenTypeSystemIsorecursive();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//Provides: caml_binaryen_get_type_system
|
|
20
|
+
//Requires: Binaryen
|
|
21
|
+
function caml_binaryen_get_type_system() {
|
|
22
|
+
return Binaryen._BinaryenGetTypeSystem();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//Provides: caml_binaryen_set_type_system
|
|
26
|
+
//Requires: Binaryen
|
|
27
|
+
function caml_binaryen_set_type_system(typeSystem) {
|
|
28
|
+
Binaryen._BinaryenSetTypeSystem(typeSystem);
|
|
29
|
+
}
|
|
@@ -93,6 +93,34 @@ caml_binaryen_type_dataref(value unit) {
|
|
|
93
93
|
CAMLreturn(alloc_BinaryenType(ty));
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
CAMLprim value
|
|
97
|
+
caml_binaryen_type_stringref(value unit) {
|
|
98
|
+
CAMLparam1(unit);
|
|
99
|
+
BinaryenType ty = BinaryenTypeStringref();
|
|
100
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
CAMLprim value
|
|
104
|
+
caml_binaryen_type_stringview_wtf8(value unit) {
|
|
105
|
+
CAMLparam1(unit);
|
|
106
|
+
BinaryenType ty = BinaryenTypeStringviewWTF8();
|
|
107
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
CAMLprim value
|
|
111
|
+
caml_binaryen_type_stringview_wtf16(value unit) {
|
|
112
|
+
CAMLparam1(unit);
|
|
113
|
+
BinaryenType ty = BinaryenTypeStringviewWTF16();
|
|
114
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
CAMLprim value
|
|
118
|
+
caml_binaryen_type_stringview_iter(value unit) {
|
|
119
|
+
CAMLparam1(unit);
|
|
120
|
+
BinaryenType ty = BinaryenTypeStringviewIter();
|
|
121
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
122
|
+
}
|
|
123
|
+
|
|
96
124
|
CAMLprim value
|
|
97
125
|
caml_binaryen_type_unreachable(value unit) {
|
|
98
126
|
CAMLparam1(unit);
|
|
@@ -136,3 +164,19 @@ caml_binaryen_type_expand(value _ty) {
|
|
|
136
164
|
|
|
137
165
|
CAMLreturn(typeArray);
|
|
138
166
|
}
|
|
167
|
+
|
|
168
|
+
CAMLprim value
|
|
169
|
+
caml_binaryen_type_is_nullable(value _ty) {
|
|
170
|
+
CAMLparam1(_ty);
|
|
171
|
+
BinaryenType ty = BinaryenType_val(_ty);
|
|
172
|
+
CAMLreturn(Val_bool(BinaryenTypeIsNullable(ty)));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
CAMLprim value
|
|
176
|
+
caml_binaryen_type_from_heap_type(value _ty, value _nullable) {
|
|
177
|
+
CAMLparam2(_ty, _nullable);
|
|
178
|
+
BinaryenHeapType heapTy = BinaryenHeapType_val(_ty);
|
|
179
|
+
bool nullable = Bool_val(_nullable);
|
|
180
|
+
BinaryenType ty = BinaryenTypeFromHeapType(heapTy, nullable);
|
|
181
|
+
CAMLreturn(alloc_BinaryenType(ty));
|
|
182
|
+
}
|
|
@@ -64,6 +64,30 @@ function caml_binaryen_type_dataref() {
|
|
|
64
64
|
return Binaryen.dataref;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
//Provides: caml_binaryen_type_stringref
|
|
68
|
+
//Requires: Binaryen
|
|
69
|
+
function caml_binaryen_type_stringref() {
|
|
70
|
+
return Binaryen.stringref;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//Provides: caml_binaryen_type_stringview_wtf8
|
|
74
|
+
//Requires: Binaryen
|
|
75
|
+
function caml_binaryen_type_stringview_wtf8() {
|
|
76
|
+
return Binaryen.stringview_wtf8;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
//Provides: caml_binaryen_type_stringview_wtf16
|
|
80
|
+
//Requires: Binaryen
|
|
81
|
+
function caml_binaryen_type_stringview_wtf16() {
|
|
82
|
+
return Binaryen.stringview_wtf16;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
//Provides: caml_binaryen_type_stringview_iter
|
|
86
|
+
//Requires: Binaryen
|
|
87
|
+
function caml_binaryen_type_stringview_iter() {
|
|
88
|
+
return Binaryen.stringview_iter;
|
|
89
|
+
}
|
|
90
|
+
|
|
67
91
|
//Provides: caml_binaryen_type_unreachable
|
|
68
92
|
//Requires: Binaryen
|
|
69
93
|
function caml_binaryen_type_unreachable() {
|
|
@@ -89,3 +113,15 @@ function caml_binaryen_type_create(typs) {
|
|
|
89
113
|
function caml_binaryen_type_expand(typ) {
|
|
90
114
|
return caml_js_to_array(Binaryen.expandType(typ));
|
|
91
115
|
}
|
|
116
|
+
|
|
117
|
+
//Provides: caml_binaryen_type_is_nullable
|
|
118
|
+
//Requires: Binaryen
|
|
119
|
+
function caml_binaryen_type_is_nullable(typ) {
|
|
120
|
+
return Binaryen._BinaryenTypeIsNullable(typ);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
//Provides: caml_binaryen_type_from_heap_type
|
|
124
|
+
//Requires: Binaryen
|
|
125
|
+
function caml_binaryen_type_from_heap_type(typ, nullable) {
|
|
126
|
+
return Binaryen._BinaryenTypeFromHeapType(typ, nullable);
|
|
127
|
+
}
|
binaryen-archive/src/dune
CHANGED
|
@@ -4,17 +4,40 @@
|
|
|
4
4
|
(libraries libbinaryen.c)
|
|
5
5
|
(foreign_stubs
|
|
6
6
|
(language c)
|
|
7
|
-
(names
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
(names
|
|
8
|
+
binaryen_stubs_types
|
|
9
|
+
binaryen_stubs_ops
|
|
10
|
+
binaryen_stubs_literals
|
|
11
|
+
binaryen_stubs_expressions
|
|
12
|
+
binaryen_stubs_functions
|
|
13
|
+
binaryen_stubs_imports
|
|
14
|
+
binaryen_stubs_exports
|
|
15
|
+
binaryen_stubs_globals
|
|
16
|
+
binaryen_stubs_tables
|
|
17
|
+
binaryen_stubs_memory
|
|
18
|
+
binaryen_stubs_features
|
|
19
|
+
binaryen_stubs_modules
|
|
20
|
+
binaryen_stubs_settings
|
|
21
|
+
binaryen_stubs_packed_types
|
|
22
|
+
binaryen_stubs_heap_types
|
|
23
|
+
binaryen_stubs_type_system
|
|
24
|
+
ocaml_helpers)
|
|
12
25
|
(flags :standard -O2 -Wall -Wextra))
|
|
13
26
|
(js_of_ocaml
|
|
14
|
-
(javascript_files
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
(javascript_files
|
|
28
|
+
binaryen_stubs_types.js
|
|
29
|
+
binaryen_stubs_ops.js
|
|
30
|
+
binaryen_stubs_literals.js
|
|
31
|
+
binaryen_stubs_expressions.js
|
|
32
|
+
binaryen_stubs_functions.js
|
|
33
|
+
binaryen_stubs_imports.js
|
|
34
|
+
binaryen_stubs_exports.js
|
|
35
|
+
binaryen_stubs_globals.js
|
|
36
|
+
binaryen_stubs_tables.js
|
|
37
|
+
binaryen_stubs_memory.js
|
|
38
|
+
binaryen_stubs_features.js
|
|
39
|
+
binaryen_stubs_modules.js
|
|
40
|
+
binaryen_stubs_settings.js
|
|
41
|
+
binaryen_stubs_packed_types.js
|
|
42
|
+
binaryen_stubs_heap_types.js
|
|
43
|
+
binaryen_stubs_type_system.js)))
|
|
@@ -57,8 +57,6 @@ type kind =
|
|
|
57
57
|
| RefTest
|
|
58
58
|
| RefCast
|
|
59
59
|
| BrOn
|
|
60
|
-
| RttCanon
|
|
61
|
-
| RttSub
|
|
62
60
|
| StructNew
|
|
63
61
|
| StructGet
|
|
64
62
|
| StructSet
|
|
@@ -310,14 +308,6 @@ external id_br_on : unit -> int = "caml_binaryen_expression_id_br_on"
|
|
|
310
308
|
|
|
311
309
|
let id_br_on = id_br_on ()
|
|
312
310
|
|
|
313
|
-
external id_rtt_canon : unit -> int = "caml_binaryen_expression_id_rtt_canon"
|
|
314
|
-
|
|
315
|
-
let id_rtt_canon = id_rtt_canon ()
|
|
316
|
-
|
|
317
|
-
external id_rtt_sub : unit -> int = "caml_binaryen_expression_id_rtt_sub"
|
|
318
|
-
|
|
319
|
-
let id_rtt_sub = id_rtt_sub ()
|
|
320
|
-
|
|
321
311
|
external id_struct_new : unit -> int = "caml_binaryen_expression_id_struct_new"
|
|
322
312
|
|
|
323
313
|
let id_struct_new = id_struct_new ()
|
|
@@ -409,8 +399,6 @@ let get_kind expr =
|
|
|
409
399
|
| n when n = id_ref_test -> RefTest
|
|
410
400
|
| n when n = id_ref_cast -> RefCast
|
|
411
401
|
| n when n = id_br_on -> BrOn
|
|
412
|
-
| n when n = id_rtt_canon -> RttCanon
|
|
413
|
-
| n when n = id_rtt_sub -> RttSub
|
|
414
402
|
| n when n = id_struct_new -> StructNew
|
|
415
403
|
| n when n = id_struct_get -> StructGet
|
|
416
404
|
| n when n = id_struct_set -> StructSet
|
|
@@ -630,10 +618,11 @@ module Global_set = struct
|
|
|
630
618
|
end
|
|
631
619
|
|
|
632
620
|
module Load = struct
|
|
633
|
-
external make :
|
|
621
|
+
external make :
|
|
622
|
+
Module.t -> int -> bool -> int -> int -> Type.t -> t -> string -> t
|
|
634
623
|
= "caml_binaryen_load__bytecode" "caml_binaryen_load"
|
|
635
624
|
|
|
636
|
-
(** Module, num_bytes, ?signed, offset, align, type, ptr
|
|
625
|
+
(** Module, num_bytes, ?signed, offset, align, type, ptr, memory_name *)
|
|
637
626
|
let make wasm_mod bytes ?(signed = false) offset align ty ptr =
|
|
638
627
|
make wasm_mod bytes signed offset align ty ptr
|
|
639
628
|
|
|
@@ -642,9 +631,10 @@ module Load = struct
|
|
|
642
631
|
end
|
|
643
632
|
|
|
644
633
|
module Store = struct
|
|
645
|
-
external make :
|
|
634
|
+
external make :
|
|
635
|
+
Module.t -> int -> int -> int -> t -> t -> Type.t -> string -> t
|
|
646
636
|
= "caml_binaryen_store__bytecode" "caml_binaryen_store"
|
|
647
|
-
(** Module, num_bytes, offset, align, ptr, value, type
|
|
637
|
+
(** Module, num_bytes, offset, align, ptr, value, type, memory_name *)
|
|
648
638
|
|
|
649
639
|
external get_ptr : t -> t = "caml_binaryen_store_get_ptr"
|
|
650
640
|
external set_ptr : t -> t -> unit = "caml_binaryen_store_set_ptr"
|
|
@@ -698,18 +688,23 @@ module Return = struct
|
|
|
698
688
|
end
|
|
699
689
|
|
|
700
690
|
module Memory_size = struct
|
|
701
|
-
external make : Module.t -> t = "caml_binaryen_memory_size"
|
|
691
|
+
external make : Module.t -> string -> bool -> t = "caml_binaryen_memory_size"
|
|
692
|
+
(** Module, memory_name, memory_is_64 *)
|
|
702
693
|
end
|
|
703
694
|
|
|
704
695
|
module Memory_grow = struct
|
|
705
|
-
external make : Module.t -> t ->
|
|
696
|
+
external make : Module.t -> t -> string -> bool -> t
|
|
697
|
+
= "caml_binaryen_memory_grow"
|
|
698
|
+
(** Module, delta, memory_name, memory_is_64 *)
|
|
699
|
+
|
|
706
700
|
external get_delta : t -> t = "caml_binaryen_memory_grow_get_delta"
|
|
707
701
|
external set_delta : t -> t -> unit = "caml_binaryen_memory_grow_set_delta"
|
|
708
702
|
end
|
|
709
703
|
|
|
710
704
|
module Memory_init = struct
|
|
711
|
-
external make : Module.t -> int -> t -> t -> t
|
|
712
|
-
|
|
705
|
+
external make : Module.t -> int -> t -> t -> t -> string -> t
|
|
706
|
+
= "caml_binaryen_memory_init__bytecode" "caml_binaryen_memory_init"
|
|
707
|
+
(** Module, segment, destination, offset, size, memory_name *)
|
|
713
708
|
|
|
714
709
|
external get_segment : t -> int = "caml_binaryen_memory_init_get_segment"
|
|
715
710
|
|
|
@@ -735,8 +730,9 @@ module Data_drop = struct
|
|
|
735
730
|
end
|
|
736
731
|
|
|
737
732
|
module Memory_copy = struct
|
|
738
|
-
external make : Module.t -> t -> t -> t ->
|
|
739
|
-
|
|
733
|
+
external make : Module.t -> t -> t -> t -> string -> string -> t
|
|
734
|
+
= "caml_binaryen_memory_copy__bytecode" "caml_binaryen_memory_copy"
|
|
735
|
+
(** Module, destination, source, size, dest_memory, source_memory *)
|
|
740
736
|
|
|
741
737
|
external get_dest : t -> t = "caml_binaryen_memory_copy_get_dest"
|
|
742
738
|
external set_dest : t -> t -> unit = "caml_binaryen_memory_copy_set_dest"
|
|
@@ -747,8 +743,9 @@ module Memory_copy = struct
|
|
|
747
743
|
end
|
|
748
744
|
|
|
749
745
|
module Memory_fill = struct
|
|
750
|
-
external make : Module.t -> t -> t -> t ->
|
|
751
|
-
|
|
746
|
+
external make : Module.t -> t -> t -> t -> string -> t
|
|
747
|
+
= "caml_binaryen_memory_fill"
|
|
748
|
+
(** Module, destination, value, size, memory_name *)
|
|
752
749
|
|
|
753
750
|
external get_dest : t -> t = "caml_binaryen_memory_fill_get_dest"
|
|
754
751
|
external set_dest : t -> t -> unit = "caml_binaryen_memory_fill_set_dest"
|
|
@@ -57,8 +57,6 @@ type kind =
|
|
|
57
57
|
| RefTest
|
|
58
58
|
| RefCast
|
|
59
59
|
| BrOn
|
|
60
|
-
| RttCanon
|
|
61
|
-
| RttSub
|
|
62
60
|
| StructNew
|
|
63
61
|
| StructGet
|
|
64
62
|
| StructSet
|
|
@@ -192,13 +190,15 @@ module Global_set : sig
|
|
|
192
190
|
end
|
|
193
191
|
|
|
194
192
|
module Load : sig
|
|
195
|
-
val make :
|
|
193
|
+
val make :
|
|
194
|
+
Module.t -> int -> ?signed:bool -> int -> int -> Type.t -> t -> string -> t
|
|
195
|
+
|
|
196
196
|
val get_ptr : t -> t
|
|
197
197
|
val set_ptr : t -> t -> unit
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
module Store : sig
|
|
201
|
-
val make : Module.t -> int -> int -> int -> t -> t -> Type.t -> t
|
|
201
|
+
val make : Module.t -> int -> int -> int -> t -> t -> Type.t -> string -> t
|
|
202
202
|
val get_ptr : t -> t
|
|
203
203
|
val set_ptr : t -> t -> unit
|
|
204
204
|
val get_value : t -> t
|
|
@@ -246,17 +246,17 @@ module Return : sig
|
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
module Memory_size : sig
|
|
249
|
-
val make : Module.t -> t
|
|
249
|
+
val make : Module.t -> string -> bool -> t
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
module Memory_grow : sig
|
|
253
|
-
val make : Module.t -> t -> t
|
|
253
|
+
val make : Module.t -> t -> string -> bool -> t
|
|
254
254
|
val get_delta : t -> t
|
|
255
255
|
val set_delta : t -> t -> unit
|
|
256
256
|
end
|
|
257
257
|
|
|
258
258
|
module Memory_init : sig
|
|
259
|
-
val make : Module.t -> int -> t -> t -> t
|
|
259
|
+
val make : Module.t -> int -> t -> t -> t -> string -> t
|
|
260
260
|
val get_segment : t -> int
|
|
261
261
|
val set_segment : t -> int -> unit
|
|
262
262
|
val get_dest : t -> t
|
|
@@ -274,7 +274,7 @@ module Data_drop : sig
|
|
|
274
274
|
end
|
|
275
275
|
|
|
276
276
|
module Memory_copy : sig
|
|
277
|
-
val make : Module.t -> t -> t -> t -> t
|
|
277
|
+
val make : Module.t -> t -> t -> t -> string -> string -> t
|
|
278
278
|
val get_dest : t -> t
|
|
279
279
|
val set_dest : t -> t -> unit
|
|
280
280
|
val get_source : t -> t
|
|
@@ -284,7 +284,7 @@ module Memory_copy : sig
|
|
|
284
284
|
end
|
|
285
285
|
|
|
286
286
|
module Memory_fill : sig
|
|
287
|
-
val make : Module.t -> t -> t -> t -> t
|
|
287
|
+
val make : Module.t -> t -> t -> t -> string -> t
|
|
288
288
|
val get_dest : t -> t
|
|
289
289
|
val set_dest : t -> t -> unit
|
|
290
290
|
val get_value : t -> t
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type t
|
|
2
|
+
|
|
3
|
+
external ext : unit -> t = "caml_binaryen_heap_type_ext"
|
|
4
|
+
external func : unit -> t = "caml_binaryen_heap_type_func"
|
|
5
|
+
external any : unit -> t = "caml_binaryen_heap_type_any"
|
|
6
|
+
external eq : unit -> t = "caml_binaryen_heap_type_eq"
|
|
7
|
+
external i31 : unit -> t = "caml_binaryen_heap_type_i31"
|
|
8
|
+
external data : unit -> t = "caml_binaryen_heap_type_data"
|
|
9
|
+
external string : unit -> t = "caml_binaryen_heap_type_string"
|
|
10
|
+
external stringview_wtf8 : unit -> t = "caml_binaryen_heap_type_stringview_wtf8"
|
|
11
|
+
|
|
12
|
+
external stringview_wtf16 : unit -> t
|
|
13
|
+
= "caml_binaryen_heap_type_stringview_wtf16"
|
|
14
|
+
|
|
15
|
+
external stringview_iter : unit -> t = "caml_binaryen_heap_type_stringview_iter"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type t
|
|
2
|
+
|
|
3
|
+
val ext : unit -> t
|
|
4
|
+
val func : unit -> t
|
|
5
|
+
val any : unit -> t
|
|
6
|
+
val eq : unit -> t
|
|
7
|
+
val i31 : unit -> t
|
|
8
|
+
val data : unit -> t
|
|
9
|
+
val string : unit -> t
|
|
10
|
+
val stringview_wtf8 : unit -> t
|
|
11
|
+
val stringview_wtf16 : unit -> t
|
|
12
|
+
val stringview_iter : unit -> t
|
binaryen-archive/src/import.ml
CHANGED
|
@@ -20,11 +20,17 @@ external add_global_import :
|
|
|
20
20
|
external function_import_get_module : Function.t -> string
|
|
21
21
|
= "caml_binaryen_function_import_get_module"
|
|
22
22
|
|
|
23
|
+
external memory_import_get_module : Module.t -> string -> string
|
|
24
|
+
= "caml_binaryen_memory_import_get_module"
|
|
25
|
+
|
|
23
26
|
external global_import_get_module : Global.t -> string
|
|
24
27
|
= "caml_binaryen_global_import_get_module"
|
|
25
28
|
|
|
26
29
|
external function_import_get_base : Function.t -> string
|
|
27
30
|
= "caml_binaryen_function_import_get_base"
|
|
28
31
|
|
|
32
|
+
external memory_import_get_base : Module.t -> string -> string
|
|
33
|
+
= "caml_binaryen_memory_import_get_base"
|
|
34
|
+
|
|
29
35
|
external global_import_get_base : Global.t -> string
|
|
30
36
|
= "caml_binaryen_global_import_get_base"
|