Project

General

Profile

Revision 217837e2 src/main_lustre_compiler.ml

View differences:

src/main_lustre_compiler.ml
34 34
    close_out h_out
35 35
  end
36 36

  
37
(* compile a .lusi header file *)
38
let compile_header dirname  basename extension =
39
  let destname = !Options.dest_dir ^ "/" ^ basename in
40
  let header_name = basename ^ extension in
41
  let lusic_ext = extension ^ "c" in
42
  begin
43
    Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v>");
44
    let header = parse_header true (dirname ^ "/" ^ header_name) in
45
    (* Disbaled today, should be done anyway when following the regular compilation 
46
ignore (Modules.load ~is_header:true ISet.empty header); *)
47
    ignore (check_top_decls header); (* typing/clocking with an empty env *)
48
    create_dest_dir ();
49
    Log.report ~level:1
50
      (fun fmt -> fprintf fmt ".. generating compiled header file %sc@," (destname ^ extension));
51
    Lusic.write_lusic true header destname lusic_ext;
52
    generate_lusic_header destname lusic_ext;
53

  
54

  
55

  
56
    Log.report ~level:1 (fun fmt -> fprintf fmt ".. done !@ @]@ ")
57
  end
58 37

  
59 38

  
60 39

  
61 40

  
62 41

  
63 42
(* compile a .lus source file *)
64
let rec compile_source dirname basename extension =
43
let rec compile dirname basename extension =
65 44
  let source_name = dirname ^ "/" ^ basename ^ extension in
66 45

  
67 46
  Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 0>");
68 47

  
69 48
  (* Parsing source *)
70
  let prog = parse_source source_name in
49
  let prog = parse source_name extension in
71 50

  
72 51
  let prog =
73
    if !Options.mpfr then
52
    if !Options.mpfr &&
53
         extension = ".lus" (* trying to avoid the injection of the module for lusi files *) 
54
    then
74 55
      Mpfr.mpfr_module::prog
75 56
    else
76 57
      prog
......
80 61
  let prog, dependencies = 
81 62
    Log.report ~level:1 (fun fmt -> fprintf fmt "@[<v 2>.. Phase 1 : Normalisation@,");
82 63
    try 
83
      Compiler_stages.stage1 params prog dirname basename
64
      Compiler_stages.stage1 params prog dirname basename extension
84 65
    with Compiler_stages.StopPhase1 prog -> (
85 66
      if !Options.lusi then
86 67
	begin
......
118 99
  let machine_code = Plugins.refine_machine_code prog machine_code in
119 100
  Log.report ~level:1 (fun fmt -> fprintf fmt "@]@ @ ");
120 101
  
121
  Compiler_stages.stage3 prog machine_code dependencies basename;
102
  Compiler_stages.stage3 prog machine_code dependencies basename extension;
122 103
  begin
123 104
    Log.report ~level:1 (fun fmt -> fprintf fmt ".. done !@ @]@.");
124 105
    (* We stop the process here *)
......
127 108

  
128 109
let compile dirname basename extension =
129 110
  match extension with
130
  | ".lusi"  -> compile_header dirname basename extension
131
  | ".lus"   -> compile_source dirname basename extension
111
  | ".lusi"  
112
  | ".lus"   -> compile dirname basename extension
132 113
  | _        -> assert false
133 114

  
134 115
let anonymous filename =

Also available in: Unified diff