Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
open Js_of_ocaml.Js | ||
open Js_of_ocaml.Js.Unsafe | ||
|
||
let add_table wasm_mod name initial maximum funcnames offset = | ||
meth_call wasm_mod "addTable" | ||
[| | ||
inject (string name); | ||
inject initial; | ||
inject maximum; | ||
inject (array (Array.of_list (List.map string funcnames))); | ||
inject offset; | ||
|] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#define CAML_NAME_SPACE | ||
#include <caml/mlvalues.h> | ||
#include <caml/fail.h> | ||
#include <caml/memory.h> | ||
|
||
#include "binaryen-c.h" | ||
#include "ocaml_helpers.h" | ||
|
||
|
||
CAMLprim value | ||
caml_binaryen_add_table(value _module, value _name, value _initial, value _maximum, value _funcnames, value _offset) { | ||
CAMLparam5(_module, _name, _initial, _maximum, _funcnames); | ||
CAMLxparam1(_offset); | ||
BinaryenModuleRef module = BinaryenModuleRef_val(_module); | ||
char* name = Safe_String_val(_name); | ||
BinaryenIndex initial = Int_val(_initial); | ||
BinaryenIndex maximum = Int_val(_maximum); | ||
_funcnames = array_of_list(_funcnames); | ||
int funcnamesLen = array_length(_funcnames); | ||
const char* funcnames[funcnamesLen]; | ||
for (int i = 0; i < funcnamesLen; i++) { | ||
funcnames[i] = Safe_String_val(Field(_funcnames, i)); | ||
} | ||
BinaryenExpressionRef offset = BinaryenExpressionRef_val(_offset); | ||
BinaryenAddTable(module, name, initial, maximum, funcnames, funcnamesLen, offset); | ||
CAMLreturn(Val_unit); | ||
} | ||
CAMLprim value | ||
caml_binaryen_add_table__bytecode(value * argv) { | ||
return caml_binaryen_add_table(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
external add_table : | ||
Module.t -> string -> int -> int -> string list -> Expression.t -> unit | ||
= "caml_binaryen_add_table__bytecode" "caml_binaryen_add_table" | ||
(** Module, name, initial size, maximum size, function names, offset. *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
(library | ||
(name binaryen) | ||
(public_name binaryen) | ||
(virtual_modules export expression features function function_table global | ||
import literal memory module op type) | ||
(virtual_modules export expression features function function_table table | ||
global import literal memory module op type) | ||
(default_implementation binaryen.native)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
val add_table : | ||
Module.t -> string -> int -> int -> string list -> Expression.t -> unit |