@grain/binaryen.ml 0.34.0 → 0.36.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 +37 -0
- binaryen-archive/binaryen.opam +3 -3
- binaryen-archive/esy.lock/index.json +366 -391
- binaryen-archive/esy.lock/opam/base.v0.17.3/opam +5 -3
- binaryen-archive/esy.lock/opam/{chrome-trace.3.20.2 → chrome-trace.3.24.1}/opam +6 -8
- binaryen-archive/esy.lock/opam/{cmdliner.1.3.0 → cmdliner.2.1.1}/opam +26 -10
- binaryen-archive/esy.lock/opam/{dune-build-info.3.20.2 → dune-build-info.3.24.2}/opam +6 -8
- binaryen-archive/esy.lock/opam/{dune-configurator.3.20.2 → dune-configurator.3.24.2}/opam +6 -8
- binaryen-archive/esy.lock/opam/{dune.3.20.2 → dune.3.24.2}/opam +15 -10
- binaryen-archive/esy.lock/opam/fix.20250919/opam +1 -0
- binaryen-archive/esy.lock/opam/js_of_ocaml-compiler.6.4.1/opam +67 -0
- binaryen-archive/esy.lock/opam/{menhir.20250912 → menhir.20260209}/opam +6 -4
- binaryen-archive/esy.lock/opam/{menhirCST.20250912 → menhirCST.20260209}/opam +4 -3
- binaryen-archive/esy.lock/opam/menhirGLR.20260209/opam +30 -0
- binaryen-archive/esy.lock/opam/{menhirLib.20250912 → menhirLib.20260209}/opam +5 -4
- binaryen-archive/esy.lock/opam/{menhirSdk.20250912 → menhirSdk.20260209}/opam +5 -4
- binaryen-archive/esy.lock/opam/ocaml-lsp-server.1.23.1/opam +2 -2
- binaryen-archive/esy.lock/opam/{ocaml-version.4.0.3 → ocaml-version.4.1.3}/opam +3 -3
- binaryen-archive/esy.lock/opam/{ocaml_intrinsics_kernel.v0.17.1 → ocaml_intrinsics_kernel.v0.17.2}/opam +3 -3
- binaryen-archive/esy.lock/opam/ocamlbuild.0.16.1/opam +1 -0
- binaryen-archive/esy.lock/opam/ocamlfind.1.9.8/opam +2 -1
- binaryen-archive/esy.lock/opam/{ocamlformat-lib.0.27.0 → ocamlformat-lib.0.29.0}/opam +7 -6
- binaryen-archive/esy.lock/opam/{ocamlformat-rpc-lib.0.28.1 → ocamlformat-rpc-lib.0.29.0}/opam +4 -4
- binaryen-archive/esy.lock/opam/{ocamlformat.0.27.0 → ocamlformat.0.29.0}/opam +6 -5
- binaryen-archive/esy.lock/opam/{ocp-indent.1.7.0 → ocp-indent.1.9.0}/opam +10 -9
- binaryen-archive/esy.lock/opam/ppx_yojson_conv_lib.v0.17.0/opam +2 -0
- binaryen-archive/esy.lock/opam/{ppxlib.0.37.0 → ppxlib.0.39.0~5.6preview}/opam +12 -13
- binaryen-archive/esy.lock/opam/sexplib0.v0.17.0/opam +2 -0
- binaryen-archive/esy.lock/opam/stdio.v0.17.0/opam +3 -1
- binaryen-archive/esy.lock/opam/{xdg.3.20.2 → xdg.3.24.2}/opam +6 -8
- binaryen-archive/package.json +9 -5
- binaryen-archive/src/dune +6 -1
- binaryen-archive/src/export.c +10 -0
- binaryen-archive/src/export.js +13 -0
- binaryen-archive/src/export.ml +4 -0
- binaryen-archive/src/export.mli +1 -0
- binaryen-archive/src/expression.c +636 -0
- binaryen-archive/src/expression.js +423 -7
- binaryen-archive/src/expression.ml +224 -0
- binaryen-archive/src/expression.mli +159 -0
- binaryen-archive/src/heap_type.c +19 -0
- binaryen-archive/src/heap_type.js +12 -0
- binaryen-archive/src/heap_type.ml +10 -1
- binaryen-archive/src/heap_type.mli +8 -1
- binaryen-archive/src/import.c +32 -0
- binaryen-archive/src/import.js +47 -0
- binaryen-archive/src/import.ml +12 -0
- binaryen-archive/src/import.mli +5 -0
- binaryen-archive/src/memory.c +6 -1
- binaryen-archive/src/memory.js +2 -2
- binaryen-archive/src/memory.ml +1 -1
- binaryen-archive/src/memory.mli +1 -1
- binaryen-archive/src/module.js +9 -22
- binaryen-archive/src/module.ml +4 -0
- binaryen-archive/src/module.mli +1 -0
- binaryen-archive/src/module_feature.c +6 -0
- binaryen-archive/src/module_feature.js +6 -0
- binaryen-archive/src/ocaml_helpers.c +17 -0
- binaryen-archive/src/ocaml_helpers.h +9 -0
- binaryen-archive/src/ocaml_helpers.js +11 -0
- binaryen-archive/src/passes.ml +13 -11
- binaryen-archive/src/passes.mli +13 -11
- binaryen-archive/src/tag.c +61 -0
- binaryen-archive/src/tag.js +43 -0
- binaryen-archive/src/tag.ml +11 -0
- binaryen-archive/src/tag.mli +8 -0
- binaryen-archive/src/type.c +5 -3
- binaryen-archive/src/type.js +5 -9
- binaryen-archive/src/type.ml +4 -1
- binaryen-archive/src/type.mli +1 -1
- binaryen-archive/src/type_builder.c +180 -0
- binaryen-archive/src/type_builder.js +116 -0
- binaryen-archive/src/type_builder.ml +67 -0
- binaryen-archive/src/type_builder.mli +28 -0
- binaryen-archive/test/test.expected +323 -33
- binaryen-archive/test/test.ml +220 -4
- binaryen-archive/esy.lock/opam/base-bytes.base/opam +0 -10
- binaryen-archive/esy.lock/opam/js_of_ocaml-compiler.6.2.0/opam +0 -56
- binaryen-archive/esy.lock/opam/stdlib-shims.0.3.0/opam +0 -31
|
@@ -124,6 +124,38 @@ caml_binaryen_call_indirect__bytecode(value * argv) {
|
|
|
124
124
|
return caml_binaryen_call_indirect(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
CAMLprim value
|
|
128
|
+
caml_binaryen_call_ref(value _module, value _target, value _params, value _ty) {
|
|
129
|
+
CAMLparam4(_module, _target, _params, _ty);
|
|
130
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
131
|
+
BinaryenExpressionRef target = BinaryenExpressionRef_val(_target);
|
|
132
|
+
_params = array_of_list(_params);
|
|
133
|
+
int paramsLen = array_length(_params);
|
|
134
|
+
BinaryenExpressionRef params[paramsLen];
|
|
135
|
+
for (int i = 0; i < paramsLen; i++) {
|
|
136
|
+
params[i] = BinaryenExpressionRef_val(Field(_params, i));
|
|
137
|
+
}
|
|
138
|
+
BinaryenType ty = BinaryenType_val(_ty);
|
|
139
|
+
BinaryenExpressionRef exp = BinaryenCallRef(module, target, params, paramsLen, ty);
|
|
140
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
CAMLprim value
|
|
144
|
+
caml_binaryen_return_call_ref(value _module, value _target, value _params, value _ty) {
|
|
145
|
+
CAMLparam4(_module, _target, _params, _ty);
|
|
146
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
147
|
+
BinaryenExpressionRef target = BinaryenExpressionRef_val(_target);
|
|
148
|
+
_params = array_of_list(_params);
|
|
149
|
+
int paramsLen = array_length(_params);
|
|
150
|
+
BinaryenExpressionRef params[paramsLen];
|
|
151
|
+
for (int i = 0; i < paramsLen; i++) {
|
|
152
|
+
params[i] = BinaryenExpressionRef_val(Field(_params, i));
|
|
153
|
+
}
|
|
154
|
+
BinaryenType ty = BinaryenType_val(_ty);
|
|
155
|
+
BinaryenExpressionRef exp = BinaryenReturnCallRef(module, target, params, paramsLen, ty);
|
|
156
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
157
|
+
}
|
|
158
|
+
|
|
127
159
|
CAMLprim value
|
|
128
160
|
caml_binaryen_return_call(value _module, value _name, value _params, value _retty) {
|
|
129
161
|
CAMLparam4(_module, _name, _params, _retty);
|
|
@@ -459,6 +491,38 @@ caml_binaryen_i31_get(value _module, value _val, value _signed) {
|
|
|
459
491
|
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
460
492
|
}
|
|
461
493
|
|
|
494
|
+
CAMLprim value
|
|
495
|
+
caml_binaryen_ref_test(value _module, value _ref, value _castType) {
|
|
496
|
+
CAMLparam3(_module, _ref, _castType);
|
|
497
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
498
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
499
|
+
BinaryenType castType = BinaryenType_val(_castType);
|
|
500
|
+
BinaryenExpressionRef exp = BinaryenRefTest(module, ref, castType);
|
|
501
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
CAMLprim value
|
|
505
|
+
caml_binaryen_ref_cast(value _module, value _ref, value _castType) {
|
|
506
|
+
CAMLparam3(_module, _ref, _castType);
|
|
507
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
508
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
509
|
+
BinaryenType castType = BinaryenType_val(_castType);
|
|
510
|
+
BinaryenExpressionRef exp = BinaryenRefCast(module, ref, castType);
|
|
511
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
CAMLprim value
|
|
515
|
+
caml_binaryen_br_on(value _module, value _op, value _name, value _ref, value _castType) {
|
|
516
|
+
CAMLparam5(_module, _op, _name, _ref, _castType);
|
|
517
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
518
|
+
BinaryenOp op = BinaryenOp_val(_op);
|
|
519
|
+
char* name = Safe_String_val(_name);
|
|
520
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
521
|
+
BinaryenType castType = BinaryenType_val(_castType);
|
|
522
|
+
BinaryenExpressionRef exp = BinaryenBrOn(module, op, name, ref, castType);
|
|
523
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
524
|
+
}
|
|
525
|
+
|
|
462
526
|
CAMLprim value
|
|
463
527
|
caml_binaryen_expression_id_invalid(value unit) {
|
|
464
528
|
CAMLparam1(unit);
|
|
@@ -1328,6 +1392,90 @@ caml_binaryen_call_indirect_set_return(value _exp, value _isReturn) {
|
|
|
1328
1392
|
CAMLreturn(Val_unit);
|
|
1329
1393
|
}
|
|
1330
1394
|
|
|
1395
|
+
CAMLprim value
|
|
1396
|
+
caml_binaryen_call_ref_get_target(value _exp) {
|
|
1397
|
+
CAMLparam1(_exp);
|
|
1398
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1399
|
+
BinaryenExpressionRef target = BinaryenCallRefGetTarget(exp);
|
|
1400
|
+
CAMLreturn(alloc_BinaryenExpressionRef(target));
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
CAMLprim value
|
|
1404
|
+
caml_binaryen_call_ref_set_target(value _exp, value _target) {
|
|
1405
|
+
CAMLparam2(_exp, _target);
|
|
1406
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1407
|
+
BinaryenExpressionRef target = BinaryenExpressionRef_val(_target);
|
|
1408
|
+
BinaryenCallRefSetTarget(exp, target);
|
|
1409
|
+
CAMLreturn(Val_unit);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
CAMLprim value
|
|
1413
|
+
caml_binaryen_call_ref_get_num_operands(value _exp) {
|
|
1414
|
+
CAMLparam1(_exp);
|
|
1415
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1416
|
+
CAMLreturn(Val_int(BinaryenCallRefGetNumOperands(exp)));
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
CAMLprim value
|
|
1420
|
+
caml_binaryen_call_ref_get_operand_at(value _exp, value _index) {
|
|
1421
|
+
CAMLparam2(_exp, _index);
|
|
1422
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1423
|
+
BinaryenIndex index = Int_val(_index);
|
|
1424
|
+
CAMLreturn(alloc_BinaryenExpressionRef(BinaryenCallRefGetOperandAt(exp, index)));
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
CAMLprim value
|
|
1428
|
+
caml_binaryen_call_ref_set_operand_at(value _exp, value _index, value _operand) {
|
|
1429
|
+
CAMLparam3(_exp, _index, _operand);
|
|
1430
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1431
|
+
BinaryenIndex index = Int_val(_index);
|
|
1432
|
+
BinaryenExpressionRef operand = BinaryenExpressionRef_val(_operand);
|
|
1433
|
+
BinaryenCallRefSetOperandAt(exp, index, operand);
|
|
1434
|
+
CAMLreturn(Val_unit);
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
CAMLprim value
|
|
1438
|
+
caml_binaryen_call_ref_append_operand(value _exp, value _operand) {
|
|
1439
|
+
CAMLparam2(_exp, _operand);
|
|
1440
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1441
|
+
BinaryenExpressionRef operand = BinaryenExpressionRef_val(_operand);
|
|
1442
|
+
CAMLreturn(Val_int(BinaryenCallRefAppendOperand(exp, operand)));
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
CAMLprim value
|
|
1446
|
+
caml_binaryen_call_ref_insert_operand_at(value _exp, value _index, value _operand) {
|
|
1447
|
+
CAMLparam3(_exp, _index, _operand);
|
|
1448
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1449
|
+
BinaryenIndex index = Int_val(_index);
|
|
1450
|
+
BinaryenExpressionRef operand = BinaryenExpressionRef_val(_operand);
|
|
1451
|
+
BinaryenCallRefInsertOperandAt(exp, index, operand);
|
|
1452
|
+
CAMLreturn(Val_unit);
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
CAMLprim value
|
|
1456
|
+
caml_binaryen_call_ref_remove_operand_at(value _exp, value _index) {
|
|
1457
|
+
CAMLparam2(_exp, _index);
|
|
1458
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1459
|
+
BinaryenIndex index = Int_val(_index);
|
|
1460
|
+
CAMLreturn(alloc_BinaryenExpressionRef(BinaryenCallRefRemoveOperandAt(exp, index)));
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
CAMLprim value
|
|
1464
|
+
caml_binaryen_call_ref_is_return(value _exp) {
|
|
1465
|
+
CAMLparam1(_exp);
|
|
1466
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1467
|
+
CAMLreturn(Val_bool(BinaryenCallRefIsReturn(exp)));
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
CAMLprim value
|
|
1471
|
+
caml_binaryen_call_ref_set_return(value _exp, value _isReturn) {
|
|
1472
|
+
CAMLparam2(_exp, _isReturn);
|
|
1473
|
+
BinaryenExpressionRef exp = BinaryenExpressionRef_val(_exp);
|
|
1474
|
+
int isReturn = Bool_val(_isReturn);
|
|
1475
|
+
BinaryenCallRefSetReturn(exp, isReturn);
|
|
1476
|
+
CAMLreturn(Val_unit);
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1331
1479
|
CAMLprim value
|
|
1332
1480
|
caml_binaryen_local_set_get_value(value _exp) {
|
|
1333
1481
|
CAMLparam1(_exp);
|
|
@@ -1883,6 +2031,494 @@ caml_binaryen_ref_eq(value _module, value _left, value _right) {
|
|
|
1883
2031
|
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
1884
2032
|
}
|
|
1885
2033
|
|
|
2034
|
+
// Struct operations
|
|
2035
|
+
|
|
2036
|
+
CAMLprim value
|
|
2037
|
+
caml_binaryen_struct_new(value _module, value _operands, value _type) {
|
|
2038
|
+
CAMLparam3(_module, _operands, _type);
|
|
2039
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2040
|
+
BinaryenHeapType type = BinaryenHeapType_val(_type);
|
|
2041
|
+
if (Is_some(_operands)) {
|
|
2042
|
+
_operands = array_of_list(Some_val(_operands));
|
|
2043
|
+
int operandsLen = array_length(_operands);
|
|
2044
|
+
BinaryenExpressionRef operands[operandsLen];
|
|
2045
|
+
for (int i = 0; i < operandsLen; i++) {
|
|
2046
|
+
operands[i] = BinaryenExpressionRef_val(Field(_operands, i));
|
|
2047
|
+
}
|
|
2048
|
+
BinaryenExpressionRef exp = BinaryenStructNew(module, operands, operandsLen, type);
|
|
2049
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2050
|
+
} else {
|
|
2051
|
+
BinaryenExpressionRef exp = BinaryenStructNew(module, NULL, 0, type);
|
|
2052
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
2055
|
+
|
|
2056
|
+
CAMLprim value
|
|
2057
|
+
caml_binaryen_struct_get(value _module, value _index, value _ref, value _type, value _signed) {
|
|
2058
|
+
CAMLparam5(_module, _index, _ref, _type, _signed);
|
|
2059
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2060
|
+
BinaryenIndex index = Int_val(_index);
|
|
2061
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
2062
|
+
BinaryenType type = BinaryenType_val(_type);
|
|
2063
|
+
bool signed_ = Bool_val(_signed);
|
|
2064
|
+
BinaryenExpressionRef exp = BinaryenStructGet(module, index, ref, type, signed_);
|
|
2065
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
CAMLprim value
|
|
2069
|
+
caml_binaryen_struct_set(value _module, value _index, value _ref, value _value) {
|
|
2070
|
+
CAMLparam4(_module, _index, _ref, _value);
|
|
2071
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2072
|
+
BinaryenIndex index = Int_val(_index);
|
|
2073
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
2074
|
+
BinaryenExpressionRef value_ = BinaryenExpressionRef_val(_value);
|
|
2075
|
+
BinaryenExpressionRef exp = BinaryenStructSet(module, index, ref, value_);
|
|
2076
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
// Array operations
|
|
2080
|
+
|
|
2081
|
+
CAMLprim value
|
|
2082
|
+
caml_binaryen_array_new(value _module, value _type, value _size, value _init) {
|
|
2083
|
+
CAMLparam4(_module, _type, _size, _init);
|
|
2084
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2085
|
+
BinaryenHeapType type = BinaryenHeapType_val(_type);
|
|
2086
|
+
BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
|
|
2087
|
+
BinaryenExpressionRef init = BinaryenExpressionRef_val(_init);
|
|
2088
|
+
BinaryenExpressionRef exp = BinaryenArrayNew(module, type, size, init);
|
|
2089
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
CAMLprim value
|
|
2093
|
+
caml_binaryen_array_new_data(value _module, value _type, value _name, value _offset, value _size) {
|
|
2094
|
+
CAMLparam5(_module, _type, _name, _offset, _size);
|
|
2095
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2096
|
+
BinaryenHeapType type = BinaryenHeapType_val(_type);
|
|
2097
|
+
char* name = Safe_String_val(_name);
|
|
2098
|
+
BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
|
|
2099
|
+
BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
|
|
2100
|
+
BinaryenExpressionRef exp = BinaryenArrayNewData(module, type, name, offset, size);
|
|
2101
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
CAMLprim value
|
|
2105
|
+
caml_binaryen_array_new_elem(value _module, value _type, value _seg, value _offset, value _size) {
|
|
2106
|
+
CAMLparam5(_module, _type, _seg, _offset, _size);
|
|
2107
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2108
|
+
BinaryenHeapType type = BinaryenHeapType_val(_type);
|
|
2109
|
+
char* seg = Safe_String_val(_seg);
|
|
2110
|
+
BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
|
|
2111
|
+
BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
|
|
2112
|
+
BinaryenExpressionRef exp = BinaryenArrayNewElem(module, type, seg, offset, size);
|
|
2113
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
CAMLprim value
|
|
2117
|
+
caml_binaryen_array_new_fixed(value _module, value _type, value _values) {
|
|
2118
|
+
CAMLparam3(_module, _type, _values);
|
|
2119
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2120
|
+
BinaryenHeapType type = BinaryenHeapType_val(_type);
|
|
2121
|
+
_values = array_of_list(_values);
|
|
2122
|
+
int valuesLen = array_length(_values);
|
|
2123
|
+
BinaryenExpressionRef values[valuesLen];
|
|
2124
|
+
for (int i = 0; i < valuesLen; i++) {
|
|
2125
|
+
values[i] = BinaryenExpressionRef_val(Field(_values, i));
|
|
2126
|
+
}
|
|
2127
|
+
BinaryenExpressionRef exp = BinaryenArrayNewFixed(module, type, values, valuesLen);
|
|
2128
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
CAMLprim value
|
|
2132
|
+
caml_binaryen_array_get(value _module, value _ref, value _index, value _type, value _signed) {
|
|
2133
|
+
CAMLparam5(_module, _ref, _index, _type, _signed);
|
|
2134
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2135
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
2136
|
+
BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
|
|
2137
|
+
BinaryenType type = BinaryenType_val(_type);
|
|
2138
|
+
bool signed_ = Bool_val(_signed);
|
|
2139
|
+
BinaryenExpressionRef exp = BinaryenArrayGet(module, ref, index, type, signed_);
|
|
2140
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2141
|
+
}
|
|
2142
|
+
|
|
2143
|
+
CAMLprim value
|
|
2144
|
+
caml_binaryen_array_set(value _module, value _ref, value _index, value _value) {
|
|
2145
|
+
CAMLparam4(_module, _ref, _index, _value);
|
|
2146
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2147
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
2148
|
+
BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
|
|
2149
|
+
BinaryenExpressionRef value_ = BinaryenExpressionRef_val(_value);
|
|
2150
|
+
BinaryenExpressionRef exp = BinaryenArraySet(module, ref, index, value_);
|
|
2151
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2152
|
+
}
|
|
2153
|
+
|
|
2154
|
+
CAMLprim value
|
|
2155
|
+
caml_binaryen_array_len(value _module, value _ref) {
|
|
2156
|
+
CAMLparam2(_module, _ref);
|
|
2157
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2158
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
2159
|
+
BinaryenExpressionRef exp = BinaryenArrayLen(module, ref);
|
|
2160
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2161
|
+
}
|
|
2162
|
+
|
|
2163
|
+
CAMLprim value
|
|
2164
|
+
caml_binaryen_array_copy(value _module, value _destRef, value _destIndex, value _srcRef, value _srcIndex, value _length) {
|
|
2165
|
+
CAMLparam5(_module, _destRef, _destIndex, _srcRef, _srcIndex);
|
|
2166
|
+
CAMLxparam1(_length);
|
|
2167
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2168
|
+
BinaryenExpressionRef destRef = BinaryenExpressionRef_val(_destRef);
|
|
2169
|
+
BinaryenExpressionRef destIndex = BinaryenExpressionRef_val(_destIndex);
|
|
2170
|
+
BinaryenExpressionRef srcRef = BinaryenExpressionRef_val(_srcRef);
|
|
2171
|
+
BinaryenExpressionRef srcIndex = BinaryenExpressionRef_val(_srcIndex);
|
|
2172
|
+
BinaryenExpressionRef length = BinaryenExpressionRef_val(_length);
|
|
2173
|
+
BinaryenExpressionRef exp = BinaryenArrayCopy(module, destRef, destIndex, srcRef, srcIndex, length);
|
|
2174
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2175
|
+
}
|
|
2176
|
+
CAMLprim value
|
|
2177
|
+
caml_binaryen_array_copy__bytecode(value * argv) {
|
|
2178
|
+
return caml_binaryen_array_copy(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
CAMLprim value
|
|
2182
|
+
caml_binaryen_array_fill(value _module, value _ref, value _index, value _value, value _size) {
|
|
2183
|
+
CAMLparam5(_module, _ref, _index, _value, _size);
|
|
2184
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2185
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
2186
|
+
BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
|
|
2187
|
+
BinaryenExpressionRef val = BinaryenExpressionRef_val(_value);
|
|
2188
|
+
BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
|
|
2189
|
+
BinaryenExpressionRef exp = BinaryenArrayFill(module, ref, index, val, size);
|
|
2190
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
CAMLprim value
|
|
2194
|
+
caml_binaryen_array_init_data(value _module, value _name, value _ref, value _index, value _offset, value _size) {
|
|
2195
|
+
CAMLparam5(_module, _name, _ref, _index, _offset);
|
|
2196
|
+
CAMLxparam1(_size);
|
|
2197
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2198
|
+
char* name = Safe_String_val(_name);
|
|
2199
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
2200
|
+
BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
|
|
2201
|
+
BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
|
|
2202
|
+
BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
|
|
2203
|
+
BinaryenExpressionRef exp = BinaryenArrayInitData(module, name, ref, index, offset, size);
|
|
2204
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
CAMLprim value
|
|
2208
|
+
caml_binaryen_array_init_data__bytecode(value * argv) {
|
|
2209
|
+
return caml_binaryen_array_init_data(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
2210
|
+
}
|
|
2211
|
+
|
|
2212
|
+
CAMLprim value
|
|
2213
|
+
caml_binaryen_array_init_elem(value _module, value _seg, value _ref, value _index, value _offset, value _size) {
|
|
2214
|
+
CAMLparam5(_module, _seg, _ref, _index, _offset);
|
|
2215
|
+
CAMLxparam1(_size);
|
|
2216
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2217
|
+
char* seg = Safe_String_val(_seg);
|
|
2218
|
+
BinaryenExpressionRef ref = BinaryenExpressionRef_val(_ref);
|
|
2219
|
+
BinaryenExpressionRef index = BinaryenExpressionRef_val(_index);
|
|
2220
|
+
BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset);
|
|
2221
|
+
BinaryenExpressionRef size = BinaryenExpressionRef_val(_size);
|
|
2222
|
+
BinaryenExpressionRef exp = BinaryenArrayInitElem(module, seg, ref, index, offset, size);
|
|
2223
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
CAMLprim value
|
|
2227
|
+
caml_binaryen_array_init_elem__bytecode(value * argv) {
|
|
2228
|
+
return caml_binaryen_array_init_elem(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
2229
|
+
}
|
|
2230
|
+
|
|
2231
|
+
// Exception handling operations
|
|
2232
|
+
CAMLprim value
|
|
2233
|
+
caml_binaryen_try(value _module, value _name, value _body, value _catchTags, value _catchBodies, value _delegateTarget) {
|
|
2234
|
+
CAMLparam5(_module, _name, _body, _catchTags, _catchBodies);
|
|
2235
|
+
CAMLxparam1(_delegateTarget);
|
|
2236
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2237
|
+
char *name;
|
|
2238
|
+
if (Is_none(_name)) {
|
|
2239
|
+
name = NULL;
|
|
2240
|
+
} else {
|
|
2241
|
+
name = Safe_String_val(Some_val(_name));
|
|
2242
|
+
}
|
|
2243
|
+
BinaryenExpressionRef body = BinaryenExpressionRef_val(_body);
|
|
2244
|
+
_catchTags = array_of_list(_catchTags);
|
|
2245
|
+
int catchTagsLen = array_length(_catchTags);
|
|
2246
|
+
const char* catchTags[catchTagsLen];
|
|
2247
|
+
for (int i = 0; i < catchTagsLen; i++) {
|
|
2248
|
+
catchTags[i] = Safe_String_val(Field(_catchTags, i));
|
|
2249
|
+
}
|
|
2250
|
+
_catchBodies = array_of_list(_catchBodies);
|
|
2251
|
+
int catchBodiesLen = array_length(_catchBodies);
|
|
2252
|
+
BinaryenExpressionRef catchBodies[catchBodiesLen];
|
|
2253
|
+
for (int i = 0; i < catchBodiesLen; i++) {
|
|
2254
|
+
catchBodies[i] = BinaryenExpressionRef_val(Field(_catchBodies, i));
|
|
2255
|
+
}
|
|
2256
|
+
char *delegateTarget;
|
|
2257
|
+
if (Is_none(_delegateTarget)) {
|
|
2258
|
+
delegateTarget = NULL;
|
|
2259
|
+
} else {
|
|
2260
|
+
delegateTarget = Safe_String_val(Some_val(_delegateTarget));
|
|
2261
|
+
}
|
|
2262
|
+
BinaryenExpressionRef exp = BinaryenTry(
|
|
2263
|
+
module,
|
|
2264
|
+
name,
|
|
2265
|
+
body,
|
|
2266
|
+
catchTags,
|
|
2267
|
+
catchTagsLen,
|
|
2268
|
+
catchBodies,
|
|
2269
|
+
catchBodiesLen,
|
|
2270
|
+
delegateTarget
|
|
2271
|
+
);
|
|
2272
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
CAMLprim value caml_binaryen_try__bytecode(value * argv) {
|
|
2276
|
+
return caml_binaryen_try(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
|
|
2277
|
+
}
|
|
2278
|
+
|
|
2279
|
+
CAMLprim value
|
|
2280
|
+
caml_binaryen_throw(value _module, value _tag, value _operands) {
|
|
2281
|
+
CAMLparam3(_module, _tag, _operands);
|
|
2282
|
+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
|
|
2283
|
+
char *tag = Safe_String_val(_tag);
|
|
2284
|
+
_operands = array_of_list(_operands);
|
|
2285
|
+
int operandsLen = array_length(_operands);
|
|
2286
|
+
BinaryenExpressionRef operands[operandsLen];
|
|
2287
|
+
for (int i = 0; i < operandsLen; i++) {
|
|
2288
|
+
operands[i] = BinaryenExpressionRef_val(Field(_operands, i));
|
|
2289
|
+
}
|
|
2290
|
+
BinaryenExpressionRef exp = BinaryenThrow(module, tag, operands, operandsLen);
|
|
2291
|
+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
CAMLprim value
|
|
2295
|
+
caml_binaryen_try_get_name(value _expr) {
|
|
2296
|
+
CAMLparam1(_expr);
|
|
2297
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2298
|
+
const char* name = BinaryenTryGetName(expr);
|
|
2299
|
+
if (name == NULL) {
|
|
2300
|
+
CAMLreturn(Val_none);
|
|
2301
|
+
} else {
|
|
2302
|
+
CAMLreturn(caml_alloc_some(caml_copy_string(name)));
|
|
2303
|
+
}
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
CAMLprim value
|
|
2307
|
+
caml_binaryen_try_set_name(value _expr, value _name) {
|
|
2308
|
+
CAMLparam2(_expr, _name);
|
|
2309
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2310
|
+
const char* name = Safe_String_val(_name);
|
|
2311
|
+
BinaryenTrySetName(expr, name);
|
|
2312
|
+
CAMLreturn(Val_unit);
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
CAMLprim value
|
|
2316
|
+
caml_binaryen_try_get_body(value _expr) {
|
|
2317
|
+
CAMLparam1(_expr);
|
|
2318
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2319
|
+
BinaryenExpressionRef binaryenRetVal = BinaryenTryGetBody(expr);
|
|
2320
|
+
CAMLreturn(alloc_BinaryenExpressionRef(binaryenRetVal));
|
|
2321
|
+
}
|
|
2322
|
+
|
|
2323
|
+
CAMLprim value
|
|
2324
|
+
caml_binaryen_try_set_body(value _expr, value _bodyExpr) {
|
|
2325
|
+
CAMLparam2(_expr, _bodyExpr);
|
|
2326
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2327
|
+
BinaryenExpressionRef bodyExpr = BinaryenExpressionRef_val(_bodyExpr);
|
|
2328
|
+
BinaryenTrySetBody(expr, bodyExpr);
|
|
2329
|
+
CAMLreturn(Val_unit);
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
CAMLprim value
|
|
2333
|
+
caml_binaryen_try_get_num_catch_tags(value _expr) {
|
|
2334
|
+
CAMLparam1(_expr);
|
|
2335
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2336
|
+
BinaryenIndex binaryenRetVal = BinaryenTryGetNumCatchTags(expr);
|
|
2337
|
+
CAMLreturn(Val_int(binaryenRetVal));
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
CAMLprim value
|
|
2341
|
+
caml_binaryen_try_get_num_catch_bodies(value _expr) {
|
|
2342
|
+
CAMLparam1(_expr);
|
|
2343
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2344
|
+
BinaryenIndex binaryenRetVal = BinaryenTryGetNumCatchBodies(expr);
|
|
2345
|
+
CAMLreturn(Val_int(binaryenRetVal));
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2348
|
+
CAMLprim value
|
|
2349
|
+
caml_binaryen_try_get_catch_tag_at(value _expr, value _index) {
|
|
2350
|
+
CAMLparam2(_expr, _index);
|
|
2351
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2352
|
+
BinaryenIndex index = Int_val(_index);
|
|
2353
|
+
const char* binaryenRetVal = BinaryenTryGetCatchTagAt(expr, index);
|
|
2354
|
+
CAMLreturn(caml_copy_string(binaryenRetVal));
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
CAMLprim value
|
|
2358
|
+
caml_binaryen_try_set_catch_tag_at(value _expr, value _index, value _catchTag) {
|
|
2359
|
+
CAMLparam3(_expr, _index, _catchTag);
|
|
2360
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2361
|
+
BinaryenIndex index = Int_val(_index);
|
|
2362
|
+
const char* catchTag = Safe_String_val(_catchTag);
|
|
2363
|
+
BinaryenTrySetCatchTagAt(expr, index, catchTag);
|
|
2364
|
+
CAMLreturn(Val_unit);
|
|
2365
|
+
}
|
|
2366
|
+
|
|
2367
|
+
CAMLprim value
|
|
2368
|
+
caml_binaryen_try_append_catch_tag(value _expr, value _catchTag) {
|
|
2369
|
+
CAMLparam2(_expr, _catchTag);
|
|
2370
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2371
|
+
const char* catchTag = Safe_String_val(_catchTag);
|
|
2372
|
+
BinaryenIndex binaryenRetVal = BinaryenTryAppendCatchTag(expr, catchTag);
|
|
2373
|
+
CAMLreturn(Val_int(binaryenRetVal));
|
|
2374
|
+
}
|
|
2375
|
+
|
|
2376
|
+
CAMLprim value
|
|
2377
|
+
caml_binaryen_try_insert_catch_tag_at(value _expr, value _index, value _catchTag) {
|
|
2378
|
+
CAMLparam3(_expr, _index, _catchTag);
|
|
2379
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2380
|
+
BinaryenIndex index = Int_val(_index);
|
|
2381
|
+
const char* catchTag = Safe_String_val(_catchTag);
|
|
2382
|
+
BinaryenTryInsertCatchTagAt(expr, index, catchTag);
|
|
2383
|
+
CAMLreturn(Val_unit);
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
CAMLprim value
|
|
2387
|
+
caml_binaryen_try_remove_catch_tag_at(value _expr, value _index) {
|
|
2388
|
+
CAMLparam2(_expr, _index);
|
|
2389
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2390
|
+
BinaryenIndex index = Int_val(_index);
|
|
2391
|
+
const char* binaryenRetVal = BinaryenTryRemoveCatchTagAt(expr, index);
|
|
2392
|
+
CAMLreturn(caml_copy_string(binaryenRetVal));
|
|
2393
|
+
}
|
|
2394
|
+
|
|
2395
|
+
CAMLprim value
|
|
2396
|
+
caml_binaryen_try_get_catch_body_at(value _expr, value _index) {
|
|
2397
|
+
CAMLparam2(_expr, _index);
|
|
2398
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2399
|
+
BinaryenIndex index = Int_val(_index);
|
|
2400
|
+
BinaryenExpressionRef binaryenRetVal = BinaryenTryGetCatchBodyAt(expr, index);
|
|
2401
|
+
CAMLreturn(alloc_BinaryenExpressionRef(binaryenRetVal));
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
CAMLprim value
|
|
2405
|
+
caml_binaryen_try_set_catch_body_at(value _expr, value _index, value _catchExpr) {
|
|
2406
|
+
CAMLparam3(_expr, _index, _catchExpr);
|
|
2407
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2408
|
+
BinaryenIndex index = Int_val(_index);
|
|
2409
|
+
BinaryenExpressionRef catchExpr = BinaryenExpressionRef_val(_catchExpr);
|
|
2410
|
+
BinaryenTrySetCatchBodyAt(expr, index, catchExpr);
|
|
2411
|
+
CAMLreturn(Val_unit);
|
|
2412
|
+
}
|
|
2413
|
+
|
|
2414
|
+
CAMLprim value
|
|
2415
|
+
caml_binaryen_try_append_catch_body(value _expr, value _catchExpr) {
|
|
2416
|
+
CAMLparam2(_expr, _catchExpr);
|
|
2417
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2418
|
+
BinaryenExpressionRef catchExpr = BinaryenExpressionRef_val(_catchExpr);
|
|
2419
|
+
BinaryenIndex binaryenRetVal = BinaryenTryAppendCatchBody(expr, catchExpr);
|
|
2420
|
+
CAMLreturn(Val_int(binaryenRetVal));
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
CAMLprim value
|
|
2424
|
+
caml_binaryen_try_insert_catch_body_at(value _expr, value _index, value _catchExpr) {
|
|
2425
|
+
CAMLparam3(_expr, _index, _catchExpr);
|
|
2426
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2427
|
+
BinaryenIndex index = Int_val(_index);
|
|
2428
|
+
BinaryenExpressionRef catchExpr = BinaryenExpressionRef_val(_catchExpr);
|
|
2429
|
+
BinaryenTryInsertCatchBodyAt(expr, index, catchExpr);
|
|
2430
|
+
CAMLreturn(Val_unit);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
CAMLprim value
|
|
2434
|
+
caml_binaryen_try_remove_catch_body_at(value _expr, value _index) {
|
|
2435
|
+
CAMLparam2(_expr, _index);
|
|
2436
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2437
|
+
BinaryenIndex index = Int_val(_index);
|
|
2438
|
+
BinaryenExpressionRef binaryenRetVal = BinaryenTryRemoveCatchBodyAt(expr, index);
|
|
2439
|
+
CAMLreturn(alloc_BinaryenExpressionRef(binaryenRetVal));
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
CAMLprim value
|
|
2443
|
+
caml_binaryen_try_has_catch_all(value _expr) {
|
|
2444
|
+
CAMLparam1(_expr);
|
|
2445
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2446
|
+
bool binaryenRetVal = BinaryenTryHasCatchAll(expr);
|
|
2447
|
+
CAMLreturn(Val_bool(binaryenRetVal));
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
CAMLprim value
|
|
2451
|
+
caml_binaryen_throw_get_tag(value _expr) {
|
|
2452
|
+
CAMLparam1(_expr);
|
|
2453
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2454
|
+
const char* binaryenRetVal = BinaryenThrowGetTag(expr);
|
|
2455
|
+
CAMLreturn(caml_copy_string(binaryenRetVal));
|
|
2456
|
+
}
|
|
2457
|
+
|
|
2458
|
+
CAMLprim value
|
|
2459
|
+
caml_binaryen_throw_set_tag(value _expr, value _tagName) {
|
|
2460
|
+
CAMLparam2(_expr, _tagName);
|
|
2461
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2462
|
+
const char* tagName = Safe_String_val(_tagName);
|
|
2463
|
+
BinaryenThrowSetTag(expr, tagName);
|
|
2464
|
+
CAMLreturn(Val_unit);
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
CAMLprim value
|
|
2468
|
+
caml_binaryen_throw_get_num_operands(value _expr) {
|
|
2469
|
+
CAMLparam1(_expr);
|
|
2470
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2471
|
+
BinaryenIndex binaryenRetVal = BinaryenThrowGetNumOperands(expr);
|
|
2472
|
+
CAMLreturn(Val_int(binaryenRetVal));
|
|
2473
|
+
}
|
|
2474
|
+
|
|
2475
|
+
CAMLprim value
|
|
2476
|
+
caml_binaryen_throw_get_operand_at(value _expr, value _index) {
|
|
2477
|
+
CAMLparam2(_expr, _index);
|
|
2478
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2479
|
+
BinaryenIndex index = Int_val(_index);
|
|
2480
|
+
BinaryenExpressionRef binaryenRetVal = BinaryenThrowGetOperandAt(expr, index);
|
|
2481
|
+
CAMLreturn(alloc_BinaryenExpressionRef(binaryenRetVal));
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
CAMLprim value
|
|
2485
|
+
caml_binaryen_throw_set_operand_at(value _expr, value _index, value _operandExpr) {
|
|
2486
|
+
CAMLparam3(_expr, _index, _operandExpr);
|
|
2487
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2488
|
+
BinaryenIndex index = Int_val(_index);
|
|
2489
|
+
BinaryenExpressionRef operandExpr = BinaryenExpressionRef_val(_operandExpr);
|
|
2490
|
+
BinaryenThrowSetOperandAt(expr, index, operandExpr);
|
|
2491
|
+
CAMLreturn(Val_unit);
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
CAMLprim value
|
|
2495
|
+
caml_binaryen_throw_append_operand(value _expr, value _operandExpr) {
|
|
2496
|
+
CAMLparam2(_expr, _operandExpr);
|
|
2497
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2498
|
+
BinaryenExpressionRef operandExpr = BinaryenExpressionRef_val(_operandExpr);
|
|
2499
|
+
BinaryenIndex binaryenRetVal = BinaryenThrowAppendOperand(expr, operandExpr);
|
|
2500
|
+
CAMLreturn(Val_int(binaryenRetVal));
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
CAMLprim value
|
|
2504
|
+
caml_binaryen_throw_insert_operand_at(value _expr, value _index, value _operandExpr) {
|
|
2505
|
+
CAMLparam3(_expr, _index, _operandExpr);
|
|
2506
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2507
|
+
BinaryenIndex index = Int_val(_index);
|
|
2508
|
+
BinaryenExpressionRef operandExpr = BinaryenExpressionRef_val(_operandExpr);
|
|
2509
|
+
BinaryenThrowInsertOperandAt(expr, index, operandExpr);
|
|
2510
|
+
CAMLreturn(Val_unit);
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
CAMLprim value
|
|
2514
|
+
caml_binaryen_throw_remove_operand_at(value _expr, value _index) {
|
|
2515
|
+
CAMLparam2(_expr, _index);
|
|
2516
|
+
BinaryenExpressionRef expr = BinaryenExpressionRef_val(_expr);
|
|
2517
|
+
BinaryenIndex index = Int_val(_index);
|
|
2518
|
+
BinaryenExpressionRef binaryenRetVal = BinaryenThrowRemoveOperandAt(expr, index);
|
|
2519
|
+
CAMLreturn(alloc_BinaryenExpressionRef(binaryenRetVal));
|
|
2520
|
+
}
|
|
2521
|
+
|
|
1886
2522
|
// Table operations
|
|
1887
2523
|
CAMLprim value
|
|
1888
2524
|
caml_binaryen_table_get(value _module, value _name, value _index, value _ty) {
|