diff --git a/compiler/obc/c/async.ml b/compiler/obc/c/async.ml index 99cee0c..4004706 100644 --- a/compiler/obc/c/async.ml +++ b/compiler/obc/c/async.ml @@ -31,3 +31,12 @@ let async_global_objs_decls cd = (fun (name, ty) -> Cdecl_extern (name, ty)) (async_global_objs_vars cd) +let async_reset cd = + List.map + (fun od -> + let global = Cvar (async_global_var_name od) in + let field = Cfield (global, local_qn "mem") in + let reset = cname_of_qn od.o_class ^ "_reset" in + Csexpr (Cfun_call (reset, [Caddrof field]))) + (filter_async_objs cd) + diff --git a/compiler/obc/c/cmain.ml b/compiler/obc/c/cmain.ml index c5a7cc3..1781270 100644 --- a/compiler/obc/c/cmain.ml +++ b/compiler/obc/c/cmain.ml @@ -36,6 +36,7 @@ open Types open Signature open C open Cgen +open Async open Compiler_utils (** {1 Main C function generation} *) @@ -405,6 +406,12 @@ let mk_main name p = (defs, nvar_l @ var_l, res @ res_l, nstep_l @ step_l) with Not_found -> ([],var_l,res_l,step_l) in + let res_l = List.fold_left + (fun res cd -> (async_reset cd) @ res) + res_l + classes + in + [("_main.c", Csource (defs @ [main_skel var_l res_l step_l])); ("_main.h", Cheader ([name], []))]; ) else