diff --git a/release-lv6/Makefile b/release-lv6/Makefile index 787490958c4e963ce0f5e59b4326d5b3fe18979e..c67b1988c49eb4c4959440554ebb4a2062468b40 100644 --- a/release-lv6/Makefile +++ b/release-lv6/Makefile @@ -14,7 +14,7 @@ RELNAME=$(RELNAME_PREFIX)$(shell date +%d-%m-%y)-$(shell uname) all: dir doc lus2lic lic2c test_files dir: - rm -rf $(RELNAME) && mkdir $(RELNAME) + (rm -rf $(RELNAME) && mkdir $(RELNAME)) || mkdir $(RELNAME) cp -rf rel-skel/* $(RELNAME)/ doc: diff --git a/src/TODO b/src/TODO index 9a699e1d0a355f36b573edc76e0eacfd1efdb32f..6914773d639dc9a7795c303d4bb9869ab9f4c4a5 100644 --- a/src/TODO +++ b/src/TODO @@ -148,6 +148,19 @@ n'est pas le cas pour l'instant... cf [solve_ident] * --help devrait retourner la liste des operateurs predefinis, avec leur type +* mettre un meilleur message d'erreur : +node mapinf2 (t1, t2: int^10) returns (res : bool^10); +let + res = map<< =>, true>>(t1, t2); + ^^^^ +tel +style : un entier est attendu (plutot qu'un ' internal error (lus2lic) occurred in file predefEvalType.ml, line 84, column 15') + +* En lic, dois-je generer lustre::ilt ou bien Lustre::lt ? +Générer lustre::ilt n'est pas tres compliqué, mais ca m'obliqe +à rajouter un LTI_n, LTR_n, etc., ce qui est un peu pénible +et probablement géré à terme au niveau du lic. + *** facile ---------- diff --git a/src/eff.ml b/src/eff.ml index a7f8d534651f7260003e7dafb5e568efeb28618b..592063f1f015190ad224d3157ad8422c7b5efd10 100644 --- a/src/eff.ml +++ b/src/eff.ml @@ -375,7 +375,8 @@ let (lookup_type: local_env -> Ident.idref -> Lxm.t -> type_) = let (lookup_node: local_env -> Ident.idref -> static_arg list -> Lxm.t -> sarg_node_eff) = - fun env id sargs lmx -> Hashtbl.find env.lenv_nodes (Ident.name_of_idref id) + fun env id sargs lmx -> + Hashtbl.find env.lenv_nodes (Ident.name_of_idref id) let (lookup_const: local_env -> Ident.idref -> Lxm.t -> const) = fun env id lmx -> diff --git a/src/getEff.ml b/src/getEff.ml index 5f5235f0a90a672554deea3c86013678530afcee..158d0a5ae28d28a5b66b9390a2b0e3da75ddd879 100644 --- a/src/getEff.ml +++ b/src/getEff.ml @@ -598,22 +598,22 @@ and (instanciate_type: Eff.type_ -> Eff.static_arg -> Eff.static_arg) = int and real? *) - | { id_pack = Some "Lustre" ; id_id = "lt" } -> - let op = if t = Int_type_eff then "ilt" - else if t = Real_type_eff then "rlt" else "lt" in - make_long "Lustre" op - | { id_pack = Some "Lustre" ; id_id = "gt" } -> - let op = if t = Int_type_eff then "igt" - else if t = Real_type_eff then "rgt" else "gt" in - make_long "Lustre" op - | { id_pack = Some "Lustre" ; id_id = "lte" } -> - let op = if t = Int_type_eff then "ilte" - else if t = Real_type_eff then "rlte" else "lte" in - make_long "Lustre" op - | { id_pack = Some "Lustre" ; id_id = "gte" } -> - let op = if t = Int_type_eff then "igte" - else if t = Real_type_eff then "rgte" else "gte" in - make_long "Lustre" op +(* | { id_pack = Some "Lustre" ; id_id = "lt" } -> *) +(* let op = if t = Int_type_eff then "ilt" *) +(* else if t = Real_type_eff then "rlt" else "lt" in *) +(* make_long "Lustre" op *) +(* | { id_pack = Some "Lustre" ; id_id = "gt" } -> *) +(* let op = if t = Int_type_eff then "igt" *) +(* else if t = Real_type_eff then "rgt" else "gt" in *) +(* make_long "Lustre" op *) +(* | { id_pack = Some "Lustre" ; id_id = "lte" } -> *) +(* let op = if t = Int_type_eff then "ilte" *) +(* else if t = Real_type_eff then "rlte" else "lte" in *) +(* make_long "Lustre" op *) +(* | { id_pack = Some "Lustre" ; id_id = "gte" } -> *) +(* let op = if t = Int_type_eff then "igte" *) +(* else if t = Real_type_eff then "rgte" else "gte" in *) +(* make_long "Lustre" op *) | { id_pack = Some "Lustre" ; id_id = "equal" } -> let op = if t = Int_type_eff then "iequal" diff --git a/src/lazyCompiler.ml b/src/lazyCompiler.ml index 080f5e0b6f10131e873ce779205073b353d8e67e..8e0b7236c6cc1e420661a8ad9ef4dd54bdb30537 100644 --- a/src/lazyCompiler.ml +++ b/src/lazyCompiler.ml @@ -46,27 +46,27 @@ type t = { (* exported *) let (create : SyntaxTab.t -> t) = -fun tbl -> - let nodes_tbl = Hashtbl.create 0 in - let prov_nodes_tbl = Hashtbl.create 0 in - List.iter - (fun op -> - let op_str = Predef.op2string op in - let op_eff = PredefEvalType.make_node_exp_eff None op (Lxm.dummy op_str) [] in - let op_key = Predef.op_to_long op, [] in - Hashtbl.add nodes_tbl op_key (Eff.Checked op_eff); - Hashtbl.add prov_nodes_tbl op_key (Eff.Checked op_eff) - ) - Predef.iterable_op; - { - src_tab = tbl; - types = Hashtbl.create 0; - consts = Hashtbl.create 0; - nodes = nodes_tbl; - prov_types = Hashtbl.create 0; - prov_consts = Hashtbl.create 0; - prov_nodes = prov_nodes_tbl; - } + fun tbl -> + let nodes_tbl = Hashtbl.create 0 in + let prov_nodes_tbl = Hashtbl.create 0 in + List.iter + (fun op -> + let op_str = Predef.op2string op in + let op_eff = PredefEvalType.make_node_exp_eff None op (Lxm.dummy op_str) [] in + let op_key = Predef.op_to_long op, [] in + Hashtbl.add nodes_tbl op_key (Eff.Checked op_eff); + Hashtbl.add prov_nodes_tbl op_key (Eff.Checked op_eff) + ) + Predef.iterable_op; + { + src_tab = tbl; + types = Hashtbl.create 0; + consts = Hashtbl.create 0; + nodes = nodes_tbl; + prov_types = Hashtbl.create 0; + prov_consts = Hashtbl.create 0; + prov_nodes = prov_nodes_tbl; + } (******************************************************************************) @@ -182,7 +182,7 @@ let x_check_interface match xp_prov_symbols_opt with | None -> (* if [xp] have no provided symbol table, the whole package is exported. *) - x_check this x_key lxm + x_check this x_key lxm | Some xp_prov_symbols -> let x_def = match find_x xp_prov_symbols xn lxm with | SymbolTab.Local x -> x @@ -213,7 +213,20 @@ let (lookup_const_eff:(Eff.item_key, Eff.const Eff.check_flag) Hashtbl.t -> let (lookup_node_exp_eff: (Eff.node_key, Eff.node_exp Eff.check_flag) Hashtbl.t -> Eff.node_key -> Lxm.t -> Eff.node_exp) = - lookup_x_eff "node ref " (fun k -> fst k) + fun tbl key lxm -> + try lookup_x_eff "node ref " (fun k -> fst k) tbl key lxm + with + Not_found -> + if fst (fst key) = "Lustre" then ( + let msg = "*** " ^ (snd (fst key)) ^ ": unknown Lustre operator. "^ + "Available operators are:\n" ^ + (Hashtbl.fold (fun (long,_) _ acc -> acc ^ ("\t - "^ (Ident.string_of_long long ) ^ "\n")) tbl "") + in + raise (Compile_error(lxm, msg)) + ) + else + raise Not_found +(* lookup_x_eff "node ref " (fun k -> fst k) *) (** This function performs the identifier (idref) resolution, @@ -592,8 +605,9 @@ and (node_check_do: t -> Eff.node_key -> Lxm.t -> SymbolTab.t -> (fun id sargs lxm -> (try let node_id, inlist, outlist = lookup_node local_env id sargs lxm in - node_check this (node_id,[]) lxm - (* XXX *) + let node_id = Ident.idref_of_long node_id in + solve_node_idref this symbols provide_flag pack_name node_id [] lxm +(* node_check this (node_id,[]) lxm *) with Not_found -> @@ -836,7 +850,7 @@ and (node_check_do: t -> Eff.node_key -> Lxm.t -> SymbolTab.t -> in let res = if !Global.one_op_per_equation then Split.node local_env res else res in let res = - if !Global.inline_iterator + if !Global.inline_iterator then Inline.iterators local_env node_id_solver res else res in diff --git a/src/licDump.ml b/src/licDump.ml index ab7417bc79c1232e52590e16eaf359973247f368..4e0b506cbccf486bdce9286c51b3a1fc51f5277a 100644 --- a/src/licDump.ml +++ b/src/licDump.ml @@ -3,6 +3,7 @@ open Printf open Lxm open Eff +open List let (long : Ident.long -> string) = Ident.string_of_long (* fun id -> *) @@ -264,7 +265,7 @@ and (string_of_leff_list : Eff.left list -> string) = (String.concat ", " (List.map string_of_leff l)) ^ (if List.length l = 1 then "" else ")") - +and sov ve = string_of_val_exp_eff ve and (string_of_by_pos_op_eff: Eff.by_pos_op srcflagged -> Eff.val_exp list -> string) = fun posop vel -> let tuple vel = (String.concat ", " (List.map string_of_val_exp_eff vel)) in @@ -305,7 +306,43 @@ and (string_of_by_pos_op_eff: Eff.by_pos_op srcflagged -> Eff.val_exp list -> st | CALL nee, _ -> ( if nee.it.def_eff = ExternEff then - ((string_of_node_key_iter nee.src nee.it.node_key_eff) ^ (tuple_par vel)) + if !Global.lv4 then + (match nee.it.node_key_eff with + (* predef op that are iterated are translated into node_exp ; + hence, we need to do (again) a particular threatment to have + a node ouput (i.e., "2>a" vs "Lustre::lt(2,a)" *) + | ("Lustre","lt"), [] -> sov (hd vel) ^ " < " ^ sov (hd (tl vel)) + | ("Lustre","lte"), [] -> sov (hd vel) ^ " <= " ^ sov (hd (tl vel)) + | ("Lustre","gt"), [] -> sov (hd vel) ^ " > " ^ sov (hd (tl vel)) + | ("Lustre","gte"), [] -> sov (hd vel) ^ " >= " ^ sov (hd (tl vel)) + | ("Lustre","eq"), [] -> sov (hd vel) ^ " = " ^ sov (hd (tl vel)) + | ("Lustre","diff"), [] -> sov (hd vel) ^ " <> " ^ sov (hd (tl vel)) + | ("Lustre","plus"), [] -> sov (hd vel) ^ " + " ^ sov (hd (tl vel)) + | ("Lustre","iplus"), [] -> sov (hd vel) ^ " + " ^ sov (hd (tl vel)) + | ("Lustre","rplus"), [] -> sov (hd vel) ^ " + " ^ sov (hd (tl vel)) + | ("Lustre","uminus"), [] -> sov (hd vel) ^ " - " ^ sov (hd (tl vel)) + | ("Lustre","iuminus"), [] -> sov (hd vel) ^ " - " ^ sov (hd (tl vel)) + | ("Lustre","ruminus"), [] -> sov (hd vel) ^ " - " ^ sov (hd (tl vel)) + | ("Lustre","minus"), [] -> sov (hd vel) ^ " - " ^ sov (hd (tl vel)) + | ("Lustre","iminus"), [] -> sov (hd vel) ^ " - " ^ sov (hd (tl vel)) + | ("Lustre","rminus"), [] -> sov (hd vel) ^ " - " ^ sov (hd (tl vel)) + | ("Lustre","div"), [] -> sov (hd vel) ^ " / " ^ sov (hd (tl vel)) + | ("Lustre","idiv"), [] -> sov (hd vel) ^ " / " ^ sov (hd (tl vel)) + | ("Lustre","rdiv"), [] -> sov (hd vel) ^ " / " ^ sov (hd (tl vel)) + | ("Lustre","times"), [] -> sov (hd vel) ^ " * " ^ sov (hd (tl vel)) + | ("Lustre","rtimes"), [] -> sov (hd vel) ^ " * " ^ sov (hd (tl vel)) + | ("Lustre","itimes"), [] -> sov (hd vel) ^ " * " ^ sov (hd (tl vel)) + | ("Lustre","slash"), [] -> sov (hd vel) ^ " / " ^ sov (hd (tl vel)) + | ("Lustre","rslash"), [] -> sov (hd vel) ^ " / " ^ sov (hd (tl vel)) + | ("Lustre","islash"), [] -> sov (hd vel) ^ " / " ^ sov (hd (tl vel)) + + | ("Lustre","impl"), [] -> sov (hd vel) ^ " => " ^ sov (hd (tl vel)) + | ("Lustre","mod"), [] -> sov (hd vel) ^ " mod " ^ sov (hd (tl vel)) + | _ -> + ((string_of_node_key_iter nee.src nee.it.node_key_eff) ^ (tuple_par vel)) + ) + else + ((string_of_node_key_iter nee.src nee.it.node_key_eff) ^ (tuple_par vel)) else (* recursive node cannot be extern *) ((string_of_node_key_rec nee.it.node_key_eff) ^ (tuple_par vel)) diff --git a/src/syntaxTab.ml b/src/syntaxTab.ml index 8da71b4867a1559a1cdb3c38fd23a46d73476849..a0520a2c7430659391ded4c4fe8745add1d2a1e7 100644 --- a/src/syntaxTab.ml +++ b/src/syntaxTab.ml @@ -109,11 +109,12 @@ let (pack_prov_env: t -> Ident.pack_name -> Lxm.t -> SymbolTab.t option) = fun this p lxm -> try (Hashtbl.find this.st_pack_mng_tab p).pm_provide_stab with Not_found -> - let msg = - ("\n*** Could not find package " ^(Ident.pack_name_to_string p) ^ - " in the package table" ) - in - raise(Compile_error(lxm, msg)) +(* let msg = *) +(* ("\n*** Could not find package " ^(Ident.pack_name_to_string p) ^ *) +(* " in the package table" ) *) +(* in *) + None +(* raise(Compile_error(lxm, msg)) *) diff --git a/src/test/test.res.exp b/src/test/test.res.exp index 31dee10e0d4f76d07dd346dc7cda370374501038..611d1451fd27c2ca91905667638d3980518b85c3 100644 --- a/src/test/test.res.exp +++ b/src/test/test.res.exp @@ -12378,7 +12378,7 @@ Opening file should_work/demo/mapinf.lus node mapinf::mapinf(t1:A_int_10; t2:A_int_10) returns (res:A_bool_10); let - res = map<<Lustre::ilt, 10>>(t1, t2); + res = map<<Lustre::lt, 10>>(t1, t2); tel -- end of node mapinf::mapinf -- automatically defined aliases: