Project

General

Profile

Revision 53206908 src/backends/C/c_backend.ml

View differences:

src/backends/C/c_backend.ml
26 26
*)
27 27

  
28 28
let gen_files funs basename prog machines dependencies header_file source_lib_file source_main_file makefile_file machines =
29

  
30 29
  let header_out = open_out header_file in
31 30
  let header_fmt = formatter_of_out_channel header_out in
32 31
  let source_lib_out = open_out source_lib_file in
33 32
  let source_lib_fmt = formatter_of_out_channel source_lib_out in
34

  
33
  
35 34
  let print_header, print_lib_c, print_main_c, print_makefile = funs in
36 35
  (* Generating H file *)
37 36
  print_header header_fmt basename prog machines dependencies;
38
 
37
  
39 38
  (* Generating Lib C file *)
40 39
  print_lib_c source_lib_fmt basename prog machines dependencies;
41
 
40

  
42 41
  close_out header_out;
43 42
  close_out source_lib_out;
44 43

  
......
46 45
  | "" ->  () (* No main node: we do not genenrate main nor makefile *)
47 46
  | main_node -> (
48 47
    match Machine_code.get_machine_opt main_node machines with
49
    | None -> Format.eprintf "Unable to find a main node named %s@.@?" main_node; assert false
48
    | None -> begin
49
      Global.main_node := main_node;
50
      Format.eprintf "Code generation error: %a@." Corelang.pp_error LustreSpec.Main_not_found;
51
      raise (Corelang.Error (Location.dummy_loc, LustreSpec.Main_not_found))
52
    end
50 53
    | Some m -> begin
51 54
      let source_main_out = open_out source_main_file in
52 55
      let source_main_fmt = formatter_of_out_channel source_main_out in
......
65 68
    end
66 69
  )
67 70

  
68
let translate_to_c header source_lib source_main makefile basename prog machines dependencies =
71
let translate_to_c header source_lib source_main makefile basename prog machines dependencies  =
72

  
69 73
  match !Options.spec with
70 74
  | "no" -> begin
71 75
    let module HeaderMod = C_backend_header.EmptyMod in
......
77 81
    let module Source = C_backend_src.Main (SourceMod) in
78 82
    let module SourceMain = C_backend_main.Main (SourceMainMod) in
79 83
    let module Makefile = C_backend_makefile.Main (MakefileMod) in
80

  
84
        
81 85
    let funs = 
82 86
      Header.print_alloc_header, 
83 87
      Source.print_lib_c, 
......
100 104
    let module Source = C_backend_src.Main (SourceMod) in
101 105
    let module SourceMain = C_backend_main.Main (SourceMainMod) in
102 106
    let module Makefile = C_backend_makefile.Main (MakefileMod) in
103

  
107
        
104 108
    let funs = 
105 109
      Header.print_alloc_header, 
106 110
      Source.print_lib_c,

Also available in: Unified diff