Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
heap_type
signature_type
struct_type
type_builder
ocaml_helpers)
(flags :standard -O2 -Wall -Wextra))
(js_of_ocaml
Expand All @@ -46,4 +47,5 @@
packed_type.js
heap_type.js
signature_type.js
type_builder.js
struct_type.js)))
345 changes: 345 additions & 0 deletions src/expression.c

Large diffs are not rendered by default.

240 changes: 239 additions & 1 deletion src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,28 @@ function caml_binaryen_call_indirect__bytecode() {
);
}

//Provides: caml_binaryen_call_ref
//Requires: caml_jsstring_of_string
//Requires: caml_list_to_js_array
function caml_binaryen_call_ref(wasm_mod, target, params, typ) {
return wasm_mod.call_ref(
target,
caml_list_to_js_array(params),
typ
);
}

//Provides: caml_binaryen_return_call_ref
//Requires: caml_jsstring_of_string
//Requires: caml_list_to_js_array
function caml_binaryen_return_call_ref(wasm_mod, target, params, typ) {
return wasm_mod.return_call_ref(
target,
caml_list_to_js_array(params),
typ
);
}

//Provides: caml_binaryen_return_call
//Requires: caml_jsstring_of_string
//Requires: caml_list_to_js_array
Expand Down Expand Up @@ -547,6 +569,32 @@ function caml_binaryen_ref_i31(wasm_mod, typ) {
return wasm_mod.ref.i31(typ);
}

//Provides: caml_binaryen_ref_test
function caml_binaryen_ref_test(wasm_mod, ref, typ) {
return wasm_mod.ref.test(ref, typ);
}

//Provides: caml_binaryen_ref_cast
function caml_binaryen_ref_cast(wasm_mod, ref, typ) {
return wasm_mod.ref.cast(ref, typ);
}

//Provides: caml_binaryen_br_on
//Requires: caml_jsstring_of_string
//Requires: Binaryen
function caml_binaryen_br_on(wasm_mod, op, name, ref, typ) {
switch (op) {
case Binaryen.BrOnNull:
return wasm_mod.br_on_null(caml_jsstring_of_string(name), ref);
case Binaryen.BrOnNonNull:
return wasm_mod.br_on_non_null(caml_jsstring_of_string(name), ref);
case Binaryen.BrOnCast:
return wasm_mod.br_on_cast(caml_jsstring_of_string(name), ref, typ);
case Binaryen.BrOnCastFail:
return wasm_mod.br_on_cast_fail(caml_jsstring_of_string(name), ref, typ);
}
}

//Provides: caml_binaryen_i31_get
function caml_binaryen_i31_get(wasm_mod, typ, signed) {
if (signed) {
Expand Down Expand Up @@ -1296,6 +1344,68 @@ function caml_binaryen_call_indirect_set_return(exp, isReturn) {
return Binaryen.CallIndirect.setReturn(exp, caml_js_from_bool(isReturn));
}

//Provides: caml_binaryen_call_ref_get_target
//Requires: Binaryen
function caml_binaryen_call_ref_get_target(exp) {
return Binaryen.CallRef.getTarget(exp);
}

//Provides: caml_binaryen_call_ref_set_target
//Requires: Binaryen
function caml_binaryen_call_ref_set_target(exp, target) {
return Binaryen.CallRef.setTarget(exp, target);
}

//Provides: caml_binaryen_call_ref_get_num_operands
//Requires: Binaryen
function caml_binaryen_call_ref_get_num_operands(exp) {
return Binaryen.CallRef.getNumOperands(exp);
}

//Provides: caml_binaryen_call_ref_get_operand_at
//Requires: Binaryen
function caml_binaryen_call_ref_get_operand_at(exp, index) {
return Binaryen.CallRef.getOperandAt(exp, index);
}

//Provides: caml_binaryen_call_ref_set_operand_at
//Requires: Binaryen
function caml_binaryen_call_ref_set_operand_at(exp, index, operand) {
return Binaryen.CallRef.setOperandAt(exp, index, operand);
}

//Provides: caml_binaryen_call_ref_append_operand
//Requires: Binaryen
function caml_binaryen_call_ref_append_operand(exp, operand) {
return Binaryen.CallRef.appendOperand(exp, operand);
}

//Provides: caml_binaryen_call_ref_insert_operand_at
//Requires: Binaryen
function caml_binaryen_call_ref_insert_operand_at(exp, index, operand) {
return Binaryen.CallRef.insertOperandAt(exp, index, operand);
}

//Provides: caml_binaryen_call_ref_remove_operand_at
//Requires: Binaryen
function caml_binaryen_call_ref_remove_operand_at(exp, index) {
return Binaryen.CallRef.removeOperandAt(exp, index);
}

//Provides: caml_binaryen_call_ref_is_return
//Requires: Binaryen
//Requires: caml_js_to_bool
function caml_binaryen_call_ref_is_return(exp) {
return caml_js_to_bool(Binaryen.CallRef.isReturn(exp));
}

//Provides: caml_binaryen_call_ref_set_return
//Requires: Binaryen
//Requires: caml_js_from_bool
function caml_binaryen_call_ref_set_return(exp, isReturn) {
return Binaryen.CallRef.setReturn(exp, caml_js_from_bool(isReturn));
}

//Provides: caml_binaryen_local_set_get_value
//Requires: Binaryen
function caml_binaryen_local_set_get_value(exp) {
Expand Down Expand Up @@ -1704,7 +1814,135 @@ function caml_binaryen_ref_func(wasm_mod, name, typ) {

//Provides: caml_binaryen_ref_eq
function caml_binaryen_ref_eq(wasm_mod, left, right) {
return wasm_mod.ref.func(left, right);
return wasm_mod.ref.eq(left, right);
}

// Struct operations

//Provides: caml_binaryen_struct_new
//Requires: caml_list_to_js_array
function caml_binaryen_struct_new(wasm_mod, operands, type) {
return wasm_mod.struct.new(
operands ? caml_list_to_js_array(operands[1]) : null,
type
);
}

//Provides: caml_binaryen_struct_get
//Requires: caml_js_from_bool
function caml_binaryen_struct_get(wasm_mod, index, ref, type, signed) {
return wasm_mod.struct.get(index, ref, type, caml_js_from_bool(signed));
}

//Provides: caml_binaryen_struct_set
function caml_binaryen_struct_set(wasm_mod, index, ref, value) {
return wasm_mod.struct.set(index, ref, value);
}

// Array operations

//Provides: caml_binaryen_array_new
function caml_binaryen_array_new(wasm_mod, type, size, init) {
return wasm_mod.array.new(type, size, init);
}

//Provides: caml_binaryen_array_new_data
//Requires: caml_jsstring_of_string
function caml_binaryen_array_new_data(wasm_mod, type, name, offset, size) {
return wasm_mod.array.new_data(
type,
caml_jsstring_of_string(name),
offset,
size
);
}

//Provides: caml_binaryen_array_new_elem
//Requires: caml_jsstring_of_string
function caml_binaryen_array_new_elem(wasm_mod, type, name, offset, size) {
return wasm_mod.array.new_elem(
type,
caml_jsstring_of_string(name),
offset,
size
);
}

//Provides: caml_binaryen_array_new_fixed
//Requires: caml_list_to_js_array
function caml_binaryen_array_new_fixed(wasm_mod, type, values) {
return wasm_mod.array.new_fixed(type, caml_list_to_js_array(values));
}

//Provides: caml_binaryen_array_get
//Requires: caml_js_from_bool
function caml_binaryen_array_get(wasm_mod, ref, index, type, signed) {
return wasm_mod.array.get(ref, index, type, caml_js_from_bool(signed));
}

//Provides: caml_binaryen_array_set
function caml_binaryen_array_set(wasm_mod, ref, index, value) {
return wasm_mod.array.set(ref, index, value);
}

//Provides: caml_binaryen_array_len
function caml_binaryen_array_len(wasm_mod, ref) {
return wasm_mod.array.len(ref);
}

//Provides: caml_binaryen_array_fill
function caml_binaryen_array_fill(wasm_mod, ref, index, value, size) {
return wasm_mod.array.fill(ref, index, value, size);
}

//Provides: caml_binaryen_array_copy
function caml_binaryen_array_copy(
wasm_mod,
destRef,
destIndex,
srcRef,
srcIndex,
length
) {
return wasm_mod.array.copy(destRef, destIndex, srcRef, srcIndex, length);
}

//Provides: caml_binaryen_array_init_data
//Requires: caml_jsstring_of_string
function caml_binaryen_array_init_data(wasm_mod, name, ref, index, offset, size) {
return wasm_mod.array.init_data(caml_jsstring_of_string(name), ref, index, offset, size);
}

//Provides: caml_binaryen_array_init_data__bytecode
//Requires: caml_binaryen_array_init_data
function caml_binaryen_array_init_data__bytecode() {
return caml_binaryen_array_init_data(
arguments[0],
arguments[1],
arguments[2],
arguments[3],
arguments[4],
arguments[5]
);
}

//Provides: caml_binaryen_array_init_elem
//Requires: caml_jsstring_of_string
function caml_binaryen_array_init_elem(wasm_mod, name, ref, index, offset, size) {
return wasm_mod.array.init_elem(caml_jsstring_of_string(name), ref, index, offset, size);
}

//Provides: caml_binaryen_array_copy__bytecode
//Requires: caml_binaryen_array_copy
function caml_binaryen_array_copy__bytecode() {
return caml_binaryen_array_copy(
arguments[0],
arguments[1],
arguments[2],
arguments[3],
arguments[4],
arguments[5]
);
}

// Exception handling operations
Expand Down
Loading
Loading