Skip to content
Snippets Groups Projects
Commit a86f3a60 authored by Erwan Jahier's avatar Erwan Jahier
Browse files

Fix a bug in soc2c: the typedef of the main soc was printed twice if it is memoryless.

parent 3bca6801
No related branches found
No related tags found
No related merge requests found
(* 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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment