diff --git a/src/astV6Dump.ml b/src/astV6Dump.ml index 7e2a0712832e31e4d36308898c3f3648d8e19f6a..3bc44e8057f590fd1a24495480fad8dd6cff7a18 100644 --- a/src/astV6Dump.ml +++ b/src/astV6Dump.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 04/04/2013 (at 15:11) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 17:25) by Erwan Jahier> *) open Lxm diff --git a/src/ident.ml b/src/ident.ml index 589461409a9dfd805fb298469b96365379f98e86..a9f3b01eb5005d926f5d58bac647a68117a83256 100644 --- a/src/ident.ml +++ b/src/ident.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 24/04/2013 (at 10:43) by Erwan Jahier> *) +(* Time-stamp: <modified the 25/04/2013 (at 09:23) by Erwan Jahier> *) (* J'ai appele ca symbol (mais ca remplace le ident) : c'est juste une couche qui garantit l'unicite en memoire @@ -63,17 +63,17 @@ let (pack_name_of_string : string -> pack_name) = let (pack_name_to_string : pack_name -> string) = fun x -> x - - - let (string_of_long : long -> string) = - fun (pn, id) -> - let sep = - if Lv6MainArgs.global_opt.Lv6MainArgs.ec || Lv6MainArgs.global_opt.Lv6MainArgs.lv4 then "__" else "::" - in - match pn with - | "" -> id - | _ -> Printf.sprintf "%s%s%s" pn sep id + fun (pn, id) -> + let sep = + if Lv6MainArgs.global_opt.Lv6MainArgs.ec || Lv6MainArgs.global_opt.Lv6MainArgs.lv4 + then "__" else "::" + in + match pn with + | "" -> id + | _ -> +(* if Lv6MainArgs.global_opt.Lv6MainArgs.no_prefix then id else *) + Printf.sprintf "%s%s%s" pn sep id let (string_of_long2 : long -> string) = function @@ -135,12 +135,17 @@ let (long_of_string : string -> long) = let string_of_idref i = ( match i.id_pack with Some p -> + if Lv6MainArgs.global_opt.Lv6MainArgs.no_prefix then i.id_id else if Lv6MainArgs.global_opt.Lv6MainArgs.ec then p^"__"^i.id_id else if Lv6MainArgs.global_opt.Lv6MainArgs.lv4 then (p^"__"^i.id_id) else - if Lv6MainArgs.global_opt.Lv6MainArgs.no_prefix then i.id_id else (p^"::"^i.id_id) | None -> i.id_id ) +let string_of_idref_bis i = ( + match i.id_pack with + Some p -> (p^"::"^i.id_id) + | None -> i.id_id +) let raw_string_of_idref i = ( let p = match i.id_pack with | Some p -> "Some \""^p^"\"" diff --git a/src/ident.mli b/src/ident.mli index d838a6cd180a5751bc67b944a09ee9ae91c8058f..d1f079e7d58b225798ced61cb88b966295b04006 100644 --- a/src/ident.mli +++ b/src/ident.mli @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 03/04/2013 (at 14:04) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 17:24) by Erwan Jahier> *) (** *) @@ -51,6 +51,7 @@ val make_idref : pack_name -> t -> idref val string_of_idref : idref -> string +val string_of_idref_bis : idref -> string val raw_string_of_idref : idref -> string val of_idref : idref -> t val to_idref : t -> idref diff --git a/src/l2lExpandNodes.ml b/src/l2lExpandNodes.ml index a44ee16f530d6eedc9b4c518c3c7964ba20295b3..dccfcb710559c6bbc96d18a46ba54574f76a2e9a 100644 --- a/src/l2lExpandNodes.ml +++ b/src/l2lExpandNodes.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 23/04/2013 (at 16:35) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 17:42) by Erwan Jahier> *) open Lxm @@ -222,10 +222,10 @@ and (expand_eq_aux: local_ctx -> Lic.eq_info -> acc option)= | Some n -> n | None -> prerr_string ( - "*** "^ (LicDump.string_of_node_key_rec node_key.it) ^" not defined.\n" ^ + "*** "^ (LicDump.string_of_node_key_rec false node_key.it) ^" not defined.\n" ^ "*** Defined nodes are:"^ (String.concat ",\n" - (List.map (fun (nk,_) -> "\""^LicDump.string_of_node_key_rec nk^"\"") + (List.map (fun (nk,_) -> "\""^LicDump.string_of_node_key_rec false nk^"\"") (LicPrg.list_nodes lctx.prg))) ); flush stderr; diff --git a/src/lic2soc.ml b/src/lic2soc.ml index 8e384dd819337195e3ae4a4fd713e37e02d84e7c..927b80624ff73b497550963af9a318a1035758e5 100644 --- a/src/lic2soc.ml +++ b/src/lic2soc.ml @@ -1,4 +1,4 @@ -(** Time-stamp: <modified the 11/04/2013 (at 17:31) by Erwan Jahier> *) +(** Time-stamp: <modified the 24/04/2013 (at 17:43) by Erwan Jahier> *) open Lxm open Lic @@ -261,7 +261,7 @@ let soc_profile_of_node: Lic.node_exp -> Soc.var list * Soc.var list = let (make_soc_key_of_node_exp : Lic.node_key -> Data.t list -> Soc.key) = fun nk vl -> - LicDump.string_of_node_key_rec nk, vl, None + LicDump.string_of_node_key_rec false nk, vl, None let (soc_key_of_node_exp : Lic.node_exp -> Soc.key) = fun n -> @@ -424,8 +424,8 @@ let by_pos_op_to_soc_ident = function | CONCAT-> "Lustre::concat" | ARRAY -> "Lustre::array" | HAT _ -> "Lustre::hat" - | PREDEF_CALL n - | CALL n -> LicDump.string_of_node_key_rec n.it + | PREDEF_CALL n + | CALL n -> LicDump.string_of_node_key_rec false n.it | _ -> assert false @@ -632,10 +632,10 @@ let rec f: (LicPrg.t -> Lic.node_key -> Soc.key * Soc.tbl) = match LicPrg.find_node prog nk with | None -> prerr_string ( - "*** "^ (LicDump.string_of_node_key_rec nk) ^" not defined.\n" ^ + "*** "^ (LicDump.string_of_node_key_rec false nk) ^" not defined.\n" ^ "*** Defined nodes are:"^ (String.concat ",\n" - (List.map (fun (nk,_) -> "\""^LicDump.string_of_node_key_rec nk^"\"") + (List.map (fun (nk,_) -> "\""^LicDump.string_of_node_key_rec false nk^"\"") (LicPrg.list_nodes prog))) ); assert false diff --git a/src/licDump.ml b/src/licDump.ml index e76cd750cb9afe28e21c77981233f677a30535c1..09e83b8d29555d7834839efb4bc987b72db6bfbf 100644 --- a/src/licDump.ml +++ b/src/licDump.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 17/04/2013 (at 11:23) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 17:41) by Erwan Jahier> *) open Lv6errors open Printf @@ -230,9 +230,12 @@ and string_of_type_matches pm = String.concat ", " (List.map sotm pm) (* for printing recursive node *) -and string_of_node_key_rec (nkey: node_key) = +and string_of_node_key_rec (no_prefix:bool) (nkey: node_key) = match nkey with - | (ik, []) -> dump_long ik + | (ik, []) -> + if no_prefix + then Ident.no_pack_string_of_long ik + else Ident.string_of_long ik | (ik, salst) -> let astrings = List.map static_arg2string_bis salst in let name = sprintf "%s_%s" (Ident.no_pack_string_of_long ik) (String.concat "_" astrings) in @@ -279,7 +282,7 @@ and static_arg2string_rec (sa : Lic.static_arg) = | TypeStaticArgLic (id, teff) -> sprintf "%s" (string_of_type_eff teff) (* | NodeStaticArgLic (id, ((long,sargs), _, _), _) -> *) | NodeStaticArgLic (id, (long,sargs)) -> - string_of_node_key_rec (long,sargs) + string_of_node_key_rec global_opt.no_prefix (long,sargs) (* sprintf "%s" (dump_long long) *) @@ -386,7 +389,7 @@ and (string_of_by_pos_op_eff: Lic.by_pos_op srcflagged -> Lic.val_exp list -> st if global_opt.lv4 then ((string_of_node_key nk) ^ (tuple_par vel)) else - ((string_of_node_key_rec nk) ^ (tuple_par vel)) + ((string_of_node_key_rec global_opt.no_prefix nk) ^ (tuple_par vel)) ) | CONST_REF idl, _ -> dump_long idl | VAR_REF id, _ -> id @@ -613,7 +616,7 @@ and node_of_node_exp_eff if neff.has_mem_eff then "node " else "function " ) )^( - string_of_node_key_rec neff.node_key_eff + string_of_node_key_rec global_opt.no_prefix neff.node_key_eff )^( profile_of_node_exp_eff neff ) @@ -639,7 +642,7 @@ and node_of_node_exp_eff "let\n " ^ (String.concat "\n " (string_of_node_def neff.def_eff)) ^ "\ntel\n-- end of node " ^ - (string_of_node_key_rec neff.node_key_eff) ^ "\n" + (string_of_node_key_rec global_opt.no_prefix neff.node_key_eff) ^ "\n" ) ) diff --git a/src/licDump.mli b/src/licDump.mli index 4c21b285a689af2f0746008058ad557b5da595b1..2eaf7291828bd3bab6f7a9c6f17ab21db77f4e79 100644 --- a/src/licDump.mli +++ b/src/licDump.mli @@ -1,7 +1,7 @@ -(* Time-stamp: <modified the 12/12/2012 (at 18:15) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 17:41) by Erwan Jahier> *) -val string_of_node_key_rec : Lic.node_key -> string +val string_of_node_key_rec : bool -> Lic.node_key -> string val string_of_node_key_iter : Lic.node_key -> string val node_of_node_exp_eff: Lic.node_exp -> string diff --git a/src/licPrg.ml b/src/licPrg.ml index 8cf885a518dc437b63d6e3036d1931766b5d994b..7409d6ee5e3290a9262ec8554c027d6071ad2441 100644 --- a/src/licPrg.ml +++ b/src/licPrg.ml @@ -111,7 +111,7 @@ let add_const (k:Lic.item_key) (v:Lic.const) (prg:t) : t = let add_node (k:Lic.node_key) (v:Lic.node_exp) (prg:t) : t = Verbose.exe ~level:3 (fun () -> - Printf.printf "## LicPrg.add_node %s\n" (LicDump.string_of_node_key_rec k)); + Printf.printf "## LicPrg.add_node %s\n" (LicDump.string_of_node_key_rec false k)); { prg with nodes = NodeKeyMap.add k v prg.nodes } exception Print_me of Lic.node_exp diff --git a/src/licTab.ml b/src/licTab.ml index 72602a704afd1d6d147aa8155394377fecf76748..d85298febe1605f19b6e7c58d6e3a15890a8eed2 100644 --- a/src/licTab.ml +++ b/src/licTab.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 11/04/2013 (at 17:31) by Erwan Jahier> *) +(* Time-stamp: <modified the 24/04/2013 (at 17:43) by Erwan Jahier> *) open Lxm @@ -1305,7 +1305,7 @@ let compile_all_nodes pack_name this id ni_f = if sp <> [] then () (* we need static arg to compile such kind of things *) else compile_all_item this "node" node_check_interface - (LicDump.string_of_node_key_rec) + (LicDump.string_of_node_key_rec false ) Lic.profile_of_node_exp (fun id -> (Ident.make_long pack_name id, [])) id ni_f @@ -1375,7 +1375,7 @@ let compile_node (this:t) (main_node:Ident.idref) : t = let main_node_key = node_key_of_idref main_node in Verbose.printf "-- MAIN NODE: \"%s\"\n" - (LicDump.string_of_node_key_rec main_node_key); + (LicDump.string_of_node_key_rec false main_node_key); let lxm = match Ident.pack_of_idref main_node with | None -> Lxm.dummy "" diff --git a/src/main.ml b/src/main.ml index 4889b1ccf2830a8e12371fed26aab575750ac927..9fb8f91588e9be171a330c46e3ea59ace8df5a73 100644 --- a/src/main.ml +++ b/src/main.ml @@ -1,4 +1,4 @@ -(* Time-stamp: <modified the 24/04/2013 (at 12:02) by Erwan Jahier> *) +(* Time-stamp: <modified the 25/04/2013 (at 09:43) by Erwan Jahier> *) open Verbose open AstV6 @@ -55,12 +55,18 @@ let (gen_autotest_files : LicPrg.t -> Ident.idref option -> Lv6MainArgs.t -> uni let msk, zesoc = Lic2soc.f lic_prg (Lic.node_key_of_idref main_node) in msk, zesoc, main_node in + let my_type_to_string t = + (* Remove the module name to have correct Lutin and lv4 type decl *) + let str = Data.type_to_string t in + let idref = Ident.idref_of_string str in + idref.Ident.id_id + 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 invars_str = List.map (fun (n,t) -> n^":"^(my_type_to_string t)) invars in + let outvars_str = List.map (fun (n,t) -> n^":"^(my_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 @@ -70,15 +76,14 @@ let (gen_autotest_files : LicPrg.t -> Ident.idref option -> Lv6MainArgs.t -> uni 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 invars,outvars=soc.Soc.profile in let locals = List.map (fun (n,t) -> n^"_bis",t) 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 invars_str = List.map (fun (n,t) -> n^":"^(my_type_to_string t)) invars in + let outvars_str = List.map (fun (n,t) -> n^":"^(my_type_to_string t)) outvars in let prg = "node "^name^"_oracle("^(String.concat ";" (invars_str@outvars_str)) in - let locals_str = List.map (fun (n,t) -> n^":"^(Data.type_to_string t)) locals in + let locals_str = List.map (fun (n,t) -> n^":"^(my_type_to_string t)) locals in let ok = (* avoid name clash*) let all_vars = List.map fst (List.rev_append (List.rev_append locals invars) outvars) in let rec gen_ok str = if List.mem str all_vars then gen_ok ("_"^str) else str in diff --git a/src/rif_base.ml b/src/rif_base.ml index 0e91f96d85db28b424942d106ea8cd5bd863156c..ec38f7ca660d7819a6c82b7e1a9797ce22ecbb5f 100644 --- a/src/rif_base.ml +++ b/src/rif_base.ml @@ -265,12 +265,12 @@ let (flush : out_channel -> unit) = (*------------------------------------------------------------------------*) (* exported *) -let (write_interface : out_channel -> vntl -> vntl -> vntl option -> vntl option -> unit) = +let (write_interface : out_channel -> vntl -> vntl -> vntl option -> vntl list option -> unit) = fun oc in_vars out_vars loc_vars_opt oracle_vars_opt -> let str = (List.fold_left (fun acc (vn,vt) -> - acc ^ "\"" ^ vn ^ "\":" ^ vt ^ " ") + acc ^ "\"" ^ vn ^ "\":" ^ vt ^ " ") "#inputs " in_vars) ^ @@ -278,33 +278,39 @@ let (write_interface : out_channel -> vntl -> vntl -> vntl option -> vntl option (List.fold_left (fun acc (vn,vt) -> - acc ^ "\"" ^ vn ^ "\":" ^ vt ^ " ") + acc ^ "\"" ^ vn ^ "\":" ^ vt ^ " ") "" out_vars) ^ (match loc_vars_opt with - | None -> "\n" - | Some loc_vars -> - ((List.fold_left - (fun acc (vn,vt) -> - acc^"\"" ^ vn ^ "\":" ^ vt ^ " ") - "\n#locals " - loc_vars - ) ^ "\n") + | None -> "\n" + | Some loc_vars -> + ((List.fold_left + (fun acc (vn,vt) -> + acc^"\"" ^ vn ^ "\":" ^ vt ^ " ") + "\n#locals " + loc_vars + ) ^ "\n") ) ^ (match oracle_vars_opt with - | None -> "" - | Some vars -> - ((List.fold_left - (fun acc (vn,vt) -> - acc^"\"" ^ vn ^ "\":" ^ vt ^ " ") - "#oracle_outputs " - vars - ) ^ "\n") + | None -> "" + | Some vars_l -> + (List.fold_left + (fun acc vars -> + ((List.fold_left + (fun acc (vn,vt) -> + acc^"\"" ^ vn ^ "\":" ^ vt ^ " ") + "#oracle_outputs " + vars + ) ^ "\n" ^ acc) + ) + "" + vars_l + ) ) in - write oc str + write oc str (*------------------------------------------------------------------------*) (* exported *) diff --git a/src/rif_base.mli b/src/rif_base.mli index e5be403d781f6b78d03eb0532b526652fdc1c57a..4afc24606c30c34e0d6d466f51e3f585540292cc 100644 --- a/src/rif_base.mli +++ b/src/rif_base.mli @@ -37,6 +37,6 @@ val write_outputs : out_channel -> (float -> string) -> Data.vntl -> Data.subst (** [write_interface oc in_vars_ out_vars loc_vars oracle_vars] writes the input and output var names and types *) val write_interface : out_channel -> Data.vntl -> Data.vntl -> Data.vntl option -> - Data.vntl option -> unit + Data.vntl list option -> unit val flush : out_channel -> unit diff --git a/test/lus2lic.sum b/test/lus2lic.sum index 45b8d56b20fd302fceb13d795b497717f4f3916e..87463a1812c1f28f49bdf10652820f0c76be915f 100644 --- a/test/lus2lic.sum +++ b/test/lus2lic.sum @@ -1,4 +1,4 @@ -Test Run By jahier on Wed Apr 24 15:04:13 2013 +Test Run By jahier on Thu Apr 25 09:37:22 2013 Native configuration is i686-pc-linux-gnu === lus2lic tests === @@ -56,7 +56,7 @@ PASS: ../utils/test_lus2lic_no_node should_work/dep.lus PASS: ./lus2lic {-o /tmp/ELMU.lic should_work/ELMU.lus} PASS: ./lus2lic {-ec -o /tmp/ELMU.ec should_work/ELMU.lus} PASS: ./ec2c {-o /tmp/ELMU.c /tmp/ELMU.ec} -FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/ELMU.lus +PASS: ../utils/test_lus2lic_no_node should_work/ELMU.lus PASS: ./lus2lic {-o /tmp/testPilote.lic should_work/testPilote.lus} PASS: ./lus2lic {-ec -o /tmp/testPilote.ec should_work/testPilote.lus} PASS: ./ec2c {-o /tmp/testPilote.c /tmp/testPilote.ec} @@ -800,7 +800,7 @@ FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node shou PASS: ./lus2lic {-o /tmp/hanane.lic should_work/hanane.lus} PASS: ./lus2lic {-ec -o /tmp/hanane.ec should_work/hanane.lus} PASS: ./ec2c {-o /tmp/hanane.c /tmp/hanane.ec} -PASS: ../utils/test_lus2lic_no_node should_work/hanane.lus +FAIL: Try to compare lus2lic -exec and ecexe: ../utils/test_lus2lic_no_node should_work/hanane.lus PASS: ./lus2lic {-o /tmp/lustre.lic should_work/lustre.lus} PASS: ./lus2lic {-ec -o /tmp/lustre.ec should_work/lustre.lus} PASS: ./ec2c {-o /tmp/lustre.c /tmp/lustre.ec} diff --git a/test/lus2lic.time b/test/lus2lic.time index d11b71f3315fbd851f90bc5f0be1c49aaae577ac..5e92f98dc2155ea7e35536c4ba97983142f03e79 100644 --- a/test/lus2lic.time +++ b/test/lus2lic.time @@ -1,2 +1,2 @@ -testcase ./lus2lic.tests/non-reg.exp completed in 62 seconds +testcase ./lus2lic.tests/non-reg.exp completed in 47 seconds testcase ./lus2lic.tests/progression.exp completed in 0 seconds diff --git a/test/should_work/ELMU.lus b/test/should_work/ELMU.lus index 2fef5f9c8941b84ae4829ab42e30813b7786665e..39159460ee029991ebf34ad4286500001c0ff2b8 100644 --- a/test/should_work/ELMU.lus +++ b/test/should_work/ELMU.lus @@ -407,7 +407,7 @@ tel ------------------------------------------------------- -- Noeud principal ------------------------------------------------------- -node testSilus(EntreeGlob : T_EntreeGlob) --Contient (au moins) les valeurs des charges et des generateurs du systeme +node ELMU(EntreeGlob : T_EntreeGlob) --Contient (au moins) les valeurs des charges et des generateurs du systeme -- OK OK OK returns (TabComChg : T_ComChg^NBC); var diff --git a/utils/test_lus2lic_no_node b/utils/test_lus2lic_no_node index 9f54ddde86cb1da164e722203f30d3060bc770ea..70a8e9409290e0f6ad55a74b2e0fdccd812dba11 100755 --- a/utils/test_lus2lic_no_node +++ b/utils/test_lus2lic_no_node @@ -9,12 +9,15 @@ env=_"$node"_env.lut set -x verbose #echo on -./lus2lic $lustre_file -n $node --gen-autotest || exit 2 +./lus2lic $lustre_file -n $node --gen-autotest -np || exit 2 cat $lustre_file >> $_oracle #./lus2lic $lustre_file -n $node -lv4 -en --no-prefix >> $_oracle || exit 2 ./lus2lic $_oracle -n $oracle -ec -o $oracle.ec || exit 2 +#./lus2ec $_oracle $oracle -o $oracle.ec || exit 2 + + ./lurettetop -rp "sut:v6:$lustre_file:$node" -rp "env:lutin:$env" -rp "oracle:ec:$oracle.ec:$oracle" -go -l 10 -ns2c --stop-on-oracle-error || exit 2 return 0