Skip to content

Commit

Permalink
remove register
Browse files Browse the repository at this point in the history
  • Loading branch information
zapashcanon committed Oct 7, 2024
1 parent f43a2a8 commit ec3b90b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
16 changes: 4 additions & 12 deletions wasm/emit_wat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2387,7 +2387,7 @@ end

let output_wat ppf wat = Format.pp_print_string ppf wat

let output_file ~output_prefix ~module_ ~register =
let output_file ~output_prefix ~module_ =
let watfile = output_prefix ^ ".wat" in
let oc = open_out_bin watfile in
let ppf = Format.formatter_of_out_channel oc in
Expand All @@ -2398,8 +2398,7 @@ let output_file ~output_prefix ~module_ ~register =
(* ~exceptionally:(fun () -> Misc.remove_file watfile) *)
(fun () ->
output_wat ppf module_;
Format.fprintf ppf "@\n";
output_wat ppf register )
Format.fprintf ppf "@\n")

let run ~output_prefix (flambda : Flambda.program) =
State.reset ();
Expand Down Expand Up @@ -2427,21 +2426,14 @@ let run ~output_prefix (flambda : Flambda.program) =
let wasm =
Profile.record_call "ToWasm" (fun () -> ToWasm.conv_module (common @ m))
in
let register =
let ln =
Compilation_unit.get_linkage_name (Compilation_unit.get_current_exn ())
in
Wat.C.register (Linkage_name.to_string ln)
in
(* Format.printf "@.%a@." ToWasm.Cst.emit wasm; *)
let emit = if Wstate.pp_wat then ToWasm.Cst.pp else ToWasm.Cst.emit in
let wasm = Format.asprintf "%a" emit wasm in
let register = Format.asprintf "%a" emit register in
Wat.{ module_ = wasm; register }
Wat.{ module_ = wasm }

let emit ~to_file ~output_prefix (flambda : Flambda.program) =
let r = run ~output_prefix flambda in
if to_file then
Profile.record_call "output_wasm" (fun () ->
output_file ~output_prefix ~module_:r.module_ ~register:r.register );
output_file ~output_prefix ~module_:r.module_ );
r
2 changes: 1 addition & 1 deletion wasm/link_wat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let out_file (name, (wat : Wat.t)) =
(fun () ->
Emit_wat.output_wat ppf wat.module_;
Format.fprintf ppf "@\n";
Emit_wat.output_wat ppf wat.register );
);
{ name; filename }

let emit_text = "--emit-text"
Expand Down
5 changes: 2 additions & 3 deletions wasm/wat.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ type printable_expr = string

type t = {
module_ : string;
register : string;
}

module C = struct
Expand Down Expand Up @@ -256,7 +255,8 @@ module C = struct

let tuple_make fields =
match fields with
| [] -> assert false
| [] -> atom "_____ishouldnotexist"
(* assert false *)
| [ field ] -> field
| fields ->
node "tuple.make" (Atom (List.length fields |> string_of_int) :: fields )
Expand Down Expand Up @@ -372,5 +372,4 @@ module C = struct
let m = import_tag :: m in
nodev "module" m

let register name = node "register" [ String (module_name name) ]
end

0 comments on commit ec3b90b

Please sign in to comment.