@grain/binaryen.ml 0.13.0 → 0.15.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 +44 -0
- binaryen-archive/README.md +16 -0
- binaryen-archive/binaryen.opam +4 -6
- binaryen-archive/dune +1 -1
- binaryen-archive/esy.lock/index.json +87 -173
- binaryen-archive/esy.lock/opam/{cmdliner.1.0.4 → cmdliner.1.1.0}/opam +17 -20
- binaryen-archive/esy.lock/opam/{ocaml-lsp-server.1.9.1 → ocaml-lsp-server.1.10.3}/opam +4 -4
- binaryen-archive/esy.lock/opam/{ocamlbuild.0.14.0 → ocamlbuild.0.14.1}/opam +18 -15
- binaryen-archive/esy.lock/opam/ocamlformat.0.20.1/opam +2 -0
- binaryen-archive/esy.lock/opam/{ppxlib.0.24.0 → ppxlib.0.25.0}/opam +4 -4
- binaryen-archive/esy.lock/opam/stdlib-shims.0.3.0/opam +1 -1
- binaryen-archive/esy.lock/opam/uutf.1.0.3/opam +36 -0
- binaryen-archive/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.1_opam_override/files/winpatch.patch +11 -0
- binaryen-archive/esy.lock/overrides/{opam__s__ocamlbuild_opam__c__0.14.0_opam_override → opam__s__ocamlbuild_opam__c__0.14.1_opam_override}/package.json +5 -3
- binaryen-archive/esy.lock/overrides/opam__s__ocamlfind_opam__c__1.9.3_opam_override/files/findlib.patch +14 -0
- binaryen-archive/package.json +4 -6
- binaryen-archive/src/binaryen_stubs_exports.js +110 -0
- binaryen-archive/src/binaryen_stubs_expressions.js +1613 -0
- binaryen-archive/src/binaryen_stubs_features.js +105 -0
- binaryen-archive/src/binaryen_stubs_functions.js +92 -0
- binaryen-archive/src/binaryen_stubs_globals.js +62 -0
- binaryen-archive/src/binaryen_stubs_imports.js +86 -0
- binaryen-archive/src/binaryen_stubs_literals.js +29 -0
- binaryen-archive/src/binaryen_stubs_memory.js +25 -0
- binaryen-archive/src/binaryen_stubs_modules.js +121 -0
- binaryen-archive/src/binaryen_stubs_ops.js +1895 -0
- binaryen-archive/src/binaryen_stubs_settings.js +120 -0
- binaryen-archive/src/binaryen_stubs_tables.c +2 -0
- binaryen-archive/src/binaryen_stubs_tables.js +84 -0
- binaryen-archive/src/binaryen_stubs_types.js +73 -0
- binaryen-archive/src/dune +11 -4
- binaryen-archive/{virtual → src}/element_segment.mli +0 -0
- binaryen-archive/{virtual → src}/export.mli +0 -0
- binaryen-archive/{virtual → src}/expression.mli +0 -0
- binaryen-archive/{virtual → src}/function.mli +0 -0
- binaryen-archive/{virtual → src}/global.mli +0 -0
- binaryen-archive/{virtual → src}/import.mli +0 -0
- binaryen-archive/src/literal.ml +0 -13
- binaryen-archive/src/literal.mli +8 -0
- binaryen-archive/src/memory.ml +6 -6
- binaryen-archive/{virtual → src}/memory.mli +1 -1
- binaryen-archive/src/module.ml +1 -1
- binaryen-archive/{virtual → src}/module.mli +1 -1
- binaryen-archive/{virtual → src}/op.mli +0 -0
- binaryen-archive/src/passes.ml +345 -0
- binaryen-archive/src/passes.mli +343 -0
- binaryen-archive/{virtual → src}/settings.mli +0 -0
- binaryen-archive/{virtual → src}/table.mli +0 -0
- binaryen-archive/{virtual → src}/type.mli +0 -0
- binaryen-archive/test/dune +2 -22
- binaryen-archive/test/test.expected +8 -4
- binaryen-archive/test/test.ml +33 -10
- binaryen-archive/esy.lock/opam/js_of_ocaml-ppx.3.11.0/opam +0 -44
- binaryen-archive/esy.lock/opam/js_of_ocaml.3.11.0/opam +0 -45
- binaryen-archive/esy.lock/opam/uchar.0.0.2/opam +0 -36
- binaryen-archive/esy.lock/opam/uutf.1.0.2/opam +0 -40
- binaryen-archive/esy.lock/overrides/opam__s__ocamlbuild_opam__c__0.14.0_opam_override/files/ocamlbuild-0.14.0.patch +0 -463
- binaryen-archive/js/binaryen.es5.js +0 -363
- binaryen-archive/js/dune +0 -13
- binaryen-archive/js/element_segment.ml +0 -33
- binaryen-archive/js/export.ml +0 -57
- binaryen-archive/js/expression.ml +0 -1105
- binaryen-archive/js/function.ml +0 -60
- binaryen-archive/js/global.ml +0 -48
- binaryen-archive/js/import.ml +0 -69
- binaryen-archive/js/literal.ml +0 -28
- binaryen-archive/js/memory.ml +0 -39
- binaryen-archive/js/module.ml +0 -116
- binaryen-archive/js/op.ml +0 -482
- binaryen-archive/js/prelude.js +0 -2
- binaryen-archive/js/settings.ml +0 -60
- binaryen-archive/js/stubs.c +0 -15
- binaryen-archive/js/table.ml +0 -29
- binaryen-archive/js/type.ml +0 -21
- binaryen-archive/virtual/dune +0 -6
- binaryen-archive/virtual/literal.mli +0 -19
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//Provides: caml_binaryen_module_get_features
|
|
2
|
+
function caml_binaryen_module_get_features(wasm_mod) {
|
|
3
|
+
return wasm_mod.getFeatures();
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
//Provides: caml_binaryen_module_set_features
|
|
7
|
+
function caml_binaryen_module_set_features(wasm_mod, features) {
|
|
8
|
+
return wasm_mod.setFeatures(features);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
//Provides: caml_binaryen_feature_mvp
|
|
12
|
+
//Requires: binaryen
|
|
13
|
+
function caml_binaryen_feature_mvp() {
|
|
14
|
+
return binaryen.Features.MVP;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//Provides: caml_binaryen_feature_atomics
|
|
18
|
+
//Requires: binaryen
|
|
19
|
+
function caml_binaryen_feature_atomics() {
|
|
20
|
+
return binaryen.Features.Atomics;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//Provides: caml_binaryen_feature_bulk_memory
|
|
24
|
+
//Requires: binaryen
|
|
25
|
+
function caml_binaryen_feature_bulk_memory() {
|
|
26
|
+
return binaryen.Features.BulkMemory;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//Provides: caml_binaryen_feature_mutable_globals
|
|
30
|
+
//Requires: binaryen
|
|
31
|
+
function caml_binaryen_feature_mutable_globals() {
|
|
32
|
+
return binaryen.Features.MutableGlobals;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//Provides: caml_binaryen_feature_nontrapping_fp_to_int
|
|
36
|
+
//Requires: binaryen
|
|
37
|
+
function caml_binaryen_feature_nontrapping_fp_to_int() {
|
|
38
|
+
return binaryen.Features.NontrappingFPToInt;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//Provides: caml_binaryen_feature_sign_ext
|
|
42
|
+
//Requires: binaryen
|
|
43
|
+
function caml_binaryen_feature_sign_ext() {
|
|
44
|
+
return binaryen.Features.SignExt;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//Provides: caml_binaryen_feature_simd128
|
|
48
|
+
//Requires: binaryen
|
|
49
|
+
function caml_binaryen_feature_simd128() {
|
|
50
|
+
return binaryen.Features.SIMD128;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//Provides: caml_binaryen_feature_exception_handling
|
|
54
|
+
//Requires: binaryen
|
|
55
|
+
function caml_binaryen_feature_exception_handling() {
|
|
56
|
+
return binaryen.Features.ExceptionHandling;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//Provides: caml_binaryen_feature_tail_call
|
|
60
|
+
//Requires: binaryen
|
|
61
|
+
function caml_binaryen_feature_tail_call() {
|
|
62
|
+
return binaryen.Features.TailCall;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//Provides: caml_binaryen_feature_reference_types
|
|
66
|
+
//Requires: binaryen
|
|
67
|
+
function caml_binaryen_feature_reference_types() {
|
|
68
|
+
return binaryen.Features.ReferenceTypes;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//Provides: caml_binaryen_feature_multivalue
|
|
72
|
+
//Requires: binaryen
|
|
73
|
+
function caml_binaryen_feature_multivalue() {
|
|
74
|
+
return binaryen.Features.Multivalue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//Provides: caml_binaryen_feature_gc
|
|
78
|
+
//Requires: binaryen
|
|
79
|
+
function caml_binaryen_feature_gc() {
|
|
80
|
+
return binaryen.Features.GC;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
//Provides: caml_binaryen_feature_memory64
|
|
84
|
+
//Requires: binaryen
|
|
85
|
+
function caml_binaryen_feature_memory64() {
|
|
86
|
+
return binaryen.Features.Memory64;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//Provides: caml_binaryen_feature_typed_function_references
|
|
90
|
+
//Requires: binaryen
|
|
91
|
+
function caml_binaryen_feature_typed_function_references() {
|
|
92
|
+
return binaryen.Features.TypedFunctionReferences;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//Provides: caml_binaryen_feature_relaxed_simd
|
|
96
|
+
//Requires: binaryen
|
|
97
|
+
function caml_binaryen_feature_relaxed_simd() {
|
|
98
|
+
return binaryen.Features.RelaxedSIMD;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//Provides: caml_binaryen_feature_all
|
|
102
|
+
//Requires: binaryen
|
|
103
|
+
function caml_binaryen_feature_all() {
|
|
104
|
+
return binaryen.Features.All;
|
|
105
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//Provides: caml_binaryen_add_function
|
|
2
|
+
//Requires: caml_jsstring_of_string, caml_js_from_array
|
|
3
|
+
function caml_binaryen_add_function(wasm_mod, name, params, results, locals, body) {
|
|
4
|
+
return wasm_mod.addFunction(
|
|
5
|
+
caml_jsstring_of_string(name),
|
|
6
|
+
params,
|
|
7
|
+
results,
|
|
8
|
+
caml_js_from_array(locals),
|
|
9
|
+
body
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
//Provides: caml_binaryen_add_function__bytecode
|
|
13
|
+
//Requires: caml_binaryen_add_function
|
|
14
|
+
function caml_binaryen_add_function__bytecode() {
|
|
15
|
+
return caml_binaryen_add_function(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//Provides: caml_binaryen_get_function
|
|
19
|
+
//Requires: caml_jsstring_of_string
|
|
20
|
+
function caml_binaryen_get_function(wasm_mod, name) {
|
|
21
|
+
return wasm_mod.getFunction(caml_jsstring_of_string(name));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//Provides: caml_binaryen_remove_function
|
|
25
|
+
//Requires: caml_jsstring_of_string
|
|
26
|
+
function caml_binaryen_remove_function(wasm_mod, name) {
|
|
27
|
+
return wasm_mod.removeFunction(caml_jsstring_of_string(name));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//Provides: caml_binaryen_get_num_functions
|
|
31
|
+
function caml_binaryen_get_num_functions(wasm_mod) {
|
|
32
|
+
return wasm_mod.getNumFunctions();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//Provides: caml_binaryen_get_function_by_index
|
|
36
|
+
function caml_binaryen_get_function_by_index(wasm_mod, index) {
|
|
37
|
+
return wasm_mod.getFunctionByIndex(index);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//Provides: caml_binaryen_set_start
|
|
41
|
+
function caml_binaryen_set_start(wasm_mod, func) {
|
|
42
|
+
return wasm_mod.setStart(func);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
//Provides: caml_binaryen_function_set_debug_location
|
|
46
|
+
//Requires: binaryen
|
|
47
|
+
function caml_binaryen_function_set_debug_location(func, exp, file, line, column) {
|
|
48
|
+
return binaryen._BinaryenFunctionSetDebugLocation(func, exp, file, line, column);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//Provides: caml_binaryen_function_get_name
|
|
52
|
+
//Requires: binaryen
|
|
53
|
+
//Requires: caml_string_of_jsstring
|
|
54
|
+
function caml_binaryen_function_get_name(func) {
|
|
55
|
+
return caml_string_of_jsstring(binaryen.Function.getName(func));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//Provides: caml_binaryen_function_get_params
|
|
59
|
+
//Requires: binaryen
|
|
60
|
+
function caml_binaryen_function_get_params(func) {
|
|
61
|
+
return binaryen.Function.getParams(func);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//Provides: caml_binaryen_function_get_results
|
|
65
|
+
//Requires: binaryen
|
|
66
|
+
function caml_binaryen_function_get_results(func) {
|
|
67
|
+
return binaryen.Function.getResults(func);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//Provides: caml_binaryen_function_get_num_vars
|
|
71
|
+
//Requires: binaryen
|
|
72
|
+
function caml_binaryen_function_get_num_vars(func) {
|
|
73
|
+
return binaryen.Function.getNumVars(func);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//Provides: caml_binaryen_function_get_var
|
|
77
|
+
//Requires: binaryen
|
|
78
|
+
function caml_binaryen_function_get_var(func, index) {
|
|
79
|
+
return binaryen.Function.getVar(func, index);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//Provides: caml_binaryen_function_get_body
|
|
83
|
+
//Requires: binaryen
|
|
84
|
+
function caml_binaryen_function_get_body(func) {
|
|
85
|
+
return binaryen.Function.getBody(func);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//Provides: caml_binaryen_function_set_body
|
|
89
|
+
//Requires: binaryen
|
|
90
|
+
function caml_binaryen_function_set_body(func, body) {
|
|
91
|
+
return binaryen.Function.setBody(func, body);
|
|
92
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
//Provides: caml_binaryen_add_global
|
|
2
|
+
//Requires: caml_jsstring_of_string
|
|
3
|
+
function caml_binaryen_add_global(wasm_mod, name, typ, is_mut, init) {
|
|
4
|
+
return wasm_mod.addGlobal(
|
|
5
|
+
caml_jsstring_of_string(name),
|
|
6
|
+
typ,
|
|
7
|
+
is_mut, // bool will come through as an int
|
|
8
|
+
init
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//Provides: caml_binaryen_get_global
|
|
13
|
+
//Requires: caml_jsstring_of_string
|
|
14
|
+
function caml_binaryen_get_global(wasm_mod, name) {
|
|
15
|
+
return wasm_mod.getGlobal(caml_jsstring_of_string(name));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//Provides: caml_binaryen_remove_global
|
|
19
|
+
//Requires: caml_jsstring_of_string
|
|
20
|
+
function caml_binaryen_remove_global(wasm_mod, name) {
|
|
21
|
+
return wasm_mod.removeGlobal(caml_jsstring_of_string(name));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//Provides: caml_binaryen_get_num_globals
|
|
25
|
+
function caml_binaryen_get_num_globals(wasm_mod) {
|
|
26
|
+
return wasm_mod.getNumGlobals();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//Provides: caml_binaryen_get_global_by_index
|
|
30
|
+
function caml_binaryen_get_global_by_index(wasm_mod, index) {
|
|
31
|
+
return wasm_mod.getGlobalByIndex(index);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//Provides: caml_binaryen_global_get_name
|
|
35
|
+
//Requires: binaryen
|
|
36
|
+
//Requires: caml_string_of_jsstring
|
|
37
|
+
function caml_binaryen_global_get_name(global) {
|
|
38
|
+
var global_info = binaryen.getGlobalInfo(global);
|
|
39
|
+
return caml_string_of_jsstring(global_info.name);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//Provides: caml_binaryen_global_get_type
|
|
43
|
+
//Requires: binaryen
|
|
44
|
+
function caml_binaryen_global_get_type(global) {
|
|
45
|
+
var global_info = binaryen.getGlobalInfo(global);
|
|
46
|
+
return global_info.type;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//Provides: caml_binaryen_global_is_mutable
|
|
50
|
+
//Requires: binaryen
|
|
51
|
+
//Requires: caml_js_to_bool
|
|
52
|
+
function caml_binaryen_global_is_mutable(global) {
|
|
53
|
+
var global_info = binaryen.getGlobalInfo(global);
|
|
54
|
+
return caml_js_to_bool(global_info.mutable);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//Provides: caml_binaryen_global_get_init_expr
|
|
58
|
+
//Requires: binaryen
|
|
59
|
+
function caml_binaryen_global_get_init_expr(global) {
|
|
60
|
+
var global_info = binaryen.getGlobalInfo(global);
|
|
61
|
+
return global_info.init;
|
|
62
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//Provides: caml_binaryen_add_function_import
|
|
2
|
+
//Requires: caml_jsstring_of_string
|
|
3
|
+
function caml_binaryen_add_function_import(wasm_mod, internalName, externalModuleName, externalBaseName, paramsty, resultsty) {
|
|
4
|
+
return wasm_mod.addFunctionImport(
|
|
5
|
+
caml_jsstring_of_string(internalName),
|
|
6
|
+
caml_jsstring_of_string(externalModuleName),
|
|
7
|
+
caml_jsstring_of_string(externalBaseName),
|
|
8
|
+
paramsty,
|
|
9
|
+
resultsty
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
//Provides: caml_binaryen_add_function_import__bytecode
|
|
13
|
+
//Requires: caml_binaryen_add_function_import
|
|
14
|
+
function caml_binaryen_add_function_import__bytecode() {
|
|
15
|
+
return caml_binaryen_add_function_import(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//Provides: caml_binaryen_add_table_import
|
|
19
|
+
//Requires: caml_jsstring_of_string
|
|
20
|
+
function caml_binaryen_add_table_import(wasm_mod, internalName, externalModuleName, externalBaseName) {
|
|
21
|
+
return wasm_mod.addTableImport(
|
|
22
|
+
caml_jsstring_of_string(internalName),
|
|
23
|
+
caml_jsstring_of_string(externalModuleName),
|
|
24
|
+
caml_jsstring_of_string(externalBaseName)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//Provides: caml_binaryen_add_memory_import
|
|
29
|
+
//Requires: caml_jsstring_of_string
|
|
30
|
+
function caml_binaryen_add_memory_import(wasm_mod, internalName, externalModuleName, externalBaseName, shared) {
|
|
31
|
+
return wasm_mod.addMemoryImport(
|
|
32
|
+
caml_jsstring_of_string(internalName),
|
|
33
|
+
caml_jsstring_of_string(externalModuleName),
|
|
34
|
+
caml_jsstring_of_string(externalBaseName),
|
|
35
|
+
shared // bool will come through as an int
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//Provides: caml_binaryen_add_global_import
|
|
40
|
+
//Requires: caml_jsstring_of_string
|
|
41
|
+
function caml_binaryen_add_global_import(wasm_mod, internalName, externalModuleName, externalBaseName, typ, is_mut) {
|
|
42
|
+
return wasm_mod.addGlobalImport(
|
|
43
|
+
caml_jsstring_of_string(internalName),
|
|
44
|
+
caml_jsstring_of_string(externalModuleName),
|
|
45
|
+
caml_jsstring_of_string(externalBaseName),
|
|
46
|
+
typ,
|
|
47
|
+
is_mut // bool will come through as an int
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
//Provides: caml_binaryen_add_global_import__bytecode
|
|
51
|
+
//Requires: caml_binaryen_add_global_import
|
|
52
|
+
function caml_binaryen_add_global_import__bytecode() {
|
|
53
|
+
return caml_binaryen_add_global_import(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//Provides: caml_binaryen_function_import_get_module
|
|
57
|
+
//Requires: binaryen
|
|
58
|
+
//Requires: caml_string_of_jsstring
|
|
59
|
+
function caml_binaryen_function_import_get_module(func) {
|
|
60
|
+
var func_info = binaryen.getFunctionInfo(func);
|
|
61
|
+
return caml_string_of_jsstring(func_info.module);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
//Provides: caml_binaryen_global_import_get_module
|
|
65
|
+
//Requires: binaryen
|
|
66
|
+
//Requires: caml_string_of_jsstring
|
|
67
|
+
function caml_binaryen_global_import_get_module(global) {
|
|
68
|
+
var global_info = binaryen.getGlobalInfo(global);
|
|
69
|
+
return caml_string_of_jsstring(global_info.module);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//Provides: caml_binaryen_function_import_get_base
|
|
73
|
+
//Requires: binaryen
|
|
74
|
+
//Requires: caml_string_of_jsstring
|
|
75
|
+
function caml_binaryen_function_import_get_base(func) {
|
|
76
|
+
var func_info = binaryen.getFunctionInfo(func);
|
|
77
|
+
return caml_string_of_jsstring(func_info.base);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//Provides: caml_binaryen_global_import_get_base
|
|
81
|
+
//Requires: binaryen
|
|
82
|
+
//Requires: caml_string_of_jsstring
|
|
83
|
+
function caml_binaryen_global_import_get_base(global) {
|
|
84
|
+
var global_info = binaryen.getGlobalInfo(global);
|
|
85
|
+
return caml_string_of_jsstring(global_info.base);
|
|
86
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//Provides: caml_binaryen_literal_int32
|
|
2
|
+
function caml_binaryen_literal_int32(i32) {
|
|
3
|
+
// Hack around Binaryen.js
|
|
4
|
+
return { type: 'int32', value: i32 };
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//Provides: caml_binaryen_literal_int64
|
|
8
|
+
function caml_binaryen_literal_int64(i64) {
|
|
9
|
+
// Hack around Binaryen.js
|
|
10
|
+
return { type: 'int64', value: i64 };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//Provides: caml_binaryen_literal_float64
|
|
14
|
+
function caml_binaryen_literal_float64(f64) {
|
|
15
|
+
// Hack around Binaryen.js
|
|
16
|
+
return { type: 'float64', value: f64 };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//Provides: caml_binaryen_literal_float32_bits
|
|
20
|
+
function caml_binaryen_literal_float32_bits(i32) {
|
|
21
|
+
// Hack around Binaryen.js
|
|
22
|
+
return { type: 'float32_bits', value: i32 };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//Provides: caml_binaryen_literal_float64_bits
|
|
26
|
+
function caml_binaryen_literal_float64_bits(i64) {
|
|
27
|
+
// Hack around Binaryen.js
|
|
28
|
+
return { type: 'float64_bits', value: i64 };
|
|
29
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//Provides: caml_binaryen_set_memory
|
|
2
|
+
//Requires: caml_list_to_js_array, caml_convert_bytes_to_array
|
|
3
|
+
//Requires: caml_jsstring_of_string, caml_js_from_bool
|
|
4
|
+
function caml_binaryen_set_memory(wasm_mod, initial, maximum, exportName, segments, segmentPassives, segmentOffsets, segmentSizes, shared) {
|
|
5
|
+
var segs = caml_list_to_js_array(segments).map(function (segment, idx) {
|
|
6
|
+
return {
|
|
7
|
+
data: caml_convert_bytes_to_array(segment),
|
|
8
|
+
passive: segmentPassives[idx + 1], // OCaml Lists are offset by 1
|
|
9
|
+
offset: segmentOffsets[idx + 1] // OCaml Lists are offset by 1
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return wasm_mod.setMemory(
|
|
14
|
+
initial,
|
|
15
|
+
maximum,
|
|
16
|
+
caml_jsstring_of_string(exportName),
|
|
17
|
+
segs,
|
|
18
|
+
caml_js_from_bool(shared)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
//Provides: caml_binaryen_set_memory__bytecode
|
|
22
|
+
//Requires: caml_binaryen_set_memory
|
|
23
|
+
function caml_binaryen_set_memory__bytecode() {
|
|
24
|
+
return caml_binaryen_set_memory(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], arguments[8]);
|
|
25
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
//Provides: caml_binaryen_module_create
|
|
2
|
+
//Requires: binaryen
|
|
3
|
+
function caml_binaryen_module_create() {
|
|
4
|
+
return new binaryen.Module();
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
//Provides: caml_binaryen_module_dispose
|
|
8
|
+
function caml_binaryen_module_dispose(wasm_mod) {
|
|
9
|
+
return wasm_mod.dispose();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//Provides: caml_binaryen_module_parse
|
|
13
|
+
//Requires: binaryen
|
|
14
|
+
//Requires: caml_jsstring_of_string
|
|
15
|
+
function caml_binaryen_module_parse(text) {
|
|
16
|
+
return binaryen.parseText(caml_jsstring_of_string(text));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//Provides: caml_binaryen_module_print
|
|
20
|
+
//Requires: caml_string_of_jsstring
|
|
21
|
+
//Requires: caml_ml_output, caml_ml_string_length
|
|
22
|
+
function caml_binaryen_module_print(wasm_mod) {
|
|
23
|
+
var text = wasm_mod.emitText();
|
|
24
|
+
var chanid = 1; // stdout
|
|
25
|
+
var s = caml_string_of_jsstring(text);
|
|
26
|
+
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//Provides: caml_binaryen_module_print_asmjs
|
|
30
|
+
//Requires: caml_string_of_jsstring
|
|
31
|
+
//Requires: caml_ml_output, caml_ml_string_length
|
|
32
|
+
function caml_binaryen_module_print_asmjs(wasm_mod) {
|
|
33
|
+
var asm = wasm_mod.emitAsmjs();
|
|
34
|
+
var chanid = 1; // stdout
|
|
35
|
+
var s = caml_string_of_jsstring(asm);
|
|
36
|
+
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//Provides: caml_binaryen_module_validate
|
|
40
|
+
function caml_binaryen_module_validate(wasm_mod) {
|
|
41
|
+
return wasm_mod.validate();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//Provides: caml_binaryen_module_optimize
|
|
45
|
+
function caml_binaryen_module_optimize(wasm_mod) {
|
|
46
|
+
return wasm_mod.optimize();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//Provides: caml_binaryen_module_run_passes
|
|
50
|
+
//Requires: caml_jsstring_of_string, caml_list_to_js_array
|
|
51
|
+
function caml_binaryen_module_run_passes(wasm_mod, passes) {
|
|
52
|
+
return wasm_mod.runPasses(
|
|
53
|
+
caml_list_to_js_array(passes).map(caml_jsstring_of_string)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//Provides: caml_binaryen_module_auto_drop
|
|
58
|
+
function caml_binaryen_module_auto_drop(wasm_mod) {
|
|
59
|
+
return wasm_mod.autoDrop();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//Provides: caml_binaryen_module_write
|
|
63
|
+
//Requires: to_option
|
|
64
|
+
//Requires: caml_jsstring_of_string, caml_string_of_jsstring, caml_bytes_of_array
|
|
65
|
+
function caml_binaryen_module_write(wasm_mod, sourceMapUrl) {
|
|
66
|
+
if (sourceMapUrl) {
|
|
67
|
+
var url = caml_jsstring_of_string(sourceMapUrl[1]);
|
|
68
|
+
var obj = wasm_mod.emitBinary(url);
|
|
69
|
+
var sourceMap = obj.sourceMap != null ? caml_string_of_jsstring(obj.sourceMap) : null;
|
|
70
|
+
return [0, caml_bytes_of_array(obj.binary), to_option(sourceMap)];
|
|
71
|
+
} else {
|
|
72
|
+
var binary = wasm_mod.emitBinary();
|
|
73
|
+
return [0, caml_bytes_of_array(binary), 0];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//Provides: caml_binaryen_module_write_text
|
|
78
|
+
//Requires: caml_string_of_jsstring
|
|
79
|
+
function caml_binaryen_module_write_text(wasm_mod) {
|
|
80
|
+
var text = wasm_mod.emitText();
|
|
81
|
+
return caml_string_of_jsstring(text);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//Provides: caml_binaryen_module_read
|
|
85
|
+
//Requires: binaryen
|
|
86
|
+
//Requires: caml_array_of_bytes
|
|
87
|
+
function caml_binaryen_module_read(bytes) {
|
|
88
|
+
var data = caml_array_of_bytes(bytes)
|
|
89
|
+
return binaryen.readBinary(data);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//Provides: caml_binaryen_module_interpret
|
|
93
|
+
function caml_binaryen_module_interpret(wasm_mod) {
|
|
94
|
+
return wasm_mod.interpret();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//Provides: caml_binaryen_module_add_debug_info_filename
|
|
98
|
+
//Requires: caml_jsstring_of_string
|
|
99
|
+
function caml_binaryen_module_add_debug_info_filename(wasm_mod, filename) {
|
|
100
|
+
return wasm_mod.addDebugInfoFileName(caml_jsstring_of_string(filename));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
//Provides: caml_binaryen_module_get_debug_info_filename
|
|
104
|
+
function caml_binaryen_module_get_debug_info_filename(wasm_mod, index) {
|
|
105
|
+
return wasm_mod.getDebugInfoFileName(index);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//Provides: caml_binaryen_add_custom_section
|
|
109
|
+
//Requires: caml_jsstring_of_string, caml_array_of_string
|
|
110
|
+
function caml_binaryen_add_custom_section(wasm_mod, name, contents) {
|
|
111
|
+
return wasm_mod.addCustomSection(
|
|
112
|
+
caml_jsstring_of_string(name),
|
|
113
|
+
caml_array_of_string(contents)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
//Provides: caml_binaryen_module_update_maps
|
|
118
|
+
function caml_binaryen_module_update_maps(wasm_mod) {
|
|
119
|
+
// The JS version doesn't expose `update_maps`
|
|
120
|
+
return;
|
|
121
|
+
}
|