Project

General

Profile

Revision 7dedc5f0 src/main_lustre_compiler.ml

View differences:

src/main_lustre_compiler.ml
131 131
      eprintf "Stateless status mismatch between defined status and declared status in lustre interface file: %a@."
132 132
	Stateless.pp_error err;
133 133
      raise exc
134
    
134

  
135
let extract_interface prog =
136
 List.fold_right
137
   (fun decl header ->
138
    match decl.top_decl_desc with
139
    | Node nd        -> { decl with top_decl_desc = ImportedNode (Corelang.get_node_interface nd) } :: header 
140
    | ImportedNode _ -> header
141
    | Consts _
142
    | Type _
143
    | Open _         -> decl :: header)
144
   prog []
145

  
146
let write_compiled_header (header : top_decl list) basename extension =
147
  let target_name = basename^extension in
148
  let outchan = open_out_bin target_name in
149
  begin
150
    Marshal.to_channel outchan header [];
151
    close_out outchan
152
  end
153

  
154
let read_compiled_header basename extension =
155
  let source_name = basename^extension in
156
  let inchan = open_in_bin source_name in
157
  let header = (Marshal.from_channel inchan : top_decl list) in
158
  begin
159
    close_in inchan;
160
    header
161
  end
162

  
163
let compile_header basename extension =
164
   let header_name = basename^extension in
165
   let header = load_lusi true header_name in
166
   begin
167
     ignore (check_lusi header);
168
     write_compiled_header header basename (extension^"c")
169
   end
170

  
171
let compile_prog basename extension =
172

  
135 173
let rec compile basename extension =
136 174

  
137 175
  (* Loading the input file *)

Also available in: Unified diff