diff --git a/src/actionsDeps.ml b/src/actionsDeps.ml index e1b86186c1f455110cd0c089eb7e80fdb09a6a08..87db94f87801bd511b862cf6168aff07cfa2b670 100644 --- a/src/actionsDeps.ml +++ b/src/actionsDeps.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 11/04/2013 (at 17:31) by Erwan Jahier> *) +(** Time-stamp: <modified the 15/04/2013 (at 14:47) by Erwan Jahier> *) let dbg = (Verbose.get_flag "exec") @@ -228,7 +228,7 @@ let build_data_deps_from_actions: (Lic.type_ -> Data.t) -> t -> action list -> let (clk, rhs, _, _,_) = action in let dep_vars = match clk with | Lic.BaseLic -> rhs - | Lic.ClockVar int -> assert false + | Lic.ClockVar int -> rhs | Lic.On ((cc,cv,ct),_) -> (Soc.Var(cv, lic_to_data_type ct))::rhs in let deps = actions_of_vars dep_vars tbl in diff --git a/src/licDump.ml b/src/licDump.ml index c4f18ac8df0388c60f37dbbc39671d047f77a382..623a1a65ab7e27146997afdfe33ead57bcf6bb12 100644 --- a/src/licDump.ml +++ b/src/licDump.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 12/04/2013 (at 08:47) by Erwan Jahier> *) +(* Time-stamp: <modified the 17/04/2013 (at 11:10) by Erwan Jahier> *) open Lv6errors open Printf @@ -691,7 +691,7 @@ and string_of_clock (ck : Lic.clock) = (* | ClockVar i -> "_clock_var_" ^ (string_of_int i) *) and op2string op = - (* Une verrue pour compatible avec les outils qui mangent du ec... *) + (* Une verrue pour être compatible avec les outils qui mangent du ec... *) if global_opt.ec && op = AstPredef.INT2REAL_n then "real" else AstPredef.op2string op diff --git a/src/lv6MainArgs.ml b/src/lv6MainArgs.ml index cb028b4479cddfb79c85f54df9c38004ccd6afc9..49007e343034a00ab3d48fb0ad1b6631adc54e15 100644 --- a/src/lv6MainArgs.ml +++ b/src/lv6MainArgs.ml @@ -26,6 +26,7 @@ type t = { mutable dont_expand_nodes : string list; mutable expand_enums : bool; mutable expand_arrays : bool; + mutable gen_autotest : bool; mutable oc : Pervasives.out_channel; mutable tlex : bool; mutable exec : bool; @@ -71,6 +72,7 @@ let (make_opt : unit -> t) = dont_expand_nodes = []; expand_enums = false; expand_arrays = false; + gen_autotest = false; (** the output channel *) oc = Pervasives.stdout; tlex = false; @@ -306,6 +308,11 @@ let mkoptab (opt:t) : unit = ( (Arg.Unit (fun () -> global_opt.nonreg_test <- true)) ["Avoid printing full path error msgs to ease non-reg test decision"] ; + mkopt opt ~hide:true + ["--gen-autotest"] + (Arg.Unit (fun () -> opt.gen_autotest <- true)) + ["Generate a Lutin file and an oracle Lustre file suitable to compare the result of 2 Lustre compilers"] + ; (* misc debug flag *) mkopt opt ~hide:true ["-dbg"; "--debug"] diff --git a/src/lv6MainArgs.mli b/src/lv6MainArgs.mli index ba8eb9ad97fdcd6c956b3b88a9155b488ba58742..269207d6373049444b84ddfcc275a92c5ad8ab97 100644 --- a/src/lv6MainArgs.mli +++ b/src/lv6MainArgs.mli @@ -18,6 +18,7 @@ type t = { mutable dont_expand_nodes : string list; mutable expand_enums : bool; mutable expand_arrays : bool; + mutable gen_autotest : bool; mutable oc : Pervasives.out_channel; mutable tlex : bool; mutable exec : bool; diff --git a/src/main.ml b/src/main.ml index d12d356bb422a5f6a46ff95eaf8669ada32e6124..cb75a23967e70995b71641c8f71d4867cd40d8a4 100644 --- a/src/main.ml +++ b/src/main.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 12/04/2013 (at 08:47) by Erwan Jahier> *) +(* Time-stamp: <modified the 17/04/2013 (at 11:19) by Erwan Jahier> *) open Verbose open AstV6 @@ -20,6 +20,50 @@ let rec first_pack_in = | (AstV6.NSModel _)::tail -> first_pack_in tail | [] -> raise (Global_error "No package has been provided") +let (gen_lutin : LicPrg.t -> Ident.idref option -> unit) = + fun lic_prg main_node -> + (match main_node with + | None -> (print_string "No node is specified\n"; flush stdout) + | Some main_node -> + let msk, zesoc = Lic2soc.f lic_prg (Lic.node_key_of_idref main_node) in + let soc = try Soc.SocMap.find msk zesoc with Not_found -> assert false in + let invars,outvars=soc.Soc.profile in + let invars = SocExec.expand_profile invars in + let outvars = SocExec.expand_profile outvars in + let invars_str = List.map (fun (n,t) -> n^":"^(Data.type_to_string t)) invars in + let outvars_str = List.map (fun (n,t) -> n^":"^(Data.type_to_string t)) outvars in + let name = main_node.Ident.id_id in + let lutin_file_name = ("_"^name^"_env.lut") in + let oc = open_out lutin_file_name in + Lv6util.dump_entete oc; + output_string oc ("node " ^ (name) ^ "_env("^ (String.concat ";" outvars_str) ^ + ") returns(" ^ (String.concat ";" invars_str) ^ ") =\n loop true \n"); + flush oc; + close_out oc; + output_string stdout (lutin_file_name ^" generated.\n"); + + let oracle_file_name = ("_"^name^"_oracle.lus") in + let oc = open_out oracle_file_name in + let locals = List.map (fun (n,t) -> n^"_bis",t) outvars in + let prg = "node "^name^"_oracle("^(String.concat ";" (invars_str@outvars_str)) in + let prg = prg ^") returns(ok:bool);\n" in + let locals_str = List.map (fun (n,t) -> n^":"^(Data.type_to_string t)) locals in + let prg = prg ^ "var\n " ^ (String.concat ";\n " locals_str) ^ ";\nlet\n" in + let locals_name = List.map fst locals in + let invars_name = List.map fst invars in + let outvars_name = List.map fst outvars in + let prg = prg^" ("^(String.concat "," locals_name)^") = "^name in + let prg = prg^"("^(String.concat "," invars_name)^");\n" in + let prg = prg^" ok = ("^ (String.concat "," outvars_name) ^ "=" in + let prg = prg^ (String.concat "," locals_name) ^ ");\ntel;\n" in + Lv6util.dump_entete oc; + output_string oc prg; + flush oc; + close_out oc; + output_string stdout (oracle_file_name ^" generated.\n"); + flush stdout + ) + let main = ( (* Compile.init_appli () ; *) (* parse_args (); *) @@ -46,8 +90,9 @@ let main = ( (try ( let nsl = Compile.get_source_list opt opt.infiles in let lic_prg = Compile.doit opt nsl main_node in - - if opt.exec then + if opt.Lv6MainArgs.gen_autotest then + gen_lutin lic_prg main_node + else if opt.exec then (match main_node with | None -> ( let first_file = List.hd opt.infiles in @@ -76,7 +121,7 @@ let main = ( ); Verbose.exe ~level:3 (fun () -> Gc.print_stat stdout); - ) with + ) with Sys_error(s) -> prerr_string (s^"\n"); my_exit opt 1 @@ -94,7 +139,7 @@ let main = ( print_compile_error lxm msg; my_exit opt 1 | L2lCheckLoops.Error(lxm,msg,lic_prg) -> - (* Sometime it helps to see the current state of the faulty program *) + (* Sometime it helps to see the current state of the faulty program *) LicPrg.to_file opt lic_prg main_node; flush opt.oc; print_compile_error lxm msg; @@ -109,15 +154,15 @@ let main = ( "\n*** You migth want to sent a bug report to "^Lv6version.maintainer ^"\n") ; my_exit opt 2 ); -(* | Compile_node_error(nkey,lxm,msg) -> ( *) -(* print_compile_node_error nkey lxm msg ; *) -(* exit 1 *) -(* ) *) -(* | Global_node_error(nkey,msg) -> ( *) -(* print_global_node_error nkey msg ; *) -(* exit 1 *) -(* ) *) + (* | Compile_node_error(nkey,lxm,msg) -> ( *) + (* print_compile_node_error nkey lxm msg ; *) + (* exit 1 *) + (* ) *) + (* | Global_node_error(nkey,msg) -> ( *) + (* print_global_node_error nkey msg ; *) + (* exit 1 *) + (* ) *) - close_out opt.oc - + close_out opt.oc + ); diff --git a/src/socExec.ml b/src/socExec.ml index e59a30b7b2053f7c9be4b64d701bafa93b60d486..ac3cd35baa188def8402b8c660d97bfe5b5a83f5 100644 --- a/src/socExec.ml +++ b/src/socExec.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 12/04/2013 (at 16:05) by Erwan Jahier> *) +(* Time-stamp: <modified the 15/04/2013 (at 15:54) by Erwan Jahier> *) open Soc open Data @@ -316,11 +316,11 @@ let (f : Lv6MainArgs.t -> Soc.tbl -> Soc.key -> unit) = let exp_vntl_o_str = vntl_of_profile exp_vntl_o in let oc = if opt.Lv6MainArgs.outfile = "" then stdout else - let rif_file = - try (Filename.chop_extension opt.Lv6MainArgs.outfile) ^ ".rif" - with _ -> opt.Lv6MainArgs.outfile ^ ".rif" - in - open_out rif_file + let rif_file = + try (Filename.chop_extension opt.Lv6MainArgs.outfile) ^ ".rif" + with _ -> opt.Lv6MainArgs.outfile ^ ".rif" + in + open_out rif_file in Lv6util.dump_entete oc; Rif_base.write_interface oc exp_vntl_i_str exp_vntl_o_str None None; @@ -342,7 +342,9 @@ let rec (do_step : Soc.tbl -> Soc.t -> SocExecValue.ctx -> SocExecValue.ctx) = let rec (do_step_dbg : Soc.tbl -> Soc.t -> Event.ctx -> SocExecValue.ctx -> (SocExecValue.ctx -> Event.t) -> Event.t) = fun soc_tbl soc ectx ctx cont -> - let (datal:Data.subst list) = SocExecValue.substs_to_data_subst ctx.s in + (* XXX un peu exegéré de mettre tout ?*) +(* let (datal:Data.subst list) = SocExecValue.substs_to_data_subst ctx.s in *) + let (datal:Data.subst list) = SocExecValue.filter_top_subst ctx.s in let (soc_name,_,_) = soc.key in let ectx = { ectx with diff --git a/test/lus2lic.sum b/test/lus2lic.sum index bbda5b8569a13587bf6a1ef60f7205d9fc5ce52a..f4b7ae838c8272c2210a5532050e65d65e79aca9 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,4 +1,4 @@ -Test Run By jahier on Fri Apr 12 16:10:00 2013 +Test Run By jahier on Wed Apr 17 10:59:56 2013 Native configuration is i686-pc-linux-gnu === lus2lic tests === diff --git a/todo.org b/todo.org index 91b587d334a713600e3b259030ce34384579dc90..ebe836b51ba51daceb83d074e6085a86c34cf9ff 100644 --- a/todo.org +++ b/todo.org @@ -2,21 +2,6 @@ #+CATEGORY: lv6 * lus2lic -exec -** TODO revoir l'intégration à rif_base et genlex - - State "TODO" from "" [2013-03-19 Tue 10:25] -** TODO Unifier les modules Data de Lustre V6 et Lutin - - State "TODO" from "" [2013-04-02 Tue 08:33] - -ie. rajouter les tableaux, struct, et enum en lutin quitte à ne pas s'en servir -tout de suite. - -Ca va facilité l'utilisation sans duplic de code du module rif_base - -** TODO Integrer ce mode -exec dans lurette, à la facon dont je l'ai fait pour Lutin - - State "TODO" from "" [2013-03-30 Sat 14:35] -Question : comment j'integre ? via un lus2lic.a ? - -file:~/lurette/source/common/lustreRun.mli ** TODO Trouver un moyen d'automatiser des tests - State "TODO" from "" [2013-03-19 Tue 10:35] @@ -27,7 +12,13 @@ faudrait rajouter une option dans lurette qui, en cas de variables manquantes, genere le programme lutin qui va bien (loop true) plutot que de lancer luciole ---auto-stubs +Un truc de ce gout là semble fonctionner : + +./lus2lic trivial3.lus -n trivial3_condact --gen-autotest + ./lus2lic trivial3.lus -n trivial3_condact -ec >> _trivial3_condact_oracle.lus + ~/lurette/bin/lurettetop -rp "sut:v6:trivial3.lus:trivial3_condact" -rp "env:lutin:_trivial3_condact_env.lut" -rp "oracle:ec:trivial3_condact_oracle.ec:" + +Reste à l'integrer dans file:test/lus2lic.tests/non-reg.exp ** TODO Écrire un test qui mette en jeu exhaustivement tous les operateurs diff --git a/todo.org_archive b/todo.org_archive index 373bf31d2d91d632a9a1ce091bc8781a09e1dee1..6e7a708d957df790c928377740ebec1c6c54ed57 100644 --- a/todo.org_archive +++ b/todo.org_archive @@ -629,6 +629,45 @@ vs "-> pre" as it is done actually in file:~/lus2lic/src/ast2lic.ml::468 :ARCHIVE_CATEGORY: lv6 :ARCHIVE_TODO: TODO :END: +* TODO Unifier les modules Data de Lustre V6 et Lutin + - State "TODO" from "" [2013-04-02 Tue 08:33] + :PROPERTIES: + :ARCHIVE_TIME: 2013-04-17 Wed 10:52 + :ARCHIVE_FILE: ~/lus2lic/todo.org + :ARCHIVE_OLPATH: lus2lic -exec + :ARCHIVE_CATEGORY: lv6 + :ARCHIVE_TODO: TODO + :END: + +ie. rajouter les tableaux, struct, et enum en lutin quitte à ne pas s'en servir +tout de suite. + +Ca va facilité l'utilisation sans duplic de code du module rif_base +* TODO revoir l'intégration à rif_base et genlex + - State "TODO" from "" [2013-03-19 Tue 10:25] + :PROPERTIES: + :ARCHIVE_TIME: 2013-04-17 Wed 10:52 + :ARCHIVE_FILE: ~/lus2lic/todo.org + :ARCHIVE_OLPATH: lus2lic -exec + :ARCHIVE_CATEGORY: lv6 + :ARCHIVE_TODO: TODO + :END: + +* TODO Integrer ce mode -exec dans lurette, à la facon dont je l'ai fait pour Lutin + - State "TODO" from "" [2013-03-30 Sat 14:35] + :PROPERTIES: + :ARCHIVE_TIME: 2013-04-17 Wed 10:53 + :ARCHIVE_FILE: ~/lus2lic/todo.org + :ARCHIVE_OLPATH: lus2lic -exec + :ARCHIVE_CATEGORY: lv6 + :ARCHIVE_TODO: TODO + :END: +Question : comment j'integre ? via un lus2lic.a ? + +file:~/lurette/source/common/lustreRun.mli + + +