Project

General

Profile

Revision ef34b4ae src/backends/C/c_backend_common.ml

View differences:

src/backends/C/c_backend_common.ml
21 21
    (Filename.basename Sys.executable_name) 
22 22
    Version.number 
23 23
    (if !Options.ansi then "ANSI C90" else "C99")
24

  
25

  
24
 
26 25
(* Generation of a non-clashing name for the self memory variable (for step and reset functions) *)
27 26
let mk_self m =
28 27
  mk_new_name (m.mstep.step_inputs@m.mstep.step_outputs@m.mstep.step_locals@m.mmemory) "self"
......
235 234
    fmt 
236 235
    m.mstep.step_checks
237 236

  
237
(********************************************************************************************)
238
(*                       Struct Printing functions                                          *)
239
(********************************************************************************************)
240

  
241
let pp_registers_struct fmt m =
242
  if m.mmemory <> []
243
  then
244
    fprintf fmt "@[%a {@[%a; @]}@] _reg; "
245
      pp_machine_regtype_name m.mname.node_id
246
      (Utils.fprintf_list ~sep:"; " pp_c_decl_struct_var) m.mmemory
247
  else
248
    ()
249

  
250
let print_machine_struct fmt m =
251
  if fst (get_stateless_status m) then
252
    begin
253
    end
254
  else
255
    begin
256
      (* Define struct *)
257
      fprintf fmt "@[%a {@[%a%a%t@]};@]@."
258
	pp_machine_memtype_name m.mname.node_id
259
	pp_registers_struct m
260
	(Utils.fprintf_list ~sep:"; " pp_c_decl_instance_var) m.minstances
261
	(Utils.pp_final_char_if_non_empty "; " m.minstances)
262
    end
263

  
264
let print_machine_struct_from_header fmt inode =
265
  if inode.nodei_stateless then
266
    begin
267
    end
268
  else
269
    begin
270
      (* Declare struct *)
271
      fprintf fmt "@[%a;@]@."
272
	pp_machine_memtype_name inode.nodei_id
273
    end
238 274

  
239 275
(********************************************************************************************)
240 276
(*                      Prototype Printing functions                                        *)
......
271 307
    pp_machine_memtype_name name
272 308
    self
273 309

  
274
let print_import_prototype fmt (s, _, _) =
310
let print_import_prototype fmt (_, s, _) =
275 311
  fprintf fmt "#include \"%s.h\"@," s
276 312

  
313
let print_import_alloc_prototype fmt (_, s, _) =
314
  fprintf fmt "#include \"%s_alloc.h\"@," s
315

  
316
let print_extern_alloc_prototypes fmt (_,_, header) =
317
  List.iter (fun decl -> match decl.top_decl_desc with
318
  | ImportedNode ind when not ind.nodei_stateless ->
319
    let static = List.filter (fun v -> v.var_dec_const) ind.nodei_inputs
320
    in fprintf fmt "extern %a;@." print_alloc_prototype (ind.nodei_id, static)
321
  | _                -> ()
322
  ) header
323

  
277 324
(* Local Variables: *)
278 325
(* compile-command:"make -C ../../.." *)
279 326
(* End: *)

Also available in: Unified diff