Revision 70e1006b src/backends/C/c_backend_src.ml
src/backends/C/c_backend_src.ml | ||
---|---|---|
259 | 259 |
|
260 | 260 |
let print_stateless_code dependencies fmt m = |
261 | 261 |
let self = "__ERROR__" in |
262 |
if not (!Options.ansi && is_generic_node { top_decl_desc = Node m.mname; top_decl_loc = Location.dummy_loc }) |
|
262 |
if not (!Options.ansi && is_generic_node { top_decl_desc = Node m.mname; top_decl_loc = Location.dummy_loc; top_decl_owner = ""; top_decl_itf = false })
|
|
263 | 263 |
then |
264 | 264 |
(* C99 code *) |
265 | 265 |
fprintf fmt "@[<v 2>%a {@,%a%t@,%a%a%t%t@]@,}@.@." |
... | ... | |
296 | 296 |
(Utils.pp_newline_if_non_empty m.minit) |
297 | 297 |
|
298 | 298 |
let print_step_code dependencies fmt m self = |
299 |
if not (!Options.ansi && is_generic_node { top_decl_desc = Node m.mname; top_decl_loc = Location.dummy_loc }) |
|
299 |
if not (!Options.ansi && is_generic_node { top_decl_desc = Node m.mname; top_decl_loc = Location.dummy_loc; top_decl_owner = ""; top_decl_itf = false })
|
|
300 | 300 |
then |
301 | 301 |
(* C99 code *) |
302 | 302 |
let array_mems = List.filter (fun v -> Types.is_array_type v.var_type) m.mmemory in |
... | ... | |
345 | 345 |
begin |
346 | 346 |
(* Alloc function, only if non static mode *) |
347 | 347 |
if (not !Options.static_mem) then |
348 |
(
|
|
348 |
begin
|
|
349 | 349 |
fprintf fmt "@[<v 2>%a {@,%a@]@,}@.@." |
350 | 350 |
print_alloc_prototype (m.mname.node_id, m.mstatic) |
351 | 351 |
print_alloc_code m; |
352 |
);
|
|
352 |
end;
|
|
353 | 353 |
let self = mk_self m in |
354 | 354 |
(* Reset function *) |
355 | 355 |
print_reset_code dependencies fmt m self; |
... | ... | |
360 | 360 |
|
361 | 361 |
let print_lib_c source_fmt basename prog machines dependencies = |
362 | 362 |
|
363 |
fprintf source_fmt "#include <stdlib.h>@.#include <assert.h>@.#include \"%s\"@.@." (basename^".h"); |
|
363 |
fprintf source_fmt "#include <assert.h>@."; |
|
364 |
if not !Options.static_mem then |
|
365 |
begin |
|
366 |
fprintf source_fmt "#include <stdlib.h>@."; |
|
367 |
end; |
|
368 |
print_import_prototype source_fmt (true, basename, []); |
|
369 |
pp_print_newline source_fmt (); |
|
364 | 370 |
(* Print the svn version number and the supported C standard (C90 or C99) *) |
365 | 371 |
print_version source_fmt; |
366 | 372 |
(* Print the prototype of imported nodes *) |
367 |
fprintf source_fmt "/* Imported nodes declarations */@.";
|
|
373 |
fprintf source_fmt "/* Import dependencies */@.";
|
|
368 | 374 |
fprintf source_fmt "@[<v>"; |
369 | 375 |
List.iter (print_import_prototype source_fmt) dependencies; |
370 | 376 |
fprintf source_fmt "@]@."; |
371 | 377 |
(* Print consts *) |
372 | 378 |
fprintf source_fmt "/* Global constants (definitions) */@."; |
373 |
List.iter (fun c -> print_const_def source_fmt c) (get_consts prog); |
|
379 |
fprintf source_fmt "@[<v>"; |
|
380 |
List.iter (fun c -> print_const_def source_fmt (const_of_top c)) (get_consts prog); |
|
381 |
fprintf source_fmt "@]@."; |
|
382 |
if not !Options.static_mem then |
|
383 |
begin |
|
384 |
fprintf source_fmt "/* External allocation function prototypes */@."; |
|
385 |
fprintf source_fmt "@[<v>"; |
|
386 |
List.iter (print_extern_alloc_prototypes source_fmt) dependencies; |
|
387 |
fprintf source_fmt "@]@."; |
|
388 |
fprintf source_fmt "/* Node allocation function prototypes */@."; |
|
389 |
fprintf source_fmt "@[<v>"; |
|
390 |
List.iter (fun m -> fprintf source_fmt "%a;@." print_alloc_prototype (m.mname.node_id, m.mstatic)) machines; |
|
391 |
fprintf source_fmt "@]@."; |
|
392 |
end; |
|
393 |
(* Print the struct definitions of all machines. *) |
|
394 |
fprintf source_fmt "/* Struct definitions */@."; |
|
395 |
fprintf source_fmt "@[<v>"; |
|
396 |
List.iter (print_machine_struct source_fmt) machines; |
|
397 |
fprintf source_fmt "@]@."; |
|
374 | 398 |
pp_print_newline source_fmt (); |
375 | 399 |
(* Print nodes one by one (in the previous order) *) |
376 | 400 |
List.iter (print_machine dependencies source_fmt) machines; |
Also available in: Unified diff