-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.ml
74 lines (56 loc) · 1.87 KB
/
main.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(* Astral -- solver for strong-separation logic
*
* Author: Tomas Dacik ([email protected]), 2021 *)
open Astral
open Context
(** Verify result against status specified in the input. *)
let verify_status result =
let status = Option.get result.status in
let expected = result.raw_input.expected_status in
status = expected || status_is_unknown status || status_is_unknown expected
let print_result result =
Format.printf "%s\n" (Context.show_status result);
if Options_base.produce_models () && Option.is_some result.model then
match Option.get result.status with
| `Sat -> Format.printf "%s\n" (StackHeapModel.to_smtlib @@ Option.get result.model)
| _ -> ()
let check_result result =
if not @@ verify_status result then
Utils.internal_error
~backtrace:false
("Expected status is " ^ Context.show_expected_status result)
let verify_model result =
if Options_base.verify_model () && Option.is_some result.model
then ModelChecker.verify_model result
else ()
let print_stats result =
if Options_base.stats ()
then Json_output.print result
else ()
let print_profile_info () =
if Options_base.profile ()
then Profiler.report ()
else ()
let run () =
Profiler.add "Start";
let input_file = Options.parse () in
(* Debug initialisation needs to be called after options' parsing *)
Debug.init ();
Printexc.record_backtrace (Options_base.debug ());
let input = Parser.parse_file input_file in
Debug.input input;
Profiler.add "Parsing";
let result = Engine.solve input in
Profiler.add "Solver";
print_result result;
check_result result;
verify_model result;
Profiler.add "Model checker";
print_stats result;
Debug.result result;
if Options_base.json_output () then
Json_output.output result (Options_base.json_output_file ())
else ();
Profiler.finish ();
print_profile_info ()
let () = run ()