@grain/binaryen.ml 0.9.0 → 0.11.1
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/.gitignore +1 -0
- binaryen-archive/CHANGELOG.md +73 -0
- binaryen-archive/README.md +27 -3
- binaryen-archive/binaryen.opam +8 -8
- binaryen-archive/esy.lock/index.json +537 -460
- binaryen-archive/esy.lock/opam/{base.v0.14.1 → base.v0.14.2}/opam +4 -4
- binaryen-archive/esy.lock/opam/biniou.1.2.1/opam +1 -1
- binaryen-archive/esy.lock/opam/{cppo.1.6.7 → cppo.1.6.8}/opam +4 -6
- binaryen-archive/esy.lock/opam/{csexp.1.4.0 → csexp.1.5.1}/opam +11 -9
- binaryen-archive/esy.lock/opam/{dune-build-info.2.8.2 → dune-build-info.2.9.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-configurator.2.8.2 → dune-configurator.2.9.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune.2.8.2 → dune.2.9.1}/opam +4 -4
- binaryen-archive/esy.lock/opam/easy-format.1.3.2/opam +1 -1
- binaryen-archive/esy.lock/opam/{fix.20201120 → fix.20211231}/opam +7 -5
- binaryen-archive/esy.lock/opam/js_of_ocaml-compiler.3.11.0/opam +54 -0
- binaryen-archive/esy.lock/opam/js_of_ocaml-ppx.3.11.0/opam +44 -0
- binaryen-archive/esy.lock/opam/js_of_ocaml.3.11.0/opam +45 -0
- binaryen-archive/esy.lock/opam/{menhir.20201216 → menhir.20211128}/opam +8 -6
- binaryen-archive/esy.lock/opam/{menhirLib.20201216 → menhirLib.20211128}/opam +8 -6
- binaryen-archive/esy.lock/opam/{menhirSdk.20201216 → menhirSdk.20211128}/opam +8 -6
- binaryen-archive/esy.lock/opam/ocaml-compiler-libs.v0.12.4/opam +39 -0
- binaryen-archive/esy.lock/opam/{ocaml-lsp-server.1.4.0 → ocaml-lsp-server.1.9.0}/opam +15 -12
- binaryen-archive/esy.lock/opam/{ocaml-migrate-parsetree.2.1.0 → ocaml-migrate-parsetree.2.3.0}/opam +13 -10
- binaryen-archive/esy.lock/opam/ocaml-version.3.4.0/opam +49 -0
- binaryen-archive/esy.lock/opam/ocamlbuild.0.14.0/opam +1 -1
- binaryen-archive/esy.lock/opam/{ocamlfind.1.8.1 → ocamlfind.1.9.1}/opam +19 -39
- binaryen-archive/esy.lock/opam/ocamlformat-rpc-lib.0.19.0/opam +40 -0
- binaryen-archive/esy.lock/opam/ocamlformat.0.18.0/opam +56 -0
- binaryen-archive/esy.lock/opam/{odoc.1.5.2 → odoc.1.5.3}/opam +12 -12
- binaryen-archive/esy.lock/opam/pp.1.1.2/opam +58 -0
- binaryen-archive/esy.lock/opam/ppx_derivers.1.2.1/opam +1 -1
- binaryen-archive/esy.lock/opam/ppx_yojson_conv_lib.v0.14.0/opam +2 -2
- binaryen-archive/esy.lock/opam/{ppxlib.0.21.0 → ppxlib.0.22.2}/opam +40 -32
- binaryen-archive/esy.lock/opam/{re.1.9.0 → re.1.10.3}/opam +8 -4
- binaryen-archive/esy.lock/opam/result.1.5/opam +2 -2
- binaryen-archive/esy.lock/opam/sexplib0.v0.14.0/opam +2 -2
- binaryen-archive/esy.lock/opam/spawn.v0.15.0/opam +56 -0
- binaryen-archive/esy.lock/opam/stdio.v0.14.0/opam +2 -2
- binaryen-archive/esy.lock/opam/{topkg.1.0.3 → topkg.1.0.4}/opam +18 -22
- binaryen-archive/esy.lock/opam/tyxml.4.5.0/opam +42 -0
- binaryen-archive/esy.lock/opam/uucp.14.0.0/opam +41 -0
- binaryen-archive/esy.lock/opam/{uuseg.13.0.0 → uuseg.14.0.0}/opam +22 -28
- binaryen-archive/esy.lock/opam/yojson.1.7.0/opam +1 -1
- binaryen-archive/esy.lock/overrides/{opam__s__ocamlfind_opam__c__1.8.1_opam_override/files/findlib-1.8.1.patch → 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 → opam__s__ocamlfind_opam__c__1.9.1_opam_override}/package.json +1 -1
- binaryen-archive/js/binaryen.es5.js +5 -0
- binaryen-archive/js/dune +1 -6
- binaryen-archive/js/element_segment.ml +33 -0
- binaryen-archive/js/export.ml +37 -0
- binaryen-archive/js/expression.ml +935 -177
- binaryen-archive/js/function.ml +31 -0
- binaryen-archive/js/global.ml +29 -0
- binaryen-archive/js/import.ml +24 -0
- binaryen-archive/js/literal.ml +8 -4
- binaryen-archive/js/module.ml +42 -46
- binaryen-archive/js/op.ml +9 -78
- binaryen-archive/js/settings.ml +60 -0
- binaryen-archive/js/table.ml +20 -3
- binaryen-archive/js/type.ml +3 -0
- binaryen-archive/package.json +14 -20
- binaryen-archive/src/binaryen_stubs_exports.c +78 -0
- binaryen-archive/src/binaryen_stubs_expressions.c +1300 -0
- binaryen-archive/src/binaryen_stubs_features.c +7 -0
- binaryen-archive/src/binaryen_stubs_functions.c +78 -0
- binaryen-archive/src/binaryen_stubs_globals.c +63 -0
- binaryen-archive/src/binaryen_stubs_imports.c +29 -0
- binaryen-archive/src/binaryen_stubs_memory.c +1 -1
- binaryen-archive/src/binaryen_stubs_modules.c +0 -122
- binaryen-archive/src/binaryen_stubs_ops.c +19 -173
- binaryen-archive/src/binaryen_stubs_settings.c +145 -0
- binaryen-archive/src/binaryen_stubs_tables.c +121 -7
- binaryen-archive/src/binaryen_stubs_types.c +18 -0
- binaryen-archive/src/dune +5 -44
- binaryen-archive/src/element_segment.ml +13 -0
- binaryen-archive/src/export.ml +33 -0
- binaryen-archive/src/expression.ml +805 -76
- binaryen-archive/src/function.ml +18 -0
- binaryen-archive/src/global.ml +14 -0
- binaryen-archive/src/import.ml +12 -0
- binaryen-archive/src/literal.ml +2 -2
- binaryen-archive/src/module.ml +64 -38
- binaryen-archive/src/ocaml_helpers.c +0 -8
- binaryen-archive/src/ocaml_helpers.h +2 -3
- binaryen-archive/src/op.ml +18 -131
- binaryen-archive/src/settings.ml +45 -0
- binaryen-archive/src/table.ml +26 -4
- binaryen-archive/src/type.ml +2 -0
- binaryen-archive/test/config/dune +8 -0
- binaryen-archive/test/config/ocamlopt_flags.ml +16 -0
- binaryen-archive/test/dune +4 -0
- binaryen-archive/test/test.expected +38 -3
- binaryen-archive/test/test.ml +90 -18
- binaryen-archive/virtual/dune +2 -2
- binaryen-archive/virtual/element_segment.mli +11 -0
- binaryen-archive/virtual/export.mli +22 -0
- binaryen-archive/virtual/expression.mli +389 -34
- binaryen-archive/virtual/function.mli +16 -0
- binaryen-archive/virtual/global.mli +12 -0
- binaryen-archive/virtual/import.mli +8 -0
- binaryen-archive/virtual/literal.mli +2 -2
- binaryen-archive/virtual/module.mli +25 -27
- binaryen-archive/virtual/op.mli +9 -53
- binaryen-archive/virtual/settings.mli +35 -0
- binaryen-archive/virtual/table.mli +19 -2
- binaryen-archive/virtual/type.mli +2 -0
- 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/features.ml +0 -27
- binaryen-archive/js/function_table.ml +0 -13
- binaryen-archive/src/binaryen_stubs_function_tables.c +0 -25
- binaryen-archive/src/config/dune +0 -8
- binaryen-archive/src/config/library_flags.ml +0 -16
- binaryen-archive/src/features.ml +0 -49
- binaryen-archive/src/function_table.ml +0 -6
- 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/features.mli +0 -23
- binaryen-archive/virtual/function_table.mli +0 -4
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#define CAML_NAME_SPACE
|
|
2
|
+
#include <caml/mlvalues.h>
|
|
3
|
+
#include <caml/alloc.h>
|
|
4
|
+
#include <caml/fail.h>
|
|
5
|
+
#include <caml/memory.h>
|
|
6
|
+
|
|
7
|
+
#include "binaryen-c.h"
|
|
8
|
+
#include "ocaml_helpers.h"
|
|
9
|
+
|
|
10
|
+
CAMLprim value
|
|
11
|
+
caml_binaryen_get_optimize_level(value unit) {
|
|
12
|
+
CAMLparam1(unit);
|
|
13
|
+
int res = BinaryenGetOptimizeLevel();
|
|
14
|
+
CAMLreturn(Val_int(res));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
CAMLprim value
|
|
18
|
+
caml_binaryen_set_optimize_level(value _level) {
|
|
19
|
+
CAMLparam1(_level);
|
|
20
|
+
int level = Int_val(_level);
|
|
21
|
+
BinaryenSetOptimizeLevel(level);
|
|
22
|
+
CAMLreturn(Val_unit);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
CAMLprim value
|
|
26
|
+
caml_binaryen_get_shrink_level(value unit) {
|
|
27
|
+
CAMLparam1(unit);
|
|
28
|
+
int res = BinaryenGetShrinkLevel();
|
|
29
|
+
CAMLreturn(Val_int(res));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
CAMLprim value
|
|
33
|
+
caml_binaryen_set_shrink_level(value _level) {
|
|
34
|
+
CAMLparam1(_level);
|
|
35
|
+
int level = Int_val(_level);
|
|
36
|
+
BinaryenSetShrinkLevel(level);
|
|
37
|
+
CAMLreturn(Val_unit);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
CAMLprim value
|
|
41
|
+
caml_binaryen_get_debug_info(value unit) {
|
|
42
|
+
CAMLparam1(unit);
|
|
43
|
+
bool res = BinaryenGetDebugInfo();
|
|
44
|
+
CAMLreturn(Val_bool(res));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
CAMLprim value
|
|
48
|
+
caml_binaryen_set_debug_info(value _on) {
|
|
49
|
+
CAMLparam1(_on);
|
|
50
|
+
bool on = Bool_val(_on);
|
|
51
|
+
BinaryenSetDebugInfo(on);
|
|
52
|
+
CAMLreturn(Val_unit);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
CAMLprim value
|
|
56
|
+
caml_binaryen_get_low_memory_unused(value unit) {
|
|
57
|
+
CAMLparam1(unit);
|
|
58
|
+
bool res = BinaryenGetLowMemoryUnused();
|
|
59
|
+
CAMLreturn(Val_bool(res));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
CAMLprim value
|
|
63
|
+
caml_binaryen_set_low_memory_unused(value _on) {
|
|
64
|
+
CAMLparam1(_on);
|
|
65
|
+
bool on = Bool_val(_on);
|
|
66
|
+
BinaryenSetLowMemoryUnused(on);
|
|
67
|
+
CAMLreturn(Val_unit);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
CAMLprim value
|
|
71
|
+
caml_binaryen_get_pass_argument(value _name) {
|
|
72
|
+
CAMLparam1(_name);
|
|
73
|
+
const char* name = Safe_String_val(_name);
|
|
74
|
+
const char* val = BinaryenGetPassArgument(name);
|
|
75
|
+
CAMLreturn(caml_copy_string(val));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
CAMLprim value
|
|
79
|
+
caml_binaryen_set_pass_argument(value _name, value _val) {
|
|
80
|
+
CAMLparam2(_name, _val);
|
|
81
|
+
const char* name = Safe_String_val(_name);
|
|
82
|
+
const char* val = Safe_String_val(_val);
|
|
83
|
+
BinaryenSetPassArgument(name, val);
|
|
84
|
+
CAMLreturn(Val_unit);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
CAMLprim value
|
|
88
|
+
caml_binaryen_get_always_inline_max_size(value unit) {
|
|
89
|
+
CAMLparam1(unit);
|
|
90
|
+
int res = BinaryenGetAlwaysInlineMaxSize();
|
|
91
|
+
CAMLreturn(Val_int(res));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
CAMLprim value
|
|
95
|
+
caml_binaryen_set_always_inline_max_size(value _size) {
|
|
96
|
+
CAMLparam1(_size);
|
|
97
|
+
int size = Int_val(_size);
|
|
98
|
+
BinaryenSetAlwaysInlineMaxSize(size);
|
|
99
|
+
CAMLreturn(Val_unit);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
CAMLprim value
|
|
103
|
+
caml_binaryen_get_flexible_inline_max_size(value unit) {
|
|
104
|
+
CAMLparam1(unit);
|
|
105
|
+
int res = BinaryenGetFlexibleInlineMaxSize();
|
|
106
|
+
CAMLreturn(Val_int(res));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
CAMLprim value
|
|
110
|
+
caml_binaryen_set_flexible_inline_max_size(value _size) {
|
|
111
|
+
CAMLparam1(_size);
|
|
112
|
+
int size = Int_val(_size);
|
|
113
|
+
BinaryenSetFlexibleInlineMaxSize(size);
|
|
114
|
+
CAMLreturn(Val_unit);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
CAMLprim value
|
|
118
|
+
caml_binaryen_get_one_caller_inline_max_size(value unit) {
|
|
119
|
+
CAMLparam1(unit);
|
|
120
|
+
int res = BinaryenGetOneCallerInlineMaxSize();
|
|
121
|
+
CAMLreturn(Val_int(res));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
CAMLprim value
|
|
125
|
+
caml_binaryen_set_one_caller_inline_max_size(value _size) {
|
|
126
|
+
CAMLparam1(_size);
|
|
127
|
+
int size = Int_val(_size);
|
|
128
|
+
BinaryenSetOneCallerInlineMaxSize(size);
|
|
129
|
+
CAMLreturn(Val_unit);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
CAMLprim value
|
|
133
|
+
caml_binaryen_set_colors_enabled(value _on) {
|
|
134
|
+
CAMLparam1(_on);
|
|
135
|
+
bool on = Bool_val(_on);
|
|
136
|
+
BinaryenSetColorsEnabled(on);
|
|
137
|
+
CAMLreturn(Val_unit);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
CAMLprim value
|
|
141
|
+
caml_binaryen_are_colors_enabled(value unit) {
|
|
142
|
+
CAMLparam1(unit);
|
|
143
|
+
bool res = BinaryenAreColorsEnabled();
|
|
144
|
+
CAMLreturn(Val_bool(res));
|
|
145
|
+
}
|
|
@@ -2,19 +2,52 @@
|
|
|
2
2
|
#include <caml/mlvalues.h>
|
|
3
3
|
#include <caml/fail.h>
|
|
4
4
|
#include <caml/memory.h>
|
|
5
|
+
#include <caml/alloc.h>
|
|
5
6
|
|
|
6
7
|
#include "binaryen-c.h"
|
|
7
8
|
#include "ocaml_helpers.h"
|
|
8
9
|
|
|
9
10
|
|
|
11
|
+
/* Allocating an OCaml custom block to hold the given BinaryenTableRef */
|
|
12
|
+
static value alloc_BinaryenTableRef(BinaryenTableRef table)
|
|
13
|
+
{
|
|
14
|
+
value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenTableRef), 0, 1);
|
|
15
|
+
BinaryenTableRef_val(v) = table;
|
|
16
|
+
return v;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Allocating an OCaml custom block to hold the given BinaryenElementSegmentRef */
|
|
20
|
+
static value alloc_BinaryenElementSegmentRef(BinaryenElementSegmentRef elem)
|
|
21
|
+
{
|
|
22
|
+
value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenElementSegmentRef), 0, 1);
|
|
23
|
+
BinaryenElementSegmentRef_val(v) = elem;
|
|
24
|
+
return v;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Allocating an OCaml custom block to hold the given BinaryenExpressionRef */
|
|
28
|
+
static value alloc_BinaryenExpressionRef(BinaryenExpressionRef exp)
|
|
29
|
+
{
|
|
30
|
+
value v = caml_alloc_custom(&binaryen_ops, sizeof(BinaryenExpressionRef), 0, 1);
|
|
31
|
+
BinaryenExpressionRef_val(v) = exp;
|
|
32
|
+
return v;
|
|
33
|
+
}
|
|
34
|
+
|
|
10
35
|
CAMLprim value
|
|
11
|
-
caml_binaryen_add_table(value _module, value
|
|
12
|
-
|
|
13
|
-
CAMLxparam1(_offset);
|
|
36
|
+
caml_binaryen_add_table(value _module, value _table, value _initial, value _maximum) {
|
|
37
|
+
CAMLparam4(_module, _table, _initial, _maximum);
|
|
14
38
|
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
15
|
-
char*
|
|
39
|
+
char* table = Safe_String_val(_table);
|
|
16
40
|
BinaryenIndex initial = Int_val(_initial);
|
|
17
41
|
BinaryenIndex maximum = Int_val(_maximum);
|
|
42
|
+
CAMLreturn(alloc_BinaryenTableRef(BinaryenAddTable(module, table, initial, maximum)));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
CAMLprim value
|
|
46
|
+
caml_binaryen_add_active_element_segment(value _module, value _table, value _name, value _funcnames, value _offset) {
|
|
47
|
+
CAMLparam5(_module, _table, _name, _funcnames, _offset);
|
|
48
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
49
|
+
char* table = Safe_String_val(_table);
|
|
50
|
+
char* name = Safe_String_val(_name);
|
|
18
51
|
_funcnames = array_of_list(_funcnames);
|
|
19
52
|
int funcnamesLen = array_length(_funcnames);
|
|
20
53
|
const char* funcnames[funcnamesLen];
|
|
@@ -22,10 +55,91 @@ caml_binaryen_add_table(value _module, value _name, value _initial, value _maxim
|
|
|
22
55
|
funcnames[i] = Safe_String_val(Field(_funcnames, i));
|
|
23
56
|
}
|
|
24
57
|
BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
|
|
25
|
-
|
|
58
|
+
CAMLreturn(alloc_BinaryenElementSegmentRef(BinaryenAddActiveElementSegment(module, table, name, funcnames, funcnamesLen, offset)));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
CAMLprim value
|
|
62
|
+
caml_binaryen_remove_element_segment(value _module, value _name) {
|
|
63
|
+
CAMLparam2(_module, _name);
|
|
64
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
65
|
+
char* name = Safe_String_val(_name);
|
|
66
|
+
BinaryenRemoveElementSegment(module, name);
|
|
67
|
+
CAMLreturn(Val_unit);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
CAMLprim value
|
|
71
|
+
caml_binaryen_get_num_element_segments(value _module) {
|
|
72
|
+
CAMLparam1(_module);
|
|
73
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
74
|
+
CAMLreturn(Val_int(BinaryenGetNumElementSegments(module)));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
CAMLprim value
|
|
78
|
+
caml_binaryen_get_element_segment(value _module, value _name) {
|
|
79
|
+
CAMLparam2(_module, _name);
|
|
80
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
81
|
+
char* name = Safe_String_val(_name);
|
|
82
|
+
CAMLreturn(alloc_BinaryenElementSegmentRef(BinaryenGetElementSegment(module, name)));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
CAMLprim value
|
|
86
|
+
caml_binaryen_get_element_segment_by_index(value _module, value _index) {
|
|
87
|
+
CAMLparam2(_module, _index);
|
|
88
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
89
|
+
BinaryenIndex index = Int_val(_index);
|
|
90
|
+
CAMLreturn(alloc_BinaryenElementSegmentRef(BinaryenGetElementSegmentByIndex(module, index)));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
CAMLprim value
|
|
94
|
+
caml_binaryen_element_segment_get_name(value _elem) {
|
|
95
|
+
CAMLparam1(_elem);
|
|
96
|
+
BinaryenElementSegmentRef elem = BinaryenElementSegmentRef_val(_elem);
|
|
97
|
+
CAMLreturn(caml_copy_string(BinaryenElementSegmentGetName(elem)));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
CAMLprim value
|
|
101
|
+
caml_binaryen_element_segment_set_name(value _elem, value _name) {
|
|
102
|
+
CAMLparam2(_elem, _name);
|
|
103
|
+
BinaryenElementSegmentRef elem = BinaryenElementSegmentRef_val(_elem);
|
|
104
|
+
char* name = Safe_String_val(_name);
|
|
105
|
+
BinaryenElementSegmentSetName(elem, name);
|
|
106
|
+
CAMLreturn(Val_unit);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
CAMLprim value
|
|
110
|
+
caml_binaryen_element_segment_get_table(value _elem) {
|
|
111
|
+
CAMLparam1(_elem);
|
|
112
|
+
BinaryenElementSegmentRef elem = BinaryenElementSegmentRef_val(_elem);
|
|
113
|
+
CAMLreturn(caml_copy_string(BinaryenElementSegmentGetTable(elem)));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
CAMLprim value
|
|
117
|
+
caml_binaryen_element_segment_set_table(value _elem, value _table) {
|
|
118
|
+
CAMLparam2(_elem, _table);
|
|
119
|
+
BinaryenElementSegmentRef elem = BinaryenElementSegmentRef_val(_elem);
|
|
120
|
+
char* table = Safe_String_val(_table);
|
|
121
|
+
BinaryenElementSegmentSetTable(elem, table);
|
|
26
122
|
CAMLreturn(Val_unit);
|
|
27
123
|
}
|
|
124
|
+
|
|
125
|
+
CAMLprim value
|
|
126
|
+
caml_binaryen_element_segment_get_offset(value _elem) {
|
|
127
|
+
CAMLparam1(_elem);
|
|
128
|
+
BinaryenElementSegmentRef elem = BinaryenElementSegmentRef_val(_elem);
|
|
129
|
+
CAMLreturn(alloc_BinaryenExpressionRef(BinaryenElementSegmentGetOffset(elem)));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
CAMLprim value
|
|
133
|
+
caml_binaryen_element_segment_get_length(value _elem) {
|
|
134
|
+
CAMLparam1(_elem);
|
|
135
|
+
BinaryenElementSegmentRef elem = BinaryenElementSegmentRef_val(_elem);
|
|
136
|
+
CAMLreturn(Val_int(BinaryenElementSegmentGetLength(elem)));
|
|
137
|
+
}
|
|
138
|
+
|
|
28
139
|
CAMLprim value
|
|
29
|
-
|
|
30
|
-
|
|
140
|
+
caml_binaryen_element_segment_get_data(value _elem, value _index) {
|
|
141
|
+
CAMLparam2(_elem, _index);
|
|
142
|
+
BinaryenElementSegmentRef elem = BinaryenElementSegmentRef_val(_elem);
|
|
143
|
+
BinaryenIndex index = Int_val(_index);
|
|
144
|
+
CAMLreturn(caml_copy_string(BinaryenElementSegmentGetData(elem, index)));
|
|
31
145
|
}
|
|
@@ -97,3 +97,21 @@ caml_binaryen_type_create(value tys) {
|
|
|
97
97
|
BinaryenType newType = BinaryenTypeCreate(valueTypes, len);
|
|
98
98
|
CAMLreturn(alloc_BinaryenType(newType));
|
|
99
99
|
}
|
|
100
|
+
|
|
101
|
+
CAMLprim value
|
|
102
|
+
caml_binaryen_type_expand(value _ty) {
|
|
103
|
+
CAMLparam1(_ty);
|
|
104
|
+
BinaryenType ty = BinaryenType_val(_ty);
|
|
105
|
+
int arity = BinaryenTypeArity(ty);
|
|
106
|
+
BinaryenType* buf = malloc(sizeof(BinaryenType) * arity);
|
|
107
|
+
BinaryenTypeExpand(ty, buf);
|
|
108
|
+
|
|
109
|
+
value typeArray = caml_alloc(arity, 0);
|
|
110
|
+
for (int i = 0; i < arity; i++) {
|
|
111
|
+
Field(typeArray, i) = alloc_BinaryenType(buf[i]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
free(buf);
|
|
115
|
+
|
|
116
|
+
CAMLreturn(typeArray);
|
|
117
|
+
}
|
binaryen-archive/src/dune
CHANGED
|
@@ -2,52 +2,13 @@
|
|
|
2
2
|
(name binaryen_native)
|
|
3
3
|
(public_name binaryen.native)
|
|
4
4
|
(implements binaryen)
|
|
5
|
+
(libraries libbinaryen.c)
|
|
5
6
|
(foreign_stubs
|
|
6
7
|
(language c)
|
|
7
8
|
(names binaryen_stubs_types binaryen_stubs_ops binaryen_stubs_literals
|
|
8
9
|
binaryen_stubs_expressions binaryen_stubs_functions
|
|
9
10
|
binaryen_stubs_imports binaryen_stubs_exports binaryen_stubs_globals
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(foreign_archives binaryen)
|
|
15
|
-
(library_flags
|
|
16
|
-
(:include ./config/library_flags.sexp))
|
|
17
|
-
(c_library_flags -lstdc++ -lpthread))
|
|
18
|
-
|
|
19
|
-
(rule
|
|
20
|
-
(target binaryen-c.h)
|
|
21
|
-
(action
|
|
22
|
-
(copy ../vendor/binaryen-c.h binaryen-c.h)))
|
|
23
|
-
|
|
24
|
-
(rule
|
|
25
|
-
(target wasm-delegations.h)
|
|
26
|
-
(action
|
|
27
|
-
(copy ../vendor/wasm-delegations.h wasm-delegations.h)))
|
|
28
|
-
|
|
29
|
-
(rule
|
|
30
|
-
(target libbinaryen.a)
|
|
31
|
-
(action
|
|
32
|
-
(copy ../vendor/%{system}/libbinaryen.a libbinaryen.a)))
|
|
33
|
-
|
|
34
|
-
(rule
|
|
35
|
-
(target dllbinaryen.so)
|
|
36
|
-
(enabled_if
|
|
37
|
-
(= %{system} macosx))
|
|
38
|
-
(action
|
|
39
|
-
(copy ../vendor/%{system}/libbinaryen.dylib dllbinaryen.so)))
|
|
40
|
-
|
|
41
|
-
(rule
|
|
42
|
-
(target dllbinaryen.so)
|
|
43
|
-
(enabled_if
|
|
44
|
-
(= %{system} linux))
|
|
45
|
-
(action
|
|
46
|
-
(copy ../vendor/%{system}/libbinaryen.so dllbinaryen.so)))
|
|
47
|
-
|
|
48
|
-
(rule
|
|
49
|
-
(target dllbinaryen.dll)
|
|
50
|
-
(enabled_if
|
|
51
|
-
(= %{system} mingw64))
|
|
52
|
-
(action
|
|
53
|
-
(copy ../vendor/%{system}/libbinaryen.dll dllbinaryen.dll)))
|
|
11
|
+
binaryen_stubs_tables binaryen_stubs_memory binaryen_stubs_features
|
|
12
|
+
binaryen_stubs_modules binaryen_stubs_settings ocaml_helpers)
|
|
13
|
+
(flags :standard -O2 -Wall -Wextra))
|
|
14
|
+
(c_library_flags :standard -lstdc++ -lpthread))
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type t
|
|
2
|
+
|
|
3
|
+
external get_name : t -> string = "caml_binaryen_element_segment_get_name"
|
|
4
|
+
|
|
5
|
+
external get_table : t -> string = "caml_binaryen_element_segment_get_table"
|
|
6
|
+
|
|
7
|
+
external get_offset : t -> Expression.t
|
|
8
|
+
= "caml_binaryen_element_segment_get_offset"
|
|
9
|
+
|
|
10
|
+
external get_length : t -> int = "caml_binaryen_element_segment_get_length"
|
|
11
|
+
|
|
12
|
+
external get_data : t -> int -> string
|
|
13
|
+
= "caml_binaryen_element_segment_get_data"
|
binaryen-archive/src/export.ml
CHANGED
|
@@ -16,6 +16,39 @@ external add_global_export : Module.t -> string -> string -> t
|
|
|
16
16
|
= "caml_binaryen_add_global_export"
|
|
17
17
|
(** Module, internal name, external name. *)
|
|
18
18
|
|
|
19
|
+
external get_export : Module.t -> string -> t = "caml_binaryen_get_export"
|
|
20
|
+
|
|
19
21
|
external remove_export : Module.t -> string -> unit
|
|
20
22
|
= "caml_binaryen_remove_export"
|
|
21
23
|
(** Module, external name. *)
|
|
24
|
+
|
|
25
|
+
external get_num_exports : Module.t -> int = "caml_binaryen_get_num_exports"
|
|
26
|
+
|
|
27
|
+
external get_export_by_index : Module.t -> int -> t
|
|
28
|
+
= "caml_binaryen_get_export_by_index"
|
|
29
|
+
|
|
30
|
+
external get_name : t -> string = "caml_binaryen_export_get_name"
|
|
31
|
+
|
|
32
|
+
external get_value : t -> string = "caml_binaryen_export_get_value"
|
|
33
|
+
|
|
34
|
+
external external_function : unit -> int = "caml_binaryen_external_function"
|
|
35
|
+
|
|
36
|
+
let external_function = external_function ()
|
|
37
|
+
|
|
38
|
+
external external_table : unit -> int = "caml_binaryen_external_table"
|
|
39
|
+
|
|
40
|
+
let external_table = external_table ()
|
|
41
|
+
|
|
42
|
+
external external_memory : unit -> int = "caml_binaryen_external_memory"
|
|
43
|
+
|
|
44
|
+
let external_memory = external_memory ()
|
|
45
|
+
|
|
46
|
+
external external_global : unit -> int = "caml_binaryen_external_global"
|
|
47
|
+
|
|
48
|
+
let external_global = external_global ()
|
|
49
|
+
|
|
50
|
+
external external_event : unit -> int = "caml_binaryen_external_event"
|
|
51
|
+
|
|
52
|
+
let external_event = external_event ()
|
|
53
|
+
|
|
54
|
+
external export_get_kind : t -> int = "caml_binaryen_export_get_kind"
|