@grain/binaryen.ml 0.17.1 → 0.19.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 +38 -0
- binaryen-archive/binaryen.opam +2 -2
- binaryen-archive/esy.lock/index.json +355 -346
- binaryen-archive/esy.lock/opam/camlp-streams.5.0.1/opam +59 -0
- binaryen-archive/esy.lock/opam/chrome-trace.3.5.0/opam +39 -0
- binaryen-archive/esy.lock/opam/{dune-build-info.3.2.0 → dune-build-info.3.5.0}/opam +5 -6
- binaryen-archive/esy.lock/opam/{dune-configurator.3.2.0 → dune-configurator.3.5.0}/opam +6 -6
- binaryen-archive/esy.lock/opam/{dune-rpc.3.2.0 → dune-rpc.3.5.0}/opam +5 -6
- binaryen-archive/esy.lock/opam/{dune.3.2.0 → dune.3.5.0}/opam +4 -5
- binaryen-archive/esy.lock/opam/{dyn.3.2.0 → dyn.3.5.0}/opam +5 -6
- binaryen-archive/esy.lock/opam/{fiber.3.2.0 → fiber.3.5.0}/opam +5 -6
- binaryen-archive/esy.lock/opam/{ocaml-lsp-server.1.11.6 → ocaml-lsp-server.1.14.1}/opam +9 -8
- 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.3 → ocamlfind.1.9.5}/opam +6 -3
- 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/opam +1 -1
- binaryen-archive/esy.lock/opam/{odoc-parser.1.0.0 → odoc-parser.1.0.1}/opam +5 -4
- binaryen-archive/esy.lock/opam/omd.1.3.2/opam +50 -0
- binaryen-archive/esy.lock/opam/{ordering.3.2.0 → ordering.3.5.0}/opam +5 -6
- binaryen-archive/esy.lock/opam/{ppxlib.0.26.0 → ppxlib.0.28.0}/opam +7 -7
- binaryen-archive/esy.lock/opam/sexplib0.v0.14.0/opam +1 -1
- binaryen-archive/esy.lock/opam/{stdune.3.2.0 → stdune.3.5.0}/opam +6 -6
- 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.2.0 → xdg.3.5.0}/opam +5 -6
- binaryen-archive/esy.lock/opam/{yojson.1.7.0 → yojson.2.0.2}/opam +14 -14
- 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/esy.lock/overrides/{opam__s__ocamlfind_opam__c__1.9.3_opam_override → opam__s__ocamlfind_opam__c__1.9.5_opam_override}/files/findlib.patch +0 -0
- binaryen-archive/esy.lock/overrides/{opam__s__ocamlfind_opam__c__1.9.3_opam_override → opam__s__ocamlfind_opam__c__1.9.5_opam_override}/package.json +0 -0
- binaryen-archive/package.json +2 -2
- binaryen-archive/src/binaryen_stubs_exports.js +36 -20
- binaryen-archive/src/binaryen_stubs_expressions.c +101 -0
- binaryen-archive/src/binaryen_stubs_expressions.js +543 -508
- binaryen-archive/src/binaryen_stubs_features.js +34 -34
- binaryen-archive/src/binaryen_stubs_functions.js +45 -19
- binaryen-archive/src/binaryen_stubs_globals.js +8 -8
- binaryen-archive/src/binaryen_stubs_imports.c +14 -0
- binaryen-archive/src/binaryen_stubs_imports.js +67 -14
- binaryen-archive/src/binaryen_stubs_memory.c +40 -0
- binaryen-archive/src/binaryen_stubs_memory.js +45 -2
- binaryen-archive/src/binaryen_stubs_modules.c +20 -0
- binaryen-archive/src/binaryen_stubs_modules.js +26 -8
- binaryen-archive/src/binaryen_stubs_ops.js +632 -632
- binaryen-archive/src/binaryen_stubs_settings.js +36 -38
- binaryen-archive/src/binaryen_stubs_tables.js +18 -12
- binaryen-archive/src/binaryen_stubs_types.c +23 -2
- binaryen-archive/src/binaryen_stubs_types.js +44 -26
- binaryen-archive/src/expression.ml +27 -0
- binaryen-archive/src/expression.mli +18 -0
- binaryen-archive/src/import.ml +4 -0
- binaryen-archive/src/import.mli +2 -0
- binaryen-archive/src/memory.ml +25 -12
- binaryen-archive/src/memory.mli +12 -6
- binaryen-archive/src/module.ml +2 -0
- binaryen-archive/src/module.mli +2 -0
- binaryen-archive/src/passes.ml +6 -0
- binaryen-archive/src/passes.mli +6 -0
- binaryen-archive/src/type.ml +14 -2
- binaryen-archive/src/type.mli +4 -1
- binaryen-archive/test/test.expected +49 -12
- binaryen-archive/test/test.ml +49 -12
- binaryen-archive/esy.lock/opam/biniou.1.2.1/opam +0 -45
- binaryen-archive/esy.lock/opam/easy-format.1.3.4/opam +0 -56
- binaryen-archive/esy.lock/opam/omd.1.3.1/opam +0 -39
- binaryen-archive/esy.lock/opam/uucp.14.0.0/opam +0 -41
|
@@ -9,103 +9,103 @@ function caml_binaryen_module_set_features(wasm_mod, features) {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
//Provides: caml_binaryen_feature_mvp
|
|
12
|
-
//Requires:
|
|
12
|
+
//Requires: Binaryen
|
|
13
13
|
function caml_binaryen_feature_mvp() {
|
|
14
|
-
return
|
|
14
|
+
return Binaryen.Features.MVP;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
//Provides: caml_binaryen_feature_atomics
|
|
18
|
-
//Requires:
|
|
18
|
+
//Requires: Binaryen
|
|
19
19
|
function caml_binaryen_feature_atomics() {
|
|
20
|
-
return
|
|
20
|
+
return Binaryen.Features.Atomics;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
//Provides: caml_binaryen_feature_bulk_memory
|
|
24
|
-
//Requires:
|
|
24
|
+
//Requires: Binaryen
|
|
25
25
|
function caml_binaryen_feature_bulk_memory() {
|
|
26
|
-
return
|
|
26
|
+
return Binaryen.Features.BulkMemory;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
//Provides: caml_binaryen_feature_mutable_globals
|
|
30
|
-
//Requires:
|
|
30
|
+
//Requires: Binaryen
|
|
31
31
|
function caml_binaryen_feature_mutable_globals() {
|
|
32
|
-
return
|
|
32
|
+
return Binaryen.Features.MutableGlobals;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
//Provides: caml_binaryen_feature_nontrapping_fp_to_int
|
|
36
|
-
//Requires:
|
|
36
|
+
//Requires: Binaryen
|
|
37
37
|
function caml_binaryen_feature_nontrapping_fp_to_int() {
|
|
38
|
-
return
|
|
38
|
+
return Binaryen.Features.NontrappingFPToInt;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
//Provides: caml_binaryen_feature_sign_ext
|
|
42
|
-
//Requires:
|
|
42
|
+
//Requires: Binaryen
|
|
43
43
|
function caml_binaryen_feature_sign_ext() {
|
|
44
|
-
return
|
|
44
|
+
return Binaryen.Features.SignExt;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
//Provides: caml_binaryen_feature_simd128
|
|
48
|
-
//Requires:
|
|
48
|
+
//Requires: Binaryen
|
|
49
49
|
function caml_binaryen_feature_simd128() {
|
|
50
|
-
return
|
|
50
|
+
return Binaryen.Features.SIMD128;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
//Provides: caml_binaryen_feature_exception_handling
|
|
54
|
-
//Requires:
|
|
54
|
+
//Requires: Binaryen
|
|
55
55
|
function caml_binaryen_feature_exception_handling() {
|
|
56
|
-
return
|
|
56
|
+
return Binaryen.Features.ExceptionHandling;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
//Provides: caml_binaryen_feature_tail_call
|
|
60
|
-
//Requires:
|
|
60
|
+
//Requires: Binaryen
|
|
61
61
|
function caml_binaryen_feature_tail_call() {
|
|
62
|
-
return
|
|
62
|
+
return Binaryen.Features.TailCall;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
//Provides: caml_binaryen_feature_reference_types
|
|
66
|
-
//Requires:
|
|
66
|
+
//Requires: Binaryen
|
|
67
67
|
function caml_binaryen_feature_reference_types() {
|
|
68
|
-
return
|
|
68
|
+
return Binaryen.Features.ReferenceTypes;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
//Provides: caml_binaryen_feature_multivalue
|
|
72
|
-
//Requires:
|
|
72
|
+
//Requires: Binaryen
|
|
73
73
|
function caml_binaryen_feature_multivalue() {
|
|
74
|
-
return
|
|
74
|
+
return Binaryen.Features.Multivalue;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
//Provides: caml_binaryen_feature_gc
|
|
78
|
-
//Requires:
|
|
78
|
+
//Requires: Binaryen
|
|
79
79
|
function caml_binaryen_feature_gc() {
|
|
80
|
-
return
|
|
80
|
+
return Binaryen.Features.GC;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
//Provides: caml_binaryen_feature_memory64
|
|
84
|
-
//Requires:
|
|
84
|
+
//Requires: Binaryen
|
|
85
85
|
function caml_binaryen_feature_memory64() {
|
|
86
|
-
return
|
|
86
|
+
return Binaryen.Features.Memory64;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
//Provides: caml_binaryen_feature_typed_function_references
|
|
90
|
-
//Requires:
|
|
90
|
+
//Requires: Binaryen
|
|
91
91
|
function caml_binaryen_feature_typed_function_references() {
|
|
92
|
-
return
|
|
92
|
+
return Binaryen.Features.TypedFunctionReferences;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
//Provides: caml_binaryen_feature_relaxed_simd
|
|
96
|
-
//Requires:
|
|
96
|
+
//Requires: Binaryen
|
|
97
97
|
function caml_binaryen_feature_relaxed_simd() {
|
|
98
|
-
return
|
|
98
|
+
return Binaryen.Features.RelaxedSIMD;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
//Provides: caml_binaryen_feature_extended_const
|
|
102
|
-
//Requires:
|
|
102
|
+
//Requires: Binaryen
|
|
103
103
|
function caml_binaryen_feature_extended_const() {
|
|
104
|
-
return
|
|
104
|
+
return Binaryen.Features.ExtendedConst;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
//Provides: caml_binaryen_feature_all
|
|
108
|
-
//Requires:
|
|
108
|
+
//Requires: Binaryen
|
|
109
109
|
function caml_binaryen_feature_all() {
|
|
110
|
-
return
|
|
110
|
+
return Binaryen.Features.All;
|
|
111
111
|
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
//Provides: caml_binaryen_add_function
|
|
2
2
|
//Requires: caml_jsstring_of_string, caml_js_from_array
|
|
3
|
-
function caml_binaryen_add_function(
|
|
3
|
+
function caml_binaryen_add_function(
|
|
4
|
+
wasm_mod,
|
|
5
|
+
name,
|
|
6
|
+
params,
|
|
7
|
+
results,
|
|
8
|
+
locals,
|
|
9
|
+
body
|
|
10
|
+
) {
|
|
4
11
|
return wasm_mod.addFunction(
|
|
5
12
|
caml_jsstring_of_string(name),
|
|
6
13
|
params,
|
|
@@ -12,7 +19,14 @@ function caml_binaryen_add_function(wasm_mod, name, params, results, locals, bod
|
|
|
12
19
|
//Provides: caml_binaryen_add_function__bytecode
|
|
13
20
|
//Requires: caml_binaryen_add_function
|
|
14
21
|
function caml_binaryen_add_function__bytecode() {
|
|
15
|
-
return caml_binaryen_add_function(
|
|
22
|
+
return caml_binaryen_add_function(
|
|
23
|
+
arguments[0],
|
|
24
|
+
arguments[1],
|
|
25
|
+
arguments[2],
|
|
26
|
+
arguments[3],
|
|
27
|
+
arguments[4],
|
|
28
|
+
arguments[5]
|
|
29
|
+
);
|
|
16
30
|
}
|
|
17
31
|
|
|
18
32
|
//Provides: caml_binaryen_get_function
|
|
@@ -43,50 +57,62 @@ function caml_binaryen_set_start(wasm_mod, func) {
|
|
|
43
57
|
}
|
|
44
58
|
|
|
45
59
|
//Provides: caml_binaryen_function_set_debug_location
|
|
46
|
-
//Requires:
|
|
47
|
-
function caml_binaryen_function_set_debug_location(
|
|
48
|
-
|
|
60
|
+
//Requires: Binaryen
|
|
61
|
+
function caml_binaryen_function_set_debug_location(
|
|
62
|
+
func,
|
|
63
|
+
exp,
|
|
64
|
+
file,
|
|
65
|
+
line,
|
|
66
|
+
column
|
|
67
|
+
) {
|
|
68
|
+
return Binaryen._BinaryenFunctionSetDebugLocation(
|
|
69
|
+
func,
|
|
70
|
+
exp,
|
|
71
|
+
file,
|
|
72
|
+
line,
|
|
73
|
+
column
|
|
74
|
+
);
|
|
49
75
|
}
|
|
50
76
|
|
|
51
77
|
//Provides: caml_binaryen_function_get_name
|
|
52
|
-
//Requires:
|
|
78
|
+
//Requires: Binaryen
|
|
53
79
|
//Requires: caml_string_of_jsstring
|
|
54
80
|
function caml_binaryen_function_get_name(func) {
|
|
55
|
-
return caml_string_of_jsstring(
|
|
81
|
+
return caml_string_of_jsstring(Binaryen.Function.getName(func));
|
|
56
82
|
}
|
|
57
83
|
|
|
58
84
|
//Provides: caml_binaryen_function_get_params
|
|
59
|
-
//Requires:
|
|
85
|
+
//Requires: Binaryen
|
|
60
86
|
function caml_binaryen_function_get_params(func) {
|
|
61
|
-
return
|
|
87
|
+
return Binaryen.Function.getParams(func);
|
|
62
88
|
}
|
|
63
89
|
|
|
64
90
|
//Provides: caml_binaryen_function_get_results
|
|
65
|
-
//Requires:
|
|
91
|
+
//Requires: Binaryen
|
|
66
92
|
function caml_binaryen_function_get_results(func) {
|
|
67
|
-
return
|
|
93
|
+
return Binaryen.Function.getResults(func);
|
|
68
94
|
}
|
|
69
95
|
|
|
70
96
|
//Provides: caml_binaryen_function_get_num_vars
|
|
71
|
-
//Requires:
|
|
97
|
+
//Requires: Binaryen
|
|
72
98
|
function caml_binaryen_function_get_num_vars(func) {
|
|
73
|
-
return
|
|
99
|
+
return Binaryen.Function.getNumVars(func);
|
|
74
100
|
}
|
|
75
101
|
|
|
76
102
|
//Provides: caml_binaryen_function_get_var
|
|
77
|
-
//Requires:
|
|
103
|
+
//Requires: Binaryen
|
|
78
104
|
function caml_binaryen_function_get_var(func, index) {
|
|
79
|
-
return
|
|
105
|
+
return Binaryen.Function.getVar(func, index);
|
|
80
106
|
}
|
|
81
107
|
|
|
82
108
|
//Provides: caml_binaryen_function_get_body
|
|
83
|
-
//Requires:
|
|
109
|
+
//Requires: Binaryen
|
|
84
110
|
function caml_binaryen_function_get_body(func) {
|
|
85
|
-
return
|
|
111
|
+
return Binaryen.Function.getBody(func);
|
|
86
112
|
}
|
|
87
113
|
|
|
88
114
|
//Provides: caml_binaryen_function_set_body
|
|
89
|
-
//Requires:
|
|
115
|
+
//Requires: Binaryen
|
|
90
116
|
function caml_binaryen_function_set_body(func, body) {
|
|
91
|
-
return
|
|
117
|
+
return Binaryen.Function.setBody(func, body);
|
|
92
118
|
}
|
|
@@ -32,31 +32,31 @@ function caml_binaryen_get_global_by_index(wasm_mod, index) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
//Provides: caml_binaryen_global_get_name
|
|
35
|
-
//Requires:
|
|
35
|
+
//Requires: Binaryen
|
|
36
36
|
//Requires: caml_string_of_jsstring
|
|
37
37
|
function caml_binaryen_global_get_name(global) {
|
|
38
|
-
var global_info =
|
|
38
|
+
var global_info = Binaryen.getGlobalInfo(global);
|
|
39
39
|
return caml_string_of_jsstring(global_info.name);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
//Provides: caml_binaryen_global_get_type
|
|
43
|
-
//Requires:
|
|
43
|
+
//Requires: Binaryen
|
|
44
44
|
function caml_binaryen_global_get_type(global) {
|
|
45
|
-
var global_info =
|
|
45
|
+
var global_info = Binaryen.getGlobalInfo(global);
|
|
46
46
|
return global_info.type;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
//Provides: caml_binaryen_global_is_mutable
|
|
50
|
-
//Requires:
|
|
50
|
+
//Requires: Binaryen
|
|
51
51
|
//Requires: caml_js_to_bool
|
|
52
52
|
function caml_binaryen_global_is_mutable(global) {
|
|
53
|
-
var global_info =
|
|
53
|
+
var global_info = Binaryen.getGlobalInfo(global);
|
|
54
54
|
return caml_js_to_bool(global_info.mutable);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
//Provides: caml_binaryen_global_get_init_expr
|
|
58
|
-
//Requires:
|
|
58
|
+
//Requires: Binaryen
|
|
59
59
|
function caml_binaryen_global_get_init_expr(global) {
|
|
60
|
-
var global_info =
|
|
60
|
+
var global_info = Binaryen.getGlobalInfo(global);
|
|
61
61
|
return global_info.init;
|
|
62
62
|
}
|
|
@@ -74,6 +74,13 @@ caml_binaryen_function_import_get_module(value _fun) {
|
|
|
74
74
|
CAMLreturn(caml_copy_string(BinaryenFunctionImportGetModule(fun)));
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
CAMLprim value
|
|
78
|
+
caml_binaryen_memory_import_get_module(value _module) {
|
|
79
|
+
CAMLparam1(_module);
|
|
80
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
81
|
+
CAMLreturn(caml_copy_string(BinaryenMemoryImportGetModule(module)));
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
CAMLprim value
|
|
78
85
|
caml_binaryen_global_import_get_module(value _global) {
|
|
79
86
|
CAMLparam1(_global);
|
|
@@ -88,6 +95,13 @@ caml_binaryen_function_import_get_base(value _fun) {
|
|
|
88
95
|
CAMLreturn(caml_copy_string(BinaryenFunctionImportGetBase(fun)));
|
|
89
96
|
}
|
|
90
97
|
|
|
98
|
+
CAMLprim value
|
|
99
|
+
caml_binaryen_memory_import_get_base(value _module) {
|
|
100
|
+
CAMLparam1(_module);
|
|
101
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
102
|
+
CAMLreturn(caml_copy_string(BinaryenMemoryImportGetBase(module)));
|
|
103
|
+
}
|
|
104
|
+
|
|
91
105
|
CAMLprim value
|
|
92
106
|
caml_binaryen_global_import_get_base(value _global) {
|
|
93
107
|
CAMLparam1(_global);
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
//Provides: caml_binaryen_add_function_import
|
|
2
2
|
//Requires: caml_jsstring_of_string
|
|
3
|
-
function caml_binaryen_add_function_import(
|
|
3
|
+
function caml_binaryen_add_function_import(
|
|
4
|
+
wasm_mod,
|
|
5
|
+
internalName,
|
|
6
|
+
externalModuleName,
|
|
7
|
+
externalBaseName,
|
|
8
|
+
paramsty,
|
|
9
|
+
resultsty
|
|
10
|
+
) {
|
|
4
11
|
return wasm_mod.addFunctionImport(
|
|
5
12
|
caml_jsstring_of_string(internalName),
|
|
6
13
|
caml_jsstring_of_string(externalModuleName),
|
|
@@ -12,12 +19,24 @@ function caml_binaryen_add_function_import(wasm_mod, internalName, externalModul
|
|
|
12
19
|
//Provides: caml_binaryen_add_function_import__bytecode
|
|
13
20
|
//Requires: caml_binaryen_add_function_import
|
|
14
21
|
function caml_binaryen_add_function_import__bytecode() {
|
|
15
|
-
return caml_binaryen_add_function_import(
|
|
22
|
+
return caml_binaryen_add_function_import(
|
|
23
|
+
arguments[0],
|
|
24
|
+
arguments[1],
|
|
25
|
+
arguments[2],
|
|
26
|
+
arguments[3],
|
|
27
|
+
arguments[4],
|
|
28
|
+
arguments[5]
|
|
29
|
+
);
|
|
16
30
|
}
|
|
17
31
|
|
|
18
32
|
//Provides: caml_binaryen_add_table_import
|
|
19
33
|
//Requires: caml_jsstring_of_string
|
|
20
|
-
function caml_binaryen_add_table_import(
|
|
34
|
+
function caml_binaryen_add_table_import(
|
|
35
|
+
wasm_mod,
|
|
36
|
+
internalName,
|
|
37
|
+
externalModuleName,
|
|
38
|
+
externalBaseName
|
|
39
|
+
) {
|
|
21
40
|
return wasm_mod.addTableImport(
|
|
22
41
|
caml_jsstring_of_string(internalName),
|
|
23
42
|
caml_jsstring_of_string(externalModuleName),
|
|
@@ -27,7 +46,13 @@ function caml_binaryen_add_table_import(wasm_mod, internalName, externalModuleNa
|
|
|
27
46
|
|
|
28
47
|
//Provides: caml_binaryen_add_memory_import
|
|
29
48
|
//Requires: caml_jsstring_of_string
|
|
30
|
-
function caml_binaryen_add_memory_import(
|
|
49
|
+
function caml_binaryen_add_memory_import(
|
|
50
|
+
wasm_mod,
|
|
51
|
+
internalName,
|
|
52
|
+
externalModuleName,
|
|
53
|
+
externalBaseName,
|
|
54
|
+
shared
|
|
55
|
+
) {
|
|
31
56
|
return wasm_mod.addMemoryImport(
|
|
32
57
|
caml_jsstring_of_string(internalName),
|
|
33
58
|
caml_jsstring_of_string(externalModuleName),
|
|
@@ -38,7 +63,14 @@ function caml_binaryen_add_memory_import(wasm_mod, internalName, externalModuleN
|
|
|
38
63
|
|
|
39
64
|
//Provides: caml_binaryen_add_global_import
|
|
40
65
|
//Requires: caml_jsstring_of_string
|
|
41
|
-
function caml_binaryen_add_global_import(
|
|
66
|
+
function caml_binaryen_add_global_import(
|
|
67
|
+
wasm_mod,
|
|
68
|
+
internalName,
|
|
69
|
+
externalModuleName,
|
|
70
|
+
externalBaseName,
|
|
71
|
+
typ,
|
|
72
|
+
is_mut
|
|
73
|
+
) {
|
|
42
74
|
return wasm_mod.addGlobalImport(
|
|
43
75
|
caml_jsstring_of_string(internalName),
|
|
44
76
|
caml_jsstring_of_string(externalModuleName),
|
|
@@ -50,37 +82,58 @@ function caml_binaryen_add_global_import(wasm_mod, internalName, externalModuleN
|
|
|
50
82
|
//Provides: caml_binaryen_add_global_import__bytecode
|
|
51
83
|
//Requires: caml_binaryen_add_global_import
|
|
52
84
|
function caml_binaryen_add_global_import__bytecode() {
|
|
53
|
-
return caml_binaryen_add_global_import(
|
|
85
|
+
return caml_binaryen_add_global_import(
|
|
86
|
+
arguments[0],
|
|
87
|
+
arguments[1],
|
|
88
|
+
arguments[2],
|
|
89
|
+
arguments[3],
|
|
90
|
+
arguments[4],
|
|
91
|
+
arguments[5]
|
|
92
|
+
);
|
|
54
93
|
}
|
|
55
94
|
|
|
56
95
|
//Provides: caml_binaryen_function_import_get_module
|
|
57
|
-
//Requires:
|
|
96
|
+
//Requires: Binaryen
|
|
58
97
|
//Requires: caml_string_of_jsstring
|
|
59
98
|
function caml_binaryen_function_import_get_module(func) {
|
|
60
|
-
var func_info =
|
|
99
|
+
var func_info = Binaryen.getFunctionInfo(func);
|
|
61
100
|
return caml_string_of_jsstring(func_info.module);
|
|
62
101
|
}
|
|
63
102
|
|
|
103
|
+
//Provides: caml_binaryen_memory_import_get_module
|
|
104
|
+
//Requires: caml_string_of_jsstring
|
|
105
|
+
function caml_binaryen_memory_import_get_module(mod) {
|
|
106
|
+
var memory_info = mod.getMemoryInfo();
|
|
107
|
+
return caml_string_of_jsstring(memory_info.module);
|
|
108
|
+
}
|
|
109
|
+
|
|
64
110
|
//Provides: caml_binaryen_global_import_get_module
|
|
65
|
-
//Requires:
|
|
111
|
+
//Requires: Binaryen
|
|
66
112
|
//Requires: caml_string_of_jsstring
|
|
67
113
|
function caml_binaryen_global_import_get_module(global) {
|
|
68
|
-
var global_info =
|
|
114
|
+
var global_info = Binaryen.getGlobalInfo(global);
|
|
69
115
|
return caml_string_of_jsstring(global_info.module);
|
|
70
116
|
}
|
|
71
117
|
|
|
72
118
|
//Provides: caml_binaryen_function_import_get_base
|
|
73
|
-
//Requires:
|
|
119
|
+
//Requires: Binaryen
|
|
74
120
|
//Requires: caml_string_of_jsstring
|
|
75
121
|
function caml_binaryen_function_import_get_base(func) {
|
|
76
|
-
var func_info =
|
|
122
|
+
var func_info = Binaryen.getFunctionInfo(func);
|
|
77
123
|
return caml_string_of_jsstring(func_info.base);
|
|
78
124
|
}
|
|
79
125
|
|
|
126
|
+
//Provides: caml_binaryen_memory_import_get_base
|
|
127
|
+
//Requires: caml_string_of_jsstring
|
|
128
|
+
function caml_binaryen_memory_import_get_base(mod) {
|
|
129
|
+
var memory_info = mod.getMemoryInfo();
|
|
130
|
+
return caml_string_of_jsstring(memory_info.base);
|
|
131
|
+
}
|
|
132
|
+
|
|
80
133
|
//Provides: caml_binaryen_global_import_get_base
|
|
81
|
-
//Requires:
|
|
134
|
+
//Requires: Binaryen
|
|
82
135
|
//Requires: caml_string_of_jsstring
|
|
83
136
|
function caml_binaryen_global_import_get_base(global) {
|
|
84
|
-
var global_info =
|
|
137
|
+
var global_info = Binaryen.getGlobalInfo(global);
|
|
85
138
|
return caml_string_of_jsstring(global_info.base);
|
|
86
139
|
}
|
|
@@ -47,3 +47,43 @@ CAMLprim value
|
|
|
47
47
|
caml_binaryen_set_memory__bytecode(value * argv) {
|
|
48
48
|
return caml_binaryen_set_memory(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8]);
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
CAMLprim value
|
|
52
|
+
caml_binaryen_has_memory(value _module) {
|
|
53
|
+
CAMLparam1(_module);
|
|
54
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
55
|
+
CAMLreturn(Val_bool(BinaryenHasMemory(module)));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
CAMLprim value
|
|
59
|
+
caml_binaryen_memory_get_initial(value _module) {
|
|
60
|
+
CAMLparam1(_module);
|
|
61
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
62
|
+
CAMLreturn(Val_int(BinaryenMemoryGetInitial(module)));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
CAMLprim value
|
|
66
|
+
caml_binaryen_memory_has_max(value _module) {
|
|
67
|
+
CAMLparam1(_module);
|
|
68
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
69
|
+
CAMLreturn(Val_bool(BinaryenMemoryHasMax(module)));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
CAMLprim value
|
|
73
|
+
caml_binaryen_memory_get_max(value _module) {
|
|
74
|
+
CAMLparam1(_module);
|
|
75
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
76
|
+
if (BinaryenMemoryHasMax(module)) {
|
|
77
|
+
CAMLreturn(Val_int(BinaryenMemoryGetMax(module)));
|
|
78
|
+
} else {
|
|
79
|
+
// This ensures that our return is equal to Memory.unlimited
|
|
80
|
+
CAMLreturn(Val_int(-1));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
CAMLprim value
|
|
85
|
+
caml_binaryen_memory_is_shared(value _module) {
|
|
86
|
+
CAMLparam1(_module);
|
|
87
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
88
|
+
CAMLreturn(Val_bool(BinaryenMemoryIsShared(module)));
|
|
89
|
+
}
|
|
@@ -2,11 +2,13 @@
|
|
|
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
4
|
function caml_binaryen_set_memory(wasm_mod, initial, maximum, exportName, segments, segmentPassives, segmentOffsets, segmentSizes, shared) {
|
|
5
|
+
var passives = caml_list_to_js_array(segmentPassives);
|
|
6
|
+
var offsets = caml_list_to_js_array(segmentOffsets);
|
|
5
7
|
var segs = caml_list_to_js_array(segments).map(function (segment, idx) {
|
|
6
8
|
return {
|
|
7
9
|
data: caml_convert_bytes_to_array(segment),
|
|
8
|
-
passive:
|
|
9
|
-
offset:
|
|
10
|
+
passive: caml_js_from_bool(passives[idx]),
|
|
11
|
+
offset: offsets[idx]
|
|
10
12
|
}
|
|
11
13
|
});
|
|
12
14
|
|
|
@@ -23,3 +25,44 @@ function caml_binaryen_set_memory(wasm_mod, initial, maximum, exportName, segmen
|
|
|
23
25
|
function caml_binaryen_set_memory__bytecode() {
|
|
24
26
|
return caml_binaryen_set_memory(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]);
|
|
25
27
|
}
|
|
28
|
+
|
|
29
|
+
//Provides: caml_binaryen_has_memory
|
|
30
|
+
//Requires: caml_js_to_bool
|
|
31
|
+
function caml_binaryen_has_memory(mod) {
|
|
32
|
+
return caml_js_to_bool(mod.hasMemory());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//Provides: caml_binaryen_memory_get_initial
|
|
36
|
+
function caml_binaryen_memory_get_initial(mod) {
|
|
37
|
+
var memory_info = mod.getMemoryInfo();
|
|
38
|
+
return memory_info.initial;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//Provides: caml_binaryen_memory_has_max
|
|
42
|
+
//Requires: caml_js_to_bool
|
|
43
|
+
function caml_binaryen_memory_has_max(mod) {
|
|
44
|
+
var memory_info = mod.getMemoryInfo();
|
|
45
|
+
if (memory_info.max != null) {
|
|
46
|
+
return caml_js_to_bool(true);
|
|
47
|
+
} else {
|
|
48
|
+
return caml_js_to_bool(false);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//Provides: caml_binaryen_memory_get_max
|
|
53
|
+
function caml_binaryen_memory_get_max(mod) {
|
|
54
|
+
var memory_info = mod.getMemoryInfo();
|
|
55
|
+
if (memory_info.max != null) {
|
|
56
|
+
return memory_info.max;
|
|
57
|
+
} else {
|
|
58
|
+
// This ensures that our return is equal to Memory.unlimited
|
|
59
|
+
return -1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//Provides: caml_binaryen_memory_is_shared
|
|
64
|
+
//Requires: caml_js_to_bool
|
|
65
|
+
function caml_binaryen_memory_is_shared(mod) {
|
|
66
|
+
var memory_info = mod.getMemoryInfo();
|
|
67
|
+
return caml_js_to_bool(memory_info.shared);
|
|
68
|
+
}
|
|
@@ -52,6 +52,13 @@ 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) {
|
|
57
|
+
CAMLparam1(module);
|
|
58
|
+
BinaryenModulePrintStackIR(BinaryenModuleRef_val(module));
|
|
59
|
+
CAMLreturn(Val_unit);
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
CAMLprim value
|
|
56
63
|
caml_binaryen_module_validate(value module) {
|
|
57
64
|
CAMLparam1(module);
|
|
@@ -125,6 +132,19 @@ caml_binaryen_module_write_text(value _module) {
|
|
|
125
132
|
CAMLreturn(text);
|
|
126
133
|
}
|
|
127
134
|
|
|
135
|
+
// There is something weird with this function that causes a bunch of newlines to
|
|
136
|
+
// be printed on stdout when calling it. Not sure if that's a bug in Binaryen.
|
|
137
|
+
CAMLprim value
|
|
138
|
+
caml_binaryen_module_write_stack_ir(value _module) {
|
|
139
|
+
CAMLparam1(_module);
|
|
140
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
141
|
+
char* result = BinaryenModuleAllocateAndWriteStackIR(module);
|
|
142
|
+
CAMLlocal1(text);
|
|
143
|
+
text = caml_copy_string(result);
|
|
144
|
+
free(result);
|
|
145
|
+
CAMLreturn(text);
|
|
146
|
+
}
|
|
147
|
+
|
|
128
148
|
CAMLprim value
|
|
129
149
|
caml_binaryen_module_read(value _bytes) {
|
|
130
150
|
CAMLparam1(_bytes);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//Provides: caml_binaryen_module_create
|
|
2
|
-
//Requires:
|
|
2
|
+
//Requires: Binaryen
|
|
3
3
|
function caml_binaryen_module_create() {
|
|
4
|
-
return new
|
|
4
|
+
return new Binaryen.Module();
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
//Provides: caml_binaryen_module_dispose
|
|
@@ -10,10 +10,10 @@ function caml_binaryen_module_dispose(wasm_mod) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
//Provides: caml_binaryen_module_parse
|
|
13
|
-
//Requires:
|
|
13
|
+
//Requires: Binaryen
|
|
14
14
|
//Requires: caml_jsstring_of_string
|
|
15
15
|
function caml_binaryen_module_parse(text) {
|
|
16
|
-
return
|
|
16
|
+
return Binaryen.parseText(caml_jsstring_of_string(text));
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
//Provides: caml_binaryen_module_print
|
|
@@ -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
|
|
41
|
+
//Requires: caml_ml_output, caml_ml_string_length
|
|
42
|
+
function caml_binaryen_module_print_stack_ir(wasm_mod) {
|
|
43
|
+
var stackir = wasm_mod.emitStackIR()
|
|
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();
|
|
@@ -66,7 +76,8 @@ function caml_binaryen_module_write(wasm_mod, sourceMapUrl) {
|
|
|
66
76
|
if (sourceMapUrl) {
|
|
67
77
|
var url = caml_jsstring_of_string(sourceMapUrl[1]);
|
|
68
78
|
var obj = wasm_mod.emitBinary(url);
|
|
69
|
-
var sourceMap =
|
|
79
|
+
var sourceMap =
|
|
80
|
+
obj.sourceMap != null ? caml_string_of_jsstring(obj.sourceMap) : null;
|
|
70
81
|
return [0, caml_bytes_of_array(obj.binary), to_option(sourceMap)];
|
|
71
82
|
} else {
|
|
72
83
|
var binary = wasm_mod.emitBinary();
|
|
@@ -81,12 +92,19 @@ function caml_binaryen_module_write_text(wasm_mod) {
|
|
|
81
92
|
return caml_string_of_jsstring(text);
|
|
82
93
|
}
|
|
83
94
|
|
|
95
|
+
//Provides: caml_binaryen_module_write_stack_ir
|
|
96
|
+
//Requires: caml_string_of_jsstring
|
|
97
|
+
function caml_binaryen_module_write_stack_ir(wasm_mod) {
|
|
98
|
+
var text = wasm_mod.emitStackIR();
|
|
99
|
+
return caml_string_of_jsstring(text);
|
|
100
|
+
}
|
|
101
|
+
|
|
84
102
|
//Provides: caml_binaryen_module_read
|
|
85
|
-
//Requires:
|
|
103
|
+
//Requires: Binaryen
|
|
86
104
|
//Requires: caml_array_of_bytes
|
|
87
105
|
function caml_binaryen_module_read(bytes) {
|
|
88
|
-
var data = caml_array_of_bytes(bytes)
|
|
89
|
-
return
|
|
106
|
+
var data = caml_array_of_bytes(bytes);
|
|
107
|
+
return Binaryen.readBinary(data);
|
|
90
108
|
}
|
|
91
109
|
|
|
92
110
|
//Provides: caml_binaryen_module_interpret
|