Project

General

Profile

Revision 1e48ef45 src/backends/C/c_backend_header.ml

View differences:

src/backends/C/c_backend_header.ml
34 34
struct
35 35

  
36 36
let print_import_standard fmt =
37
  fprintf fmt "#include \"%s/include/lustrec/arrow.h\"@.@." Version.prefix
37
  fprintf fmt "#include \"%s/arrow.h\"@.@." Version.include_path
38 38

  
39 39
let print_static_declare_instance attr fmt (i, (m, static)) =
40 40
  fprintf fmt "%a(%s, %a%t%s)"
......
163 163

  
164 164
let print_machine_decl_from_header fmt inode =
165 165
  (*Mod.print_machine_decl_prefix fmt m;*)
166
  if inode.nodei_stateless then
167
    begin
168
      fprintf fmt "extern %a;@.@."
169
	print_stateless_prototype
170
	(inode.nodei_id, inode.nodei_inputs, inode.nodei_outputs)
171
    end
166
  if inode.nodei_prototype = Some "C" then
167
    if inode.nodei_stateless then
168
      begin
169
	fprintf fmt "extern %a;@.@."
170
	  print_stateless_C_prototype
171
	  (inode.nodei_id, inode.nodei_inputs, inode.nodei_outputs)
172
      end
173
    else (
174
      raise (Invalid_argument ("A node with declared prototype C cannot be stateful, it has to be a function")))
172 175
  else
176
    if inode.nodei_stateless then
173 177
    begin
174
      let static_inputs = List.filter (fun v -> v.var_dec_const) inode.nodei_inputs in
175
      let used name =
176
	   (List.exists (fun v -> v.var_id = name) inode.nodei_inputs)
177
	|| (List.exists (fun v -> v.var_id = name) inode.nodei_outputs) in
178
      let self = mk_new_name used "self" in
179 178
      fprintf fmt "extern %a;@.@."
180
	(print_reset_prototype self) (inode.nodei_id, static_inputs);
181

  
182
      fprintf fmt "extern %a;@.@."
183
	(print_step_prototype self)
179
	print_stateless_prototype 
184 180
	(inode.nodei_id, inode.nodei_inputs, inode.nodei_outputs)
185 181
    end
182
    else 
183
      begin
184
	let static_inputs = List.filter (fun v -> v.var_dec_const) inode.nodei_inputs in
185
	let used name =
186
	  (List.exists (fun v -> v.var_id = name) inode.nodei_inputs)
187
	  || (List.exists (fun v -> v.var_id = name) inode.nodei_outputs) in
188
	let self = mk_new_name used "self" in
189
	fprintf fmt "extern %a;@.@."
190
	  (print_reset_prototype self) (inode.nodei_id, static_inputs);
191
	
192
	fprintf fmt "extern %a;@.@."
193
	  (print_step_prototype self)
194
	  (inode.nodei_id, inode.nodei_inputs, inode.nodei_outputs)
195
      end
186 196

  
187 197
let print_const_decl fmt cdecl =
188 198
  fprintf fmt "extern %a;@." 
......
303 313
    pp_print_newline header_fmt ()
304 314
  end
305 315

  
316
(* Function called when compiling a lusi file and generating the associated C
317
   header. *)
306 318
let print_header_from_header header_fmt basename header =
307 319
  (* Include once: start *)
308 320
  let baseNAME = String.uppercase basename in

Also available in: Unified diff