diff --git a/src/soc2c.ml b/src/soc2c.ml index e9651e37df7aaa4d593b7b6f1354a094d453aa88..197fdad9d04c76256c9153edcb02365e061e56ae 100644 --- a/src/soc2c.ml +++ b/src/soc2c.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 04/06/2014 (at 17:37) by Erwan Jahier> *) +(* Time-stamp: <modified the 04/06/2014 (at 18:07) by Erwan Jahier> *) (* let put (os: out_channel) (fmt:('a, unit, string, unit) format4) : 'a = *) @@ -271,27 +271,29 @@ let (typedef_of_soc : Soc.t -> string) = let str = Printf.sprintf "%s} %s;\n\n" str ctx_name_type in str -let (typedef : LicPrg.t -> Soc.tbl -> Soc.t -> string) = - fun licprg soc_tbl main_soc -> +let (typedef : LicPrg.t -> Soc.tbl -> Soc.t -> string) = + fun licprg soc_tbl main_soc -> (* We need to print the ctx typedef a good order (w.r.t. typedef dependancies). To do that, we traverse the tree of soc instances which root is the main soc. *) let rec (soc_with_mem : string -> Soc.t -> string) = - fun acc soc -> + fun acc soc -> let acc = (typedef_of_soc soc) ^ acc in List.fold_left - (fun acc (iname, sk) -> + (fun acc (iname, sk) -> let soc = SocUtils.find_no_exc sk soc_tbl in - soc_with_mem acc soc - ) + soc_with_mem acc soc + ) acc soc.instances in - let soc_ctx_typedef_with = soc_with_mem "" main_soc in + let soc_ctx_typedef_with = + if is_memory_less main_soc then "" else soc_with_mem "" main_soc + in (* Then we still have to print memoryless soc that can not appear as a soc instance *) - let soc_ctx_typedef_without = + let soc_ctx_typedef_without = let socs = Soc.SocMap.bindings soc_tbl in - let socs = snd (List.split socs) in + let socs = snd (List.split socs) in let memless_soc_to_string acc soc = if is_memory_less soc then acc^(typedef_of_soc soc) else acc in @@ -492,7 +494,7 @@ int main(){ (String.concat " " outputs_fmt)^ "\\n\"," ^ (String.concat "," (List.map (fun (id,_) -> "ctx->"^id ) (inputs@outputs)))^ "); - first_step=_false; + first_step=_false; } return 1;