Project

General

Profile

Revision 6a6abd76 src/c_backend.ml

View differences:

src/c_backend.ml
601 601
  let array_mem = List.filter (fun v -> Types.is_array_type v.var_type) m.mmemory in
602 602
  let inst = mk_instance m in
603 603
  let attr = mk_attribute m in
604
  fprintf fmt "@[<v 2>#define %a(%s, %a%tinst)\\@,%s %a inst;\\@,%a%t%a;@,@]"
604
  fprintf fmt "@[<v 2>#define %a(%s, %a%t%s)\\@,%s %a %s;\\@,%a%t%a;@,@]"
605 605
    pp_machine_static_declare_name m.mname.node_id
606 606
    attr
607 607
    (Utils.fprintf_list ~sep:", " (pp_c_var_read m)) m.mstatic
608 608
    (Utils.pp_final_char_if_non_empty ", " m.mstatic)
609
    inst
609 610
    attr
610 611
    pp_machine_memtype_name m.mname.node_id
612
    inst
611 613
    (Utils.fprintf_list ~sep:";\\@," pp_c_decl_local_var) array_mem
612 614
    (Utils.pp_final_char_if_non_empty ";\\@," array_mem)
613 615
    (Utils.fprintf_list ~sep:";\\@,"
......
858 860
let print_main_header fmt =
859 861
  fprintf fmt "#include <stdio.h>@.#include <unistd.h>@.#include \"%s/include/lustrec/io_frontend.h\"@." Version.prefix
860 862

  
861
let rec pp_c_type_decl filename cpt var fmt tdecl =
863
let rec pp_c_struct_type_field filename cpt var fmt (label, tdesc) =
864
  fprintf fmt "%a %a" (pp_c_type_decl filename cpt var) tdesc pp_print_string label
865
and pp_c_type_decl filename cpt var fmt tdecl =
862 866
  match tdecl with
863 867
  | Tydec_any           -> assert false
864 868
  | Tydec_int           -> fprintf fmt "int %s" var
......
873 877
      incr cpt;
874 878
      fprintf fmt "enum _enum_%s_%d { %a } %s" filename !cpt (Utils.fprintf_list ~sep:", " pp_print_string) tl var
875 879
    end
880
  | Tydec_struct fl ->
881
    begin
882
      incr cpt;
883
      fprintf fmt "struct _struct_%s_%d { %a } %s" filename !cpt (Utils.fprintf_list ~sep:"; " (pp_c_struct_type_field filename cpt var)) fl var
884
    end
876 885

  
877 886
let print_type_definitions fmt filename =
878 887
  let cpt_type = ref 0 in

Also available in: Unified diff