diff --git a/src/compile.ml b/src/compile.ml index 7a65272618ab55f1cbe50f89c0db974c632bb2e4..1e751ec542d83c2a486791e5b10887e2bd7c4624 100644 --- a/src/compile.ml +++ b/src/compile.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 16/01/2013 (at 17:06) by Erwan Jahier> *) +(* Time-stamp: <modified the 16/01/2013 (at 18:14) by Erwan Jahier> *) open Lxm @@ -47,7 +47,7 @@ let (doit : AstV6.pack_or_model list -> Ident.idref option -> LicPrg.t) = let zelic = if not !Global.inline_iterator then zelic else (* Array and struct expansion: to do after polymorphism elimination *) L2lExpandMetaOp.doit zelic - in + in let zelic = if !Global.one_op_per_equation diff --git a/src/licPrg.ml b/src/licPrg.ml index 65a707fd02bdf3524fb43d8ac21a7be75fd1595e..febb90770df7f29734241cb1d5a6000ff9524070 100644 --- a/src/licPrg.ml +++ b/src/licPrg.ml @@ -136,45 +136,52 @@ let dump_entete oc = Printf.fprintf oc "-- on %s the %s at %s\n" hostname date time_str -exception Enough -let to_file (oc: out_channel) (this:t) = +exception Print_me of Lic.node_exp +let to_file (oc: out_channel) (this:t) (main_node: Ident.idref option) = dump_entete oc; (* On imprime dans l'ordre du iter, donc pas terrible ??? *) if !Global.ec then ( (* If no node is set a top-level, the compiler will compile every node. But the ec format only accepts one node (and no type nor const) - Hence we print the first one. + Hence we print the first one (if no main node is set). *) - try - NodeKeyMap.iter ( - fun _ nexp -> - match nexp.Lic.node_key_eff, nexp.Lic.def_eff with - (* only user nodes with a body are valid ec node *) - | _, Lic.BodyLic _ -> - output_string !Global.oc (LicDump.node_of_node_exp_eff nexp); - flush !Global.oc; - raise Enough - | _ -> () - ) - this.nodes - with Enough -> () + try + NodeKeyMap.iter + (fun (key,_) nexp -> ( + match main_node with + | Some { Ident.id_pack = None ; Ident.id_id= name } -> + if Ident.of_long key = name then raise (Print_me nexp) + | Some idref -> + if Ident.long_of_idref idref = key then raise (Print_me nexp) + | None -> ( + match nexp.Lic.node_key_eff, nexp.Lic.def_eff with + (* only user nodes with a body are valid ec node *) + | _, Lic.BodyLic _ -> raise (Print_me nexp) + | _ -> () + ) + ) + ) + this.nodes + with Print_me nexp -> + output_string !Global.oc (LicDump.node_of_node_exp_eff nexp); + flush !Global.oc; ) else ( - (* Pour les noeuds, pas sur que ça marche tant qu'on n'a - pas séparés les transformations source_to_source du LicTab: - en cas d'expansion, il y avait cette remarque : - nb: we print res_struct, but do not return it from - node_check, because the structure and array expansion - modify (instanciate) the node profiles. - - On n'affiche PAS les extern Lustre::... - *) + (* Pour les noeuds, pas sur que ça marche tant qu'on n'a + pas séparés les transformations source_to_source du LicTab: + en cas d'expansion, il y avait cette remarque : + nb: we print res_struct, but do not return it from + node_check, because the structure and array expansion + modify (instanciate) the node profiles. + + On n'affiche PAS les extern Lustre::... + *) NodeKeyMap.iter ( fun _ nexp -> match nexp.Lic.node_key_eff with - (* inutile d'écrire les noeuds predefs *) + (* inutile d'écrire les noeuds predefs *) | (("Lustre",_),[]) -> () | _ -> output_string !Global.oc (LicDump.node_of_node_exp_eff nexp) ) diff --git a/src/licPrg.mli b/src/licPrg.mli index bab9a3f68f6968b8a7af0c158c4982a7af410e9e..f5bf92901aa3e400eb933acc3e1ab344da170510 100644 --- a/src/licPrg.mli +++ b/src/licPrg.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 20/12/2012 (at 15:41) by Erwan Jahier> *) +(* Time-stamp: <modified the 16/01/2013 (at 18:34) by Erwan Jahier> *) (** The data structure resulting from the compilation process *) @@ -43,7 +43,7 @@ val iter_consts : (Lic.item_key -> Lic.const -> unit) -> t -> unit val iter_types : (Lic.item_key -> Lic.type_ -> unit) -> t -> unit val iter_nodes : (Lic.node_key -> Lic.node_exp -> unit) -> t -> unit -val to_file : out_channel -> t -> unit +val to_file : out_channel -> t -> Ident.idref option -> unit val find_type : t -> Lic.item_key -> Lic.type_ option val find_const : t -> Lic.item_key -> Lic.const option diff --git a/src/main.ml b/src/main.ml index a7b88a80e5b82f36fd629323807cd17e1847d66e..3efea0ccc2abcf3bafb1fb5876b2bdcd4a4fb246 100644 --- a/src/main.ml +++ b/src/main.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 11/01/2013 (at 18:11) by Erwan Jahier> *) +(* Time-stamp: <modified the 16/01/2013 (at 18:18) by Erwan Jahier> *) @@ -168,7 +168,7 @@ let main = ( in if !Global.outfile <> "" then Global.oc := open_out !Global.outfile; let lic_prg = Compile.doit nsl main_node in - LicPrg.to_file !Global.oc lic_prg; + LicPrg.to_file !Global.oc lic_prg main_node; Verbose.exe ~level:3 (fun () -> Gc.print_stat stdout); close_out !Global.oc ) with diff --git a/test/lus2lic.sum b/test/lus2lic.sum index f31fd7767a85f2af32818d6983ba8023bf08cbd3..246afb49fce45cb70cea55238e5cb1faf08491ba 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,4 +1,4 @@ -Test Run By jahier on Wed Jan 16 18:06:46 2013 +Test Run By jahier on Wed Jan 16 18:35:13 2013 Native configuration is i686-pc-linux-gnu === lus2lic tests === diff --git a/test/lus2lic.time b/test/lus2lic.time index f1a7edf1a17595ce95f637788c12b998cff2c285..9c3c3314319e458e442937ff55342a88ebffa4a8 100644 --- a/test/lus2lic.time +++ b/test/lus2lic.time @@ -1,2 +1,2 @@ -testcase ./lus2lic.tests/non-reg.exp completed in 137 seconds -testcase ./lus2lic.tests/progression.exp completed in 13 seconds +testcase ./lus2lic.tests/non-reg.exp completed in 160 seconds +testcase ./lus2lic.tests/progression.exp completed in 12 seconds