bugfix for reset calls in C
This commit is contained in:
parent
f40dc66e57
commit
10115684d9
1 changed files with 12 additions and 14 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue