From 10115684d99b23d85d7575fab498f6026effb6c9 Mon Sep 17 00:00:00 2001 From: Brice Gelineau Date: Fri, 8 Jul 2011 10:51:10 +0200 Subject: [PATCH] bugfix for reset calls in C --- compiler/obc/c/cgen.ml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/compiler/obc/c/cgen.ml b/compiler/obc/c/cgen.ml index 3ef147c..c90c330 100644 --- a/compiler/obc/c/cgen.ml +++ b/compiler/obc/c/cgen.ml @@ -560,20 +560,18 @@ let rec cstm_of_act out_env var_env obj_env act = let on = obj_ref_name o in let obj = assoc_obj on obj_env in let classn = cname_of_qn obj.o_class in - (match obj.o_size with - | None -> - [Csexpr (Cfun_call (classn ^ "_reset", - [Caddrof (Cfield (Cderef (Cvar "self"), local_qn (name on)))]))] - | Some size -> - let field = Cfield (Cderef (Cvar "self"), local_qn (name on)) in - let rec mk_loop nl elt = match nl with - | [] -> [Csexpr (Cfun_call (classn ^ "_reset", [Caddrof elt] ))] - | n::nl -> - let x = gen_symbol () in - let elt = Carray(elt, Cvar x) in - [Cfor(x, Cconst (Ccint 0), cexpr_of_static_exp n, mk_loop nl elt)] - in - mk_loop size field + let field = Cfield (Cderef (Cvar "self"), local_qn (name on)) in + (match o with + | Oobj _ -> + [Csexpr (Cfun_call (classn ^ "_reset", [Caddrof field]))] + | Oarray (_, pl) -> + let rec mk_loop pl field = match pl with + | [] -> + [Csexpr (Cfun_call (classn ^ "_reset", [Caddrof field]))] + | p::pl -> + mk_loop pl (Carray(field, cexpr_of_pattern out_env var_env p)) + in + mk_loop pl field ) (** Step functions applications can return multiple values, so we use a