From 7b6690d443f4604535363baad2a3ac7a060689a9 Mon Sep 17 00:00:00 2001 From: Adrien Guatto Date: Sat, 2 Oct 2010 13:19:21 +0200 Subject: [PATCH] Cgen: proper assignment from structs. --- compiler/obc/c/cgen.ml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/obc/c/cgen.ml b/compiler/obc/c/cgen.ml index a722e23..3f98fa5 100644 --- a/compiler/obc/c/cgen.ml +++ b/compiler/obc/c/cgen.ml @@ -212,6 +212,15 @@ and create_affect_stm dest src ty = (Clhs (Carray (src, Clhs (Cvar x)))) bty)] | _ -> assert false (** TODO: add missing cases eg for records *) ) + | Cty_id ln -> + (match src with + | Cstructlit (_, ce_list) -> + let create_affect { f_name = f_name; + Signature.f_type = f_type; } e stm_list = + let cty = ctype_of_otype f_type in + create_affect_stm (Cfield (dest, f_name)) e cty @ stm_list in + List.fold_right2 create_affect (find_struct ln) ce_list [] + | _ -> [Caffect (dest, src)]) | _ -> [Caffect (dest, src)] (** Returns the expression to use e as an argument of