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
9 changes: 1 addition & 8 deletions .github/workflows/opam.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: "recursive"

- name: Setup node.js
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0
with:
Expand All @@ -36,13 +36,6 @@ jobs:
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

# Necessary until using libbinaryen v122
- name: Override C Compiler Flags For Windows
if: ${{ startsWith(matrix.os, 'windows-') }}
run: |
echo "CC=x86_64-w64-mingw32-gcc" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "CXX=x86_64-w64-mingw32-g++" | Out-File -FilePath $env:GITHUB_ENV -Append

- name: Install local dependencies
run: |
opam install . --deps-only --with-test
Expand Down
2 changes: 1 addition & 1 deletion binaryen.opam
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ depends: [
"dune" {>= "3.0.0"}
"dune-configurator" {>= "3.0.0"}
"js_of_ocaml-compiler" {>= "6.0.0" < "7.0.0"}
"libbinaryen" {> "117.0.0" < "118.0.0"}
"libbinaryen" {>= "123.0.0" < "124.0.0"}
]
2 changes: 1 addition & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(dirs :standard)

(data_only_dirs node_modules)
(data_only_dirs node_modules)
30 changes: 15 additions & 15 deletions esy.lock/index.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
"description": "OCaml bindings for Binaryen.",
"author": "Oscar Spencer <oscar@grain-lang.org>",
"license": "Apache-2.0",
"installConfig": {
"pnp": false
},
"dependencies": {
"ocaml": ">= 4.13.0 < 5.4.0",
"@grain/libbinaryen": "117.0.0-b",
"@grain/libbinaryen": ">= 123.0.0 < 124.0.0",
"@opam/dune": ">= 3.0.0",
"@opam/dune-configurator": ">= 3.0.0"
},
Expand All @@ -19,7 +16,8 @@
"@opam/ocaml-lsp-server": ">= 1.9.1 < 2.0.0"
},
"resolutions": {
"@opam/ocp-indent": "1.7.0"
"@opam/ocp-indent": "1.7.0",
"@grain/libbinaryen": "git+https://github.com/grain-lang/libbinaryen.git#cb37a909a8b27ab2f5ef89b5c5c346e2622424f0"
},
"esy": {
"build": "dune build -p binaryen"
Expand Down
9 changes: 4 additions & 5 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,14 +285,13 @@ caml_binaryen_binary(value _module, value _op, value _p1, value _p2) {
}

CAMLprim value
caml_binaryen_select(value _module, value _cond, value _tru, value _fals, value _ty) {
CAMLparam5(_module, _cond, _tru, _fals, _ty);
caml_binaryen_select(value _module, value _cond, value _tru, value _fals) {
CAMLparam4(_module, _cond, _tru, _fals);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
BinaryenExpressionRef cond = BinaryenExpressionRef_val(_cond);
BinaryenExpressionRef tru = BinaryenExpressionRef_val(_tru);
BinaryenExpressionRef fals = BinaryenExpressionRef_val(_fals);
BinaryenType ty = BinaryenType_val(_ty);
BinaryenExpressionRef exp = BinaryenSelect(module, cond, tru, fals, ty);
BinaryenExpressionRef exp = BinaryenSelect(module, cond, tru, fals);
CAMLreturn(alloc_BinaryenExpressionRef(exp));
}

Expand Down Expand Up @@ -1869,7 +1868,7 @@ caml_binaryen_ref_func(value _module, value _name, value _ty) {
CAMLparam3(_module, _name, _ty);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
char* name = Safe_String_val(_name);
BinaryenType ty = BinaryenType_val(_ty);
BinaryenHeapType ty = BinaryenHeapType_val(_ty);
BinaryenExpressionRef exp = BinaryenRefFunc(module, name, ty);
CAMLreturn(alloc_BinaryenExpressionRef(exp));
}
Expand Down
4 changes: 2 additions & 2 deletions src/expression.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ function caml_binaryen_binary(wasm_mod, op, p1, p2) {
}

//Provides: caml_binaryen_select
function caml_binaryen_select(wasm_mod, cond, if_true, if_false, typ) {
return wasm_mod.select(cond, if_true, if_false, typ);
function caml_binaryen_select(wasm_mod, cond, if_true, if_false) {
return wasm_mod.select(cond, if_true, if_false);
}

//Provides: caml_binaryen_drop
Expand Down
7 changes: 4 additions & 3 deletions src/expression.ml
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,11 @@ module Binary = struct
end

module Select = struct
external make : Module.t -> t -> t -> t -> Type.t -> t
external make : Module.t -> t -> t -> t -> t
= "caml_binaryen_select"

(** Module, condition, true branch, false branch. *)
let make wasm_mod cond tru fals = make wasm_mod cond tru fals Type.auto
let make wasm_mod cond tru fals = make wasm_mod cond tru fals

external get_if_true : t -> t = "caml_binaryen_select_get_if_true"
external set_if_true : t -> t -> unit = "caml_binaryen_select_set_if_true"
Expand Down Expand Up @@ -818,7 +818,8 @@ module Ref = struct
external as_ : Module.t -> Op.t -> t -> t = "caml_binaryen_ref_as"
(** Module, op, value *)

external func : Module.t -> string -> Type.t -> t = "caml_binaryen_ref_func"
external func : Module.t -> string -> Heap_type.t -> t
= "caml_binaryen_ref_func"
(** Module, func, type *)

external eq : Module.t -> t -> t -> t = "caml_binaryen_ref_eq"
Expand Down
2 changes: 1 addition & 1 deletion src/expression.mli
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ module Ref : sig
val as_ : Module.t -> Op.t -> t -> t
(** Module, op, value *)

val func : Module.t -> string -> Type.t -> t
val func : Module.t -> string -> Heap_type.t -> t
(** Module, func, type *)

val eq : Module.t -> t -> t -> t
Expand Down
21 changes: 0 additions & 21 deletions src/heap_type.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,6 @@ caml_binaryen_heap_type_string(value unit) {
CAMLreturn(alloc_BinaryenHeapType(ty));
}

CAMLprim value
caml_binaryen_heap_type_stringview_wtf8(value unit) {
CAMLparam1(unit);
BinaryenHeapType ty = BinaryenHeapTypeStringviewWTF8();
CAMLreturn(alloc_BinaryenHeapType(ty));
}

CAMLprim value
caml_binaryen_heap_type_stringview_wtf16(value unit) {
CAMLparam1(unit);
BinaryenHeapType ty = BinaryenHeapTypeStringviewWTF16();
CAMLreturn(alloc_BinaryenHeapType(ty));
}

CAMLprim value
caml_binaryen_heap_type_stringview_iter(value unit) {
CAMLparam1(unit);
BinaryenHeapType ty = BinaryenHeapTypeStringviewIter();
CAMLreturn(alloc_BinaryenHeapType(ty));
}

CAMLprim value
caml_binaryen_heap_type_none(value unit) {
CAMLparam1(unit);
Expand Down
18 changes: 0 additions & 18 deletions src/heap_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,6 @@ function caml_binaryen_heap_type_string() {
return Binaryen._BinaryenHeapTypeString();
}

//Provides: caml_binaryen_heap_type_stringview_wtf8
//Requires: Binaryen
function caml_binaryen_heap_type_stringview_wtf8() {
return Binaryen._BinaryenHeapTypeStringviewWTF8();
}

//Provides: caml_binaryen_heap_type_stringview_wtf16
//Requires: Binaryen
function caml_binaryen_heap_type_stringview_wtf16() {
return Binaryen._BinaryenHeapTypeStringviewWTF16();
}

//Provides: caml_binaryen_heap_type_stringview_iter
//Requires: Binaryen
function caml_binaryen_heap_type_stringview_iter() {
return Binaryen._BinaryenHeapTypeStringviewIter();
}

//Provides: caml_binaryen_heap_type_none
//Requires: Binaryen
function caml_binaryen_heap_type_none() {
Expand Down
6 changes: 0 additions & 6 deletions src/heap_type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ external i31 : unit -> t = "caml_binaryen_heap_type_i31"
external struct_ : unit -> t = "caml_binaryen_heap_type_struct"
external array : unit -> t = "caml_binaryen_heap_type_array"
external string : unit -> t = "caml_binaryen_heap_type_string"
external stringview_wtf8 : unit -> t = "caml_binaryen_heap_type_stringview_wtf8"

external stringview_wtf16 : unit -> t
= "caml_binaryen_heap_type_stringview_wtf16"

external stringview_iter : unit -> t = "caml_binaryen_heap_type_stringview_iter"
external none : unit -> t = "caml_binaryen_heap_type_none"
external noext : unit -> t = "caml_binaryen_heap_type_noext"
external nofunc : unit -> t = "caml_binaryen_heap_type_nofunc"
Expand Down
3 changes: 0 additions & 3 deletions src/heap_type.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ val i31 : unit -> t
val struct_ : unit -> t
val array : unit -> t
val string : unit -> t
val stringview_wtf8 : unit -> t
val stringview_wtf16 : unit -> t
val stringview_iter : unit -> t
val none : unit -> t
val noext : unit -> t
val nofunc : unit -> t
Expand Down
22 changes: 6 additions & 16 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ caml_binaryen_module_print_asmjs(value module) {
}

CAMLprim value
caml_binaryen_module_print_stack_ir(value module, value _optimize) {
CAMLparam2(module, _optimize);
bool optimize = Bool_val(_optimize);
BinaryenModulePrintStackIR(BinaryenModuleRef_val(module), optimize);
caml_binaryen_module_print_stack_ir(value module) {
CAMLparam1(module);
BinaryenModulePrintStackIR(BinaryenModuleRef_val(module));
CAMLreturn(Val_unit);
}

Expand Down Expand Up @@ -79,14 +78,6 @@ caml_binaryen_module_run_passes(value _module, value _passes) {
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_module_auto_drop(value _module) {
CAMLparam1(_module);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
BinaryenModuleAutoDrop(module);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_module_write(value _module, value _sourceMapUrl) {
CAMLparam2(_module, _sourceMapUrl);
Expand Down Expand Up @@ -127,11 +118,10 @@ caml_binaryen_module_write_text(value _module) {
// There is something weird with this function that causes a bunch of newlines to
// be printed on stdout when calling it. Not sure if that's a bug in Binaryen.
CAMLprim value
caml_binaryen_module_write_stack_ir(value _module, value _optimize) {
CAMLparam2(_module, _optimize);
caml_binaryen_module_write_stack_ir(value _module) {
CAMLparam1(_module);
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
bool optimize = Bool_val(_optimize);
char* result = BinaryenModuleAllocateAndWriteStackIR(module, optimize);
char* result = BinaryenModuleAllocateAndWriteStackIR(module);
CAMLlocal1(text);
text = caml_copy_string(result);
free(result);
Expand Down
17 changes: 6 additions & 11 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ function caml_binaryen_module_print_asmjs(wasm_mod) {

//Provides: caml_binaryen_module_print_stack_ir
//Requires: caml_sys_fds
//Requires: caml_string_of_jsstring, caml_js_from_bool
//Requires: caml_string_of_jsstring
//Requires: caml_ml_output, caml_ml_string_length
function caml_binaryen_module_print_stack_ir(wasm_mod, optimize) {
var stackir = wasm_mod.emitStackIR(caml_js_from_bool(optimize));
function caml_binaryen_module_print_stack_ir(wasm_mod) {
var stackir = wasm_mod.emitStackIR();
var chanid = caml_sys_fds[1].chanid; // stdout
var s = caml_string_of_jsstring(stackir);
caml_ml_output(chanid, s, 0, caml_ml_string_length(s));
Expand All @@ -67,11 +67,6 @@ function caml_binaryen_module_run_passes(wasm_mod, passes) {
);
}

//Provides: caml_binaryen_module_auto_drop
function caml_binaryen_module_auto_drop(wasm_mod) {
return wasm_mod.autoDrop();
}

//Provides: caml_binaryen_module_write
//Requires: to_option
//Requires: caml_jsstring_of_string, caml_string_of_jsstring, caml_bytes_of_array
Expand All @@ -96,9 +91,9 @@ function caml_binaryen_module_write_text(wasm_mod) {
}

//Provides: caml_binaryen_module_write_stack_ir
//Requires: caml_string_of_jsstring, caml_js_from_bool
function caml_binaryen_module_write_stack_ir(wasm_mod, optimize) {
var text = wasm_mod.emitStackIR(caml_js_from_bool(optimize));
//Requires: caml_string_of_jsstring
function caml_binaryen_module_write_stack_ir(wasm_mod) {
var text = wasm_mod.emitStackIR();
return caml_string_of_jsstring(text);
}

Expand Down
Loading
Loading