Skip to content

Commit

Permalink
feat: Add update_maps function that Binaryen added
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Jan 14, 2022
1 parent c29fb50 commit 49741c5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/module.ml
Expand Up @@ -112,3 +112,6 @@ let add_debug_info_filename wasm_mod filename =

let get_debug_info_filename wasm_mod index =
meth_call wasm_mod "getDebugInfoFileName" [| inject index |]

(* The JS version doesn't expose `update_maps` *)
let update_maps wasm_mod = ()
7 changes: 7 additions & 0 deletions src/binaryen_stubs_modules.c
Expand Up @@ -172,3 +172,10 @@ caml_binaryen_add_custom_section(value _module, value _name, value _contents) {
BinaryenAddCustomSection(module, name, contents, contentsLen);
CAMLreturn(Val_unit);
}

CAMLprim value
caml_binaryen_module_update_maps(value module) {
CAMLparam1(module);
BinaryenModuleUpdateMaps(BinaryenModuleRef_val(module));
CAMLreturn(Val_unit);
}
2 changes: 2 additions & 0 deletions src/module.ml
Expand Up @@ -111,3 +111,5 @@ external add_debug_info_filename : t -> string -> int

external get_debug_info_filename : t -> int -> string
= "caml_binaryen_module_get_debug_info_filename"

external update_maps : t -> unit = "caml_binaryen_module_update_maps"
3 changes: 3 additions & 0 deletions test/test.ml
Expand Up @@ -116,6 +116,9 @@ let _ =

let _ = Export.add_function_export wasm_mod "hello" "hello"

(* Shouldn't actually do anything since we aren't doing function renames *)
let _ = Module.update_maps wasm_mod

(* Finally, we print 3 versions of the module to be checked against test.expected *)

(* 1. Print the the module as-is *)
Expand Down
2 changes: 2 additions & 0 deletions virtual/module.mli
Expand Up @@ -63,3 +63,5 @@ val interpret : t -> unit
val add_debug_info_filename : t -> string -> int

val get_debug_info_filename : t -> int -> string

val update_maps : t -> unit

0 comments on commit 49741c5

Please sign in to comment.