From 2b18fcab93b818565a56380c747fef78b990df49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pasteur?= Date: Tue, 18 Jan 2011 17:52:44 +0100 Subject: [PATCH] Generate C code for static records This fixes the test t8.ept --- compiler/obc/c/cgen.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/obc/c/cgen.ml b/compiler/obc/c/cgen.ml index 9831cb8..4f6728a 100644 --- a/compiler/obc/c/cgen.ml +++ b/compiler/obc/c/cgen.ml @@ -244,6 +244,14 @@ let rec cexpr_of_static_exp se = | Sfield _ -> assert false | Sconstructor c -> Cconst (Ctag (cname_of_qn c)) | Sarray sl -> Carraylit (List.map cexpr_of_static_exp sl) + | Srecord fl -> + let ty_name = + match Modules.unalias_type se.se_ty with + | Types.Tid n -> cname_of_qn n + | _ -> assert false + in + Cstructlit (ty_name, + List.map (fun (_, se) -> cexpr_of_static_exp se) fl) | Sarray_power(n,c) -> let cc = cexpr_of_static_exp c in Carraylit (repeat_list cc (int_of_static_exp n)) @@ -259,7 +267,7 @@ let rec cexpr_of_static_exp se = else cexpr_of_static_exp se' | Stuple _ -> assert false (** TODO *) - | Srecord _ -> assert false (** TODO *) + (** [cexpr_of_exp exp] translates the Obj action [exp] to a C expression. *) let rec cexpr_of_exp var_env exp =