Project

General

Profile

Revision 3769b712 src/main_lustre_verifier.ml

View differences:

src/main_lustre_verifier.ml
10 10
(********************************************************************)
11 11

  
12 12
open Format
13
open Log
14
open Compiler_common
13
open Lustrec.Log
14
open Lustrec.Compiler_common
15 15

  
16
open Utils
17
open Lustre_types
16
open Lustrec.Utils
17
open Lustrec.Lustre_types
18 18
 
19 19

  
20 20
let usage = "Usage: lustrev [options] \x1b[4msource file\x1b[0m"
......
43 43
*)
44 44
let rec verify dirname basename extension =
45 45
  let source_name = dirname ^ "/" ^ basename ^ extension in
46
  Options.compile_header := false; (* to avoid producing .h / .lusic *)
47
  Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 0>");
48
  decr Options.verbose_level;
46
  Lustrec.Options.compile_header := false; (* to avoid producing .h / .lusic *)
47
  Lustrec.Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 0>");
48
  decr Lustrec.Options.verbose_level;
49 49

  
50 50
  (* Parsing source *)
51 51
  let prog = parse source_name extension in
52 52

  
53 53
  (* Checking which solver is active *)
54
  incr Options.verbose_level;
54
  incr Lustrec.Options.verbose_level;
55 55
  let verifier = Verifiers.get_active () in
56
  let module Verifier = (val verifier : VerifierType.S) in
56
  let module Verifier = (val verifier : Lustrec.VerifierType.S) in
57 57

  
58
  decr Options.verbose_level;
58
  decr Lustrec.Options.verbose_level;
59 59
  let params = Verifier.get_normalization_params () in
60 60
  (* Normalizing it *)
61 61
  let prog, dependencies = 
62
    Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 2>.. Phase 1 : Normalisation@,");
62
    Lustrec.Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 2>.. Phase 1 : Normalisation@,");
63 63
    try
64
      incr Options.verbose_level;
65
      decr Options.verbose_level;
64
      incr Lustrec.Options.verbose_level;
65
      decr Lustrec.Options.verbose_level;
66 66
      Compiler_stages.stage1 params prog dirname basename extension
67 67
    with Compiler_stages.StopPhase1 prog -> (
68
      if !Options.print_nodes then (
69
        Format.printf "%a@.@?" Printers.pp_node_list prog;
68
      if !Lustrec.Options.print_nodes then (
69
        Format.printf "%a@.@?" Lustrec.Printers.pp_node_list prog;
70 70
        exit 0
71 71
      )
72 72
      else
73 73
        assert false
74 74
    )
75 75
  in
76
  Log.report ~level:1 (fun fmt -> fprintf fmt "@]@,");
77
  Log.report ~level:3 (fun fmt -> fprintf fmt ".. Normalized program:@ %a@ "Printers.pp_prog prog);
76
  Lustrec.Log.report ~level:1 (fun fmt -> fprintf fmt "@]@,");
77
  Lustrec.Log.report ~level:3 (fun fmt -> fprintf fmt ".. Normalized program:@ %a@ "Lustrec.Printers.pp_prog prog);
78 78

  
79
  Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 2>.. Phase 2 : Machines generation@,");
79
  Lustrec.Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 2>.. Phase 2 : Machines generation@,");
80 80

  
81 81
  let prog, machine_code = 
82 82
    Compiler_stages.stage2 params prog 
83 83
  in
84 84

  
85
  Log.report ~level:1 (fun fmt -> fprintf fmt "@]@ ");
86
  Log.report ~level:3 (fun fmt -> fprintf fmt ".. Generated machines:@ %a@ "
87
                                    Machine_code_common.pp_machines machine_code);
85
  Lustrec.Log.report ~level:1 (fun fmt -> fprintf fmt "@]@ ");
86
  Lustrec.Log.report ~level:3 (fun fmt -> fprintf fmt ".. Generated machines:@ %a@ "
87
                                    Lustrec.Machine_code_common.pp_machines machine_code);
88 88
  
89 89
  if Scopes.Plugin.show_scopes () then
90 90
    begin
91
      let all_scopes = Scopes.compute_scopes prog !Options.main_node in
91
      let all_scopes = Scopes.compute_scopes prog !Lustrec.Options.main_node in
92 92
      (* Printing scopes *)
93
      if !Options.verbose_level >= 1 then
93
      if !Lustrec.Options.verbose_level >= 1 then
94 94
	Format.printf "Possible scopes are:@   ";
95 95
      Format.printf "@[<v>%a@ @]@ @?" Scopes.print_scopes all_scopes;
96 96
      exit 0
......
100 100
  let machine_code = Plugins.refine_machine_code prog machine_code in
101 101

  
102 102
  (*assert (dependencies = []); (* Do not handle deps yet *)*)
103
  incr Options.verbose_level;
103
  incr Lustrec.Options.verbose_level;
104 104
  Verifier.run basename prog machine_code;
105 105
  begin
106
    decr Options.verbose_level;
107
    Log.report ~level:1 (fun fmt -> fprintf fmt ".. done !@ ");
108
    incr Options.verbose_level;
109
    Log.report ~level:1 (fun fmt -> fprintf fmt "@]@.");
106
    decr Lustrec.Options.verbose_level;
107
    Lustrec.Log.report ~level:1 (fun fmt -> fprintf fmt ".. done !@ ");
108
    incr Lustrec.Options.verbose_level;
109
    Lustrec.Log.report ~level:1 (fun fmt -> fprintf fmt "@]@.");
110 110
    (* We stop the process here *)
111 111
    exit 0
112 112
  end
......
128 128
    raise (Arg.Bad ("Can only compile *.lusi, *.lus or *.ec files"))
129 129

  
130 130
let _ =
131
  Global.initialize ();
132
  Corelang.add_internal_funs ();
131
  Lustrec.Global.initialize ();
132
  Lustrec.Corelang.add_internal_funs ();
133 133
  try
134 134
    Printexc.record_backtrace true;
135 135

  
136
    let options = Options_management.lustrev_options @ (Verifiers.options ()) in
136
    let options = Lustrec.Options_management.lustrev_options @ (Verifiers.options ()) in
137 137
    
138 138
    Arg.parse options anonymous usage
139 139
  with
140
  | Parse.Error _
141
    | Types.Error (_,_) | Clocks.Error (_,_) -> exit 1
142
  | Error.Error (loc , kind) (*| Task_set.Error _*) -> 
143
     Error.pp_error loc (fun fmt -> Error.pp_error_msg fmt kind);
144
     exit (Error.return_code kind)
145
  (* | Causality.Error _  -> exit (Error.return_code Error.AlgebraicLoop) *)
140
  | Lustrec.Parse.Error _
141
    | Lustrec.Types.Error (_,_) | Lustrec.Clocks.Error (_,_) -> exit 1
142
  |Lustrec.Error.Error (loc , kind) (*| Task_set.Error _*) -> 
143
    Lustrec.Error.pp_error loc (fun fmt ->Lustrec.Error.pp_error_msg fmt kind);
144
     exit (Lustrec.Error.return_code kind)
145
  (* | Lustrec.Causality.Error _  -> exit (Error.return_codeLustrec.Error.AlgebraicLoop) *)
146 146
  | Sys_error msg -> (eprintf "Failure: %s@." msg); exit 1
147 147
  | exc -> (track_exception (); raise exc) 
148 148

  

Also available in: Unified diff