Skip to content

Commit

Permalink
Fix input format in the JS example
Browse files Browse the repository at this point in the history
  • Loading branch information
Halbaroth committed Oct 7, 2024
1 parent f6b986e commit 3a3a8b8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/bin/js/main_text_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ let parse_cmdline () =
with Parse_command.Exit_parse_command i -> exit i

let () =
Options.set_exit_on_error false;
(* Currently, the main function of [Solving_loop] calls the [exit] function in
case of recoverable error, which is not supported in Javascript. We
turn off this feature as we do not support it correctly. See issue
https://github.com/OCamlPro/alt-ergo/issues/1250 *)
AltErgoLib.Options.set_exit_on_error false;
register_input ();
parse_cmdline ();
AltErgoLib.Printer.init_colors ();
Expand Down
7 changes: 5 additions & 2 deletions src/bin/js/worker_example.ml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ let exec worker file options =
let solve () =
let options =
{(Worker_interface.init_options ()) with
input_format=Some Native;
input_format = None;
file = Some "try-alt-ergo";
debug = Some true;
verbose = Some true;
Expand All @@ -82,7 +82,10 @@ let solve () =
diagnostic = Some ["Timeout"]});
(
let file = String.split_on_char '\n' !file in
let json_file = Worker_interface.file_to_json None (Some 42) file in
let json_file =
Worker_interface.file_to_json
(Some ("dummy" ^ !extension)) (Some 42) file
in
Firebug.console##log json_file;
let json_options = Worker_interface.options_to_json options in
Firebug.console##log json_options;
Expand Down
4 changes: 2 additions & 2 deletions src/bin/js/worker_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ let create_buffer () =
buf, output

let main worker_id filename filecontent =
let filename = match filename with | Some f -> f | None -> "<worker>" in
try
(* Create buffer for each formatter
The content of this buffers are then retrieved and send as results *)
Expand Down Expand Up @@ -163,7 +162,7 @@ let () =
at_exit Options.Output.close_all;
Worker.set_onmessage (fun (json_file, json_options) ->
Lwt_js_events.async (fun () ->
let filename, worker_id, filecontent =
let filename_opt, worker_id, filecontent =
Worker_interface.file_from_json json_file
in
let filecontent = String.concat "\n" filecontent in
Expand All @@ -174,6 +173,7 @@ let () =
Options.set_exit_on_error false;

(* Run the worker on the input file (filecontent) *)
let filename = Option.get filename_opt in
let results = main worker_id filename filecontent in

(* Convert results and returns them *)
Expand Down

0 comments on commit 3a3a8b8

Please sign in to comment.