Revision 17abbe95 src/c_backend.ml
src/c_backend.ml | ||
---|---|---|
432 | 432 |
(* Header Printing functions *) |
433 | 433 |
(********************************************************************************************) |
434 | 434 |
|
435 |
(* Removed because of "open" constructs. No more extern functions *) |
|
436 |
(* |
|
437 | 435 |
let print_prototype fmt decl = |
438 | 436 |
match decl.top_decl_desc with |
439 | 437 |
| ImportedFun m -> ( |
... | ... | |
457 | 455 |
) |
458 | 456 |
) |
459 | 457 |
| _ -> () (* We don't do anything here *) |
460 |
*) |
|
461 | 458 |
|
462 |
let print_prototype fmt decl = |
|
463 |
match decl.top_decl_desc with |
|
464 |
| Open m -> fprintf fmt "#include \"%s.h\"@," m |
|
465 |
| _ -> () (* We don't do anything here *) |
|
466 |
|
|
467 | 459 |
let pp_registers_struct fmt m = |
468 | 460 |
if m.mmemory <> [] |
469 | 461 |
then |
... | ... | |
770 | 762 |
(pp_c_type_decl cpt_type var) def |
771 | 763 |
| _ -> ()) type_table |
772 | 764 |
|
773 |
let print_makefile basename nodename fmt = |
|
774 |
fprintf fmt "GCC=gcc@."; |
|
775 |
fprintf fmt "INC=/usr/local/include/lustrec@."; |
|
776 |
fprintf fmt "@."; |
|
777 |
fprintf fmt "main:@."; |
|
778 |
fprintf fmt "\t${GCC} -I${INC} -I. -c %s.c@." basename; |
|
779 |
fprintf fmt "\t${GCC} -I${INC} -c ${INC}/io_frontend.c@."; |
|
780 |
fprintf fmt "\t${GCC} -I${INC} -c ${INC}/StdLibrary.c@."; |
|
781 |
fprintf fmt "\t${GCC} -o %s_%s io_frontend.o StdLibrary.o -lm %s.o@." basename nodename basename |
|
782 |
|
|
783 | 765 |
(********************************************************************************************) |
784 | 766 |
(* Translation function *) |
785 | 767 |
(********************************************************************************************) |
786 | 768 |
|
787 |
let translate_to_c header_fmt source_fmt makefile_fmt spec_fmt_opt basename prog machines =
|
|
769 |
let translate_to_c header_fmt source_fmt spec_fmt_opt basename prog machines = |
|
788 | 770 |
(* Generating H file *) |
789 | 771 |
|
790 | 772 |
(* Include once: start *) |
... | ... | |
813 | 795 |
(* Generating C file *) |
814 | 796 |
|
815 | 797 |
(* If a main node is identified, generate a main function for it *) |
816 |
let main_include, main_print, main_makefile =
|
|
798 |
let main_include, main_print = |
|
817 | 799 |
match !Options.main_node with |
818 |
| "" -> (fun _ -> ()), (fun _ -> ()), (fun _ -> ())
|
|
800 |
| "" -> (fun _ -> ()), (fun _ -> ()) |
|
819 | 801 |
| main_node -> ( |
820 | 802 |
let main_node_opt = |
821 | 803 |
List.fold_left |
... | ... | |
826 | 808 |
None machines |
827 | 809 |
in |
828 | 810 |
match main_node_opt with |
829 |
| None -> eprintf "Unable to find a main node named %s@.@?" main_node; (fun _ -> ()), (fun _ -> ()), (fun _ -> ())
|
|
830 |
| Some m -> print_main_header, print_main_fun machines m, print_makefile basename !Options.main_node
|
|
811 |
| None -> eprintf "Unable to find a main node named %s@.@?" main_node; (fun _ -> ()), (fun _ -> ()) |
|
812 |
| Some m -> print_main_header, print_main_fun machines m |
|
831 | 813 |
) |
832 | 814 |
in |
833 | 815 |
main_include source_fmt; |
... | ... | |
847 | 829 |
pp_print_newline source_fmt (); |
848 | 830 |
(* Print nodes one by one (in the previous order) *) |
849 | 831 |
List.iter (print_machine source_fmt) machines; |
850 |
main_print source_fmt; |
|
832 |
main_print source_fmt |
|
833 |
|
|
834 |
|
|
835 |
|
|
851 | 836 |
|
852 |
(* Generating Makefile *) |
|
853 |
main_makefile makefile_fmt |
|
854 | 837 |
|
855 | 838 |
(* Local Variables: *) |
856 | 839 |
(* compile-command:"make -C .." *) |
Also available in: Unified diff