Skip to content

Commit

Permalink
small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
vasucp1207 committed Aug 27, 2024
1 parent 24de7fd commit 90b12c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 3 additions & 7 deletions src/ast/binary_encoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -762,15 +762,11 @@ let encode
let write_file outfile filename content =
let _dir, filename = Fpath.split_base filename in
let filename = Fpath.set_ext "wasm" filename in
match outfile with
| Some name -> Bos.OS.File.write name content
| None -> Bos.OS.File.write filename content
Bos.OS.File.write (Option.value outfile ~default:filename) content

let convert (outfile : Fpath.t option) (filename : Fpath.t) ~unsafe ~optimize m
=
Log.debug0 "bin encoding ...@\n";
let+ m = Compile.Text.until_optimize ~unsafe ~optimize m in
let* m = Compile.Text.until_optimize ~unsafe ~optimize m in
let content = encode m in
match write_file outfile filename content with
| Error _ -> raise Exit
| Ok _ -> ()
write_file outfile filename content
4 changes: 1 addition & 3 deletions src/cmd/cmd_opt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ let print_or_emit ~unsafe file outfile =

let cmd debug unsafe file outfile =
if debug then Log.debug_on := true;
match print_or_emit ~unsafe file outfile with
| Error _ -> raise Exit
| Ok _ -> Ok ()
Result.bind (print_or_emit ~unsafe file outfile) (fun _ -> Ok ())

0 comments on commit 90b12c2

Please sign in to comment.