Fix C backend with new obc ast

This commit is contained in:
Cédric Pasteur 2011-04-19 09:23:52 +02:00
parent 028dfe0468
commit 3c8fc39745
3 changed files with 19 additions and 3 deletions

View file

@ -106,7 +106,7 @@ let add context expected_kind e =
| (Evar _ | Eapp ({ a_op = Efield }, _, _) | Ewhen _
| Eapp ({ a_op = Etuple }, _, _) | Econst _) , ExtValue -> false
| _ , ExtValue -> true
| _ -> Format.printf "Not normalizing \n"; false in
| _ -> false in
if up then
let context, n = equation context e in
context, { e with e_desc = n }

View file

@ -737,7 +737,8 @@ let cdefs_and_cdecls_of_type_decl otd =
(** [cfile_list_of_oprog oprog] translates the Obc program [oprog] to a list of
C source and header files. *)
let cfile_list_of_oprog_ty_decls name oprog =
let cdefs_and_cdecls = List.map cdefs_and_cdecls_of_type_decl oprog.p_types in
let types = Obc_utils.program_types oprog in
let cdefs_and_cdecls = List.map cdefs_and_cdecls_of_type_decl types in
let (cty_defs, cty_decls) = List.split cdefs_and_cdecls in
let filename_types = name ^ "_types" in
@ -751,8 +752,9 @@ let global_file_header name prog =
let dependencies = ModulSet.elements (Obc_utils.Deps.deps_program prog) in
let dependencies = List.map modul_to_string dependencies in
let classes = program_classes prog in
let (decls, defs) =
List.split (List.map cdefs_and_cdecls_of_class_def prog.p_classes) in
List.split (List.map cdefs_and_cdecls_of_class_def classes) in
let decls = List.concat decls
and defs = List.concat defs in

View file

@ -195,3 +195,17 @@ let rec copy_array pass dest src = match dest.l_ty with
| _ ->
Aassgn(dest, Epattern src)
*)
let program_types p =
let add_type acc pd = match pd with
| Ptype ty -> ty :: acc
| _ -> acc
in
List.fold_left add_type [] p.p_desc
let program_classes p =
let add_class acc pd = match pd with
| Pclass cd -> cd :: acc
| _ -> acc
in
List.fold_left add_class [] p.p_desc