bugfix for reset calls in C

This commit is contained in:
Brice Gelineau 2011-07-08 10:51:10 +02:00
parent f40dc66e57
commit 10115684d9

View file

@ -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