let init_file_names () =
let err= ref false in
let dispErr mesg f =
Aorai_option.error "Error. File '%s' %s.\n" f mesg;
err:=true
in
let freshname pre suf =
let rec fn p s n =
if not (Sys.file_exists (p^(string_of_int n)^s)) then (p^(string_of_int n)^s)
else fn p s (n+1)
in
let name =
if not (Sys.file_exists (pre^suf)) then pre^suf
else fn pre suf 0
in name
in
c_file := List.hd (Parameters.Files.get ());
if (!c_file="") then dispErr ": invalid C file name" !c_file;
if (not (Sys.file_exists !c_file)) then dispErr "not found" !c_file;
output_c_file := (Aorai_option.Output_C_File.get ()) ;
if (!output_c_file="") then output_c_file:=freshname ((Filename.chop_extension !c_file)^"_annot") ".c";
if Aorai_option.Dot.get () then
dot_file:=freshname (Filename.chop_extension !c_file) ".dot";
if Aorai_option.Ya.get () = "" then
if Aorai_option.Buchi.get () = "" then
begin
ltl_file := Aorai_option.Ltl_File.get ();
if (!ltl_file="") then dispErr ": invalid LTL file name" !ltl_file;
if (not (Sys.file_exists !ltl_file)) then dispErr "not found" !ltl_file;
if Aorai_option.To_Buchi.get () <> "" then
begin
ltl_tmp_file:=
freshname
(Filename.chop_extension
(Aorai_option.promela_file ())) ".ltl";
promela_file:= Aorai_option.promela_file ();
toBeRemoved:=(!ltl_tmp_file)::!toBeRemoved
end
else
begin
ltl_tmp_file:=
Extlib.temp_file_cleanup_at_exit
(Filename.basename !c_file) ".ltl";
promela_file:=
freshname (Filename.chop_extension !ltl_tmp_file) ".promela";
toBeRemoved:=(!promela_file)::!toBeRemoved;
toBeRemoved:=(!ltl_tmp_file)::!toBeRemoved
end
end
else
begin
if Aorai_option.To_Buchi.get () <> "" &&
Aorai_option.Ltl_File.get () <> ""
then begin
Aorai_option.error "Error. '-buchi' option is incompatible with '-to-buchi' and '-ltl' options.";
err:=true
end;
promela_file := Aorai_option.promela_file ();
end
else
begin
ya_file := Aorai_option.Ya.get ();
if (!ya_file="") then dispErr ": invalid Ya file name" !ya_file;
if (not (Sys.file_exists !ya_file)) then dispErr "not found" !ya_file
end;
if Globals.has_entry_point () then begin
let ep,_ =Globals.entry_point () in
root := Kernel_function.get_name ep
end else
Aorai_option.abort
"The file '%s' does not have any entry point. Generation stopped"
!c_file;
display_status ();
!err