Project

General

Profile

Revision 3769b712 src/backends/C/c_backend.ml

View differences:

src/backends/C/c_backend.ml
17 17
(* USELESS
18 18
let makefile_opt print basename dependencies makefile_fmt machines =
19 19
  (* If a main node is identified, generate a main target for it *)
20
  match !Options.main_node with
20
  match !Lustrec.Options.main_node with
21 21
  | "" ->  ()
22 22
  | main_node -> (
23 23
    match Machine_code.get_machine_opt main_node machines with
24 24
    | None -> Format.eprintf "Unable to find a main node named %s@.@?" main_node; ()
25
    | Some _ -> print basename !Options.main_node dependencies makefile_fmt
25
    | Some _ -> print basename !Lustrec.Options.main_node dependencies makefile_fmt
26 26
  )
27 27
*)
28 28

  
29 29
let gen_files funs basename prog machines dependencies =
30
  let destname = !Options.dest_dir ^ "/" ^ basename in
30
  let destname = !Lustrec.Options.dest_dir ^ "/" ^ basename in
31 31
  
32 32
  let print_header, print_lib_c, print_main_c, print_makefile, preprocess (* , print_cmake *) = funs in
33 33

  
......
41 41
  close_out header_out;
42 42
  
43 43
  (* Generating Lib C file *)
44
  let source_lib_file = (if !Options.cpp then destname ^ ".cpp" else destname ^ ".c") in (* Could be changed *)
44
  let source_lib_file = (if !Lustrec.Options.cpp then destname ^ ".cpp" else destname ^ ".c") in (* Could be changed *)
45 45
  let source_lib_out = open_out source_lib_file in
46 46
  let source_lib_fmt = formatter_of_out_channel source_lib_out in
47 47
  print_lib_c source_lib_fmt basename prog machines dependencies;
48 48
  close_out source_lib_out;
49 49

  
50
  (match !Options.main_node with
50
  (match !Lustrec.Options.main_node with
51 51
  | "" ->  () (* No main node: we do not generate main *)
52 52
  | main_node -> (
53
    match Machine_code_common.get_machine_opt machines main_node with
53
    match Lustrec.Machine_code_common.get_machine_opt machines main_node with
54 54
    | None -> begin
55
      Global.main_node := main_node;
56
      Format.eprintf "Code generation error: %a@." Error.pp_error_msg Error.Main_not_found;
57
      raise (Error.Error (Location.dummy_loc, Error.Main_not_found))
55
      Lustrec.Global.main_node := main_node;
56
      Format.eprintf "Code generation error: %a@." Lustrec.Error.pp_error_msg Lustrec.Error.Main_not_found;
57
      raise (Lustrec.Error.Error (Lustrec.Location.dummy_loc,Lustrec.Error.Main_not_found))
58 58
    end
59 59
    | Some m -> begin
60
      let source_main_file = (if !Options.cpp then destname ^ "_main.cpp" else destname ^ "_main.c") in (* Could be changed *)
60
      let source_main_file = (if !Lustrec.Options.cpp then destname ^ "_main.cpp" else destname ^ "_main.c") in (* Could be changed *)
61 61
      let source_main_out = open_out source_main_file in
62 62
      let source_main_fmt = formatter_of_out_channel source_main_out in
63 63

  
......
68 68
    end
69 69
  ));
70 70

  
71
  (match !Options.mauve with
71
  (match !Lustrec.Options.mauve with
72 72
  | "" ->  ()
73 73
  | mauve -> (
74 74
    (* looking for the main node *)
75
    match Machine_code_common.get_machine_opt machines mauve  with
75
    match Lustrec.Machine_code_common.get_machine_opt machines mauve  with
76 76
    | None -> begin
77
      Global.main_node := mauve;
78
      Format.eprintf "Code generation error: %a@." Error.pp_error_msg Error.Main_not_found;
79
      raise (Error.Error (Location.dummy_loc, Error.Main_not_found))
77
      Lustrec.Global.main_node := mauve;
78
      Format.eprintf "Code generation error: %a@." Lustrec.Error.pp_error_msg Lustrec.Error.Main_not_found;
79
      raise (Lustrec.Error.Error (Lustrec.Location.dummy_loc,Lustrec.Error.Main_not_found))
80 80
    end
81 81
    | Some m -> begin
82 82
      let source_mauve_file = destname ^ "_mauve.hpp" in
......
106 106
     - Later option 1 should be removed
107 107
  *)
108 108
  (* Case 1 *)
109
  (match !Options.main_node with
109
  (match !Lustrec.Options.main_node with
110 110
  | "" ->  () (* No main node: we do not generate main *)
111 111
  | main_node -> (
112 112
    let makefile_file = destname ^ ".makefile" in (* Could be changed *)
......
121 121
  
122 122
  (* (\* Case 2 *\) *)
123 123
  (* let cmake_file = "lustrec-" ^ basename ^ ".cmake" in *)
124
  (* let cmake_file_full_path = !Options.dest_dir ^ "/" ^ cmake_file in *)
124
  (* let cmake_file_full_path = !Lustrec.Options.dest_dir ^ "/" ^ cmake_file in *)
125 125
  (* let cmake_out = open_out cmake_file_full_path in *)
126 126
  (* let cmake_fmt = formatter_of_out_channel cmake_out in *)
127 127
  (* (\* Generating Makefile *\) *)
......
131 131
  
132 132

  
133 133
let translate_to_c basename prog machines dependencies =
134
  match !Options.spec with
134
  match !Lustrec.Options.spec with
135 135
  | "no" -> begin
136 136
    let module HeaderMod = C_backend_header.EmptyMod in
137 137
    let module SourceMod = C_backend_src.EmptyMod in

Also available in: Unified diff