diff --git a/src/getEff.ml b/src/getEff.ml index 341e8a897b4290f8cd4aa76ee254b19d6769b39a..d7d00606b5fa33d9adf7aa2e424da8035b087d24 100644 --- a/src/getEff.ml +++ b/src/getEff.ml @@ -13,7 +13,7 @@ open Ident exception GetEffType_error of string (* exported *) -let rec (typ:Eff.id_solver -> SyntaxTreeCore.type_exp -> Eff.type_) = +let rec (of_type: Eff.id_solver -> SyntaxTreeCore.type_exp -> Eff.type_) = fun env texp -> try ( match texp.it with @@ -22,7 +22,7 @@ let rec (typ:Eff.id_solver -> SyntaxTreeCore.type_exp -> Eff.type_) = | Real_type_exp -> Real_type_eff | Named_type_exp s -> env.id2type s texp.src | Array_type_exp (elt_texp, szexp) -> - let elt_teff = typ env elt_texp in + let elt_teff = of_type env elt_texp in try let sz = EvalConst.eval_array_size env szexp in Array_type_eff (elt_teff, sz) @@ -47,7 +47,7 @@ let (add_pack_name : id_solver -> Lxm.t -> Ident.idref -> Ident.idref) = (* exported *) -let rec (clock : Eff.id_solver -> SyntaxTreeCore.var_info -> Eff.id_clock)= +let rec (of_clock : Eff.id_solver -> SyntaxTreeCore.var_info -> Eff.id_clock)= fun id_solver v -> match v.var_clock with | Base -> v.var_name, BaseEff @@ -133,7 +133,7 @@ let (get_static_params_from_idref : SymbolTab.t -> Lxm.t -> Ident.idref -> [] (* exported *) -let rec (node : Eff.id_solver -> SyntaxTreeCore.node_exp srcflagged -> +let rec (of_node : Eff.id_solver -> SyntaxTreeCore.node_exp srcflagged -> Eff.node_exp) = fun id_solver { src = lxm; it=(idref, static_args) } -> let static_params = get_static_params_from_idref id_solver.symbols lxm idref in @@ -238,7 +238,7 @@ and (check_static_arg : Eff.id_solver -> | _ -> assert false (* should not occur *) ) | StaticArgType te, StaticParamType id -> - let teff = typ node_id_solver te in + let teff = of_type node_id_solver te in TypeStaticArgEff (id, teff) | StaticArgIdent idref, StaticParamNode(id, vii, vio,_) -> @@ -249,7 +249,7 @@ and (check_static_arg : Eff.id_solver -> NodeStaticArgEff (id, (neff.node_key_eff, inlist, outlist), neff) | StaticArgNode(CALL_n ne), StaticParamNode(id,vii,vio,_) -> - let neff = node node_id_solver ne in + let neff = of_node node_id_solver ne in let (inlist, outlist) = check_node_arg neff vii vio in NodeStaticArgEff (id, (neff.node_key_eff, inlist, outlist), neff) @@ -283,7 +283,7 @@ and (check_static_arg : Eff.id_solver -> (******************************************************************************) (* exported *) -and (eq:Eff.id_solver -> SyntaxTreeCore.eq_info srcflagged -> Eff.eq_info srcflagged) = +and (of_eq: Eff.id_solver -> SyntaxTreeCore.eq_info srcflagged -> Eff.eq_info srcflagged) = fun id_solver eq_info -> let (lpl, ve) = eq_info.it in let lpl_eff = List.map (translate_left_part id_solver) lpl @@ -385,7 +385,7 @@ and (translate_val_exp : Eff.id_solver -> UnifyClock.subst -> s, mk_by_pos_op(Predef (op,[])) ) | CALL_n node_exp_f -> - s, mk_by_pos_op(Eff.CALL (flagit (node id_solver node_exp_f) + s, mk_by_pos_op(Eff.CALL (flagit (of_node id_solver node_exp_f) node_exp_f.src)) | IDENT_n idref -> ( try @@ -540,10 +540,14 @@ and translate_field id_solver s (id, ve) = s, (id, ve) (* XXX autre nom, autre module ? + node_of_static_arg : appelé QUAND ON SAIT qu'un sarg doit etre un NODE + const_of_static_arg : appelé QUAND ON SAIT qu'un sarg doit etre une CONST + + -> sert pour les macros predefs ca fait partie de la definition des iterateurs d'une certaine maniere... -> créer 2 modules, Iterator + IteratorSemantics *) -and get_const id_solver const_or_const_ident lxm = +and const_of_static_arg id_solver const_or_const_ident lxm = match const_or_const_ident with | StaticArgConst(c) -> ( match EvalConst.f id_solver c with @@ -558,13 +562,13 @@ and get_const id_solver const_or_const_ident lxm = -and get_node id_solver node_or_node_ident lxm = +and node_of_static_arg id_solver node_or_node_ident lxm = match node_or_node_ident with | StaticArgIdent(id) -> let sargs = [] in (* it is an alias: no static arg *) id_solver.id2node id sargs lxm - | StaticArgNode(CALL_n ne) -> node id_solver ne + | StaticArgNode(CALL_n ne) -> of_node id_solver ne | StaticArgNode(Predef_n (op,sargs)) -> let sargs_eff = translate_predef_static_args id_solver op sargs lxm in PredefEvalType.make_node_exp_eff None op lxm sargs_eff @@ -666,9 +670,9 @@ and translate_predef_static_args match sargs with | [c1; c2; c3] -> [ - ConstStaticArgEff(Ident.of_string "min", get_const id_solver c1.it c1.src); - ConstStaticArgEff(Ident.of_string "max", get_const id_solver c2.it c2.src); - ConstStaticArgEff(Ident.of_string "size",get_const id_solver c3.it c3.src) + ConstStaticArgEff(Ident.of_string "min", const_of_static_arg id_solver c1.it c1.src); + ConstStaticArgEff(Ident.of_string "max", const_of_static_arg id_solver c2.it c2.src); + ConstStaticArgEff(Ident.of_string "size",const_of_static_arg id_solver c3.it c3.src) ] | _ -> raise (Compile_error(lxm, "bad arguments number for boolred iterator")) ) @@ -676,13 +680,13 @@ and translate_predef_static_args (* expects 1 node, 1 constant *) match sargs with | [n; s] -> - let node_eff = get_node id_solver n.it n.src in + let node_eff = node_of_static_arg id_solver n.it n.src in let node_arg = node_eff.node_key_eff, node_eff.inlist_eff, node_eff.outlist_eff in [ NodeStaticArgEff(Ident.of_string "node", node_arg, node_eff); - ConstStaticArgEff(Ident.of_string "size", get_const id_solver s.it s.src) + ConstStaticArgEff(Ident.of_string "size", const_of_static_arg id_solver s.it s.src) ] | _ -> raise (Compile_error(lxm, "bad arguments number for array iterator")) ) @@ -698,11 +702,11 @@ and translate_predef_static_args ); *) - let node_eff = get_node id_solver n.it n.src in + let node_eff = node_of_static_arg id_solver n.it n.src in let node_arg = node_eff.node_key_eff, node_eff.inlist_eff, node_eff.outlist_eff in - let dflt = get_const id_solver d.it d.src in + let dflt = const_of_static_arg id_solver d.it d.src in [ NodeStaticArgEff(Ident.of_string "node", node_arg, node_eff); @@ -727,7 +731,7 @@ and (translate_slice_info : Eff.id_solver -> SyntaxTreeCore.slice_info -> (**********************************************************************************) (* exported *) -let (assertion : Eff.id_solver -> SyntaxTreeCore.val_exp Lxm.srcflagged -> +let (of_assertion : Eff.id_solver -> SyntaxTreeCore.val_exp Lxm.srcflagged -> Eff.val_exp Lxm.srcflagged) = fun id_solver vef -> let s, val_exp_eff = translate_val_exp id_solver UnifyClock.empty_subst vef.it in diff --git a/src/getEff.mli b/src/getEff.mli index ff5dfcacdf84711fe5aed463429c5e2c11272daa..ec256f11bdc1c137e133c0d1606135e74c144901 100644 --- a/src/getEff.mli +++ b/src/getEff.mli @@ -13,8 +13,8 @@ - checks the arguments and the parameters are compatible (i.e., that they unify) *) -val typ : Eff.id_solver -> SyntaxTreeCore.type_exp -> Eff.type_ -val clock: Eff.id_solver -> SyntaxTreeCore.var_info -> Eff.id_clock +val of_type : Eff.id_solver -> SyntaxTreeCore.type_exp -> Eff.type_ +val of_clock : Eff.id_solver -> SyntaxTreeCore.var_info -> Eff.id_clock (** A [node_exp] is a name plus a list of static arguments. @@ -24,13 +24,13 @@ val clock: Eff.id_solver -> SyntaxTreeCore.var_info -> Eff.id_clock - check they are compatible with the node signature check the type of the static arguments ( *) -val node : Eff.id_solver -> SyntaxTreeCore.node_exp Lxm.srcflagged -> +val of_node : Eff.id_solver -> SyntaxTreeCore.node_exp Lxm.srcflagged -> Eff.node_exp -val eq : Eff.id_solver -> SyntaxTreeCore.eq_info Lxm.srcflagged -> +val of_eq : Eff.id_solver -> SyntaxTreeCore.eq_info Lxm.srcflagged -> Eff.eq_info Lxm.srcflagged -val assertion : Eff.id_solver -> SyntaxTreeCore.val_exp Lxm.srcflagged -> +val of_assertion : Eff.id_solver -> SyntaxTreeCore.val_exp Lxm.srcflagged -> Eff.val_exp Lxm.srcflagged diff --git a/src/lazyCompiler.ml b/src/lazyCompiler.ml index 6d25ccba13e7eefe5b1a74bcee975ceabcd6e4c3..70e718eed0bbf534b168b1f50c453cc048a6b828 100644 --- a/src/lazyCompiler.ml +++ b/src/lazyCompiler.ml @@ -121,9 +121,9 @@ let (create : SyntaxTab.t -> t) = o tabulates its result o takes an x_key and returns an [x_eff] o lookups its (syntaxic) definition (x_info) via the symbolTab.t - o calls [GetEff.X] to translate its sub-terms + o calls [GetEff.of_X] to translate its sub-terms - - [GetEff.X] + - [GetEff.of_X] o takes a [x_exp] (i.e., an expression) and returns an [x_eff] o compute the effective static args (for nodes) o calls [solve_x_idref] (via [id_solver]) to translate its sub-terms @@ -455,7 +455,7 @@ and (type_check_do: t -> Ident.long -> Lxm.t -> SymbolTab.t -> bool -> with e -> External_type_eff (lid) ) - | AliasedType (s, texp) -> GetEff.typ id_solver texp + | AliasedType (s, texp) -> GetEff.of_type id_solver texp | EnumType (s, clst) -> ( let n = Ident.make_long pack_name s in let add_pack_name x = Ident.make_long pack_name x.it in @@ -464,7 +464,7 @@ and (type_check_do: t -> Ident.long -> Lxm.t -> SymbolTab.t -> bool -> | StructType sti -> ( let make_field (fname : Ident.t) = let field_def = Hashtbl.find sti.st_ftable fname in - let teff = GetEff.typ id_solver field_def.it.fd_type in + let teff = GetEff.of_type id_solver field_def.it.fd_type in match field_def.it.fd_value with | None -> (fname, (teff, None)) | Some vexp -> ( @@ -535,7 +535,7 @@ and (const_check_do : t -> Ident.long -> Lxm.t -> SymbolTab.t -> bool -> match const_def.it with | ExternalConst (id, texp, val_opt) -> let lid = Ident.make_long currpack id in - let teff = GetEff.typ id_solver texp in + let teff = GetEff.of_type id_solver texp in if provide_flag then match val_opt with | None -> @@ -560,7 +560,7 @@ and (const_check_do : t -> Ident.long -> Lxm.t -> SymbolTab.t -> bool -> (* indeed, how can a body constant be extern and have a value? *) ) | EnumConst (id, texp) -> - Enum_const_eff ((Ident.make_long currpack id), GetEff.typ id_solver texp) + Enum_const_eff ((Ident.make_long currpack id), GetEff.of_type id_solver texp) | DefinedConst (id, texp_opt, vexp ) -> ( match (EvalConst.f id_solver vexp) with @@ -568,7 +568,7 @@ and (const_check_do : t -> Ident.long -> Lxm.t -> SymbolTab.t -> bool -> match texp_opt with | None -> ceff | Some texp -> ( - let tdecl = GetEff.typ id_solver texp in + let tdecl = GetEff.of_type id_solver texp in let teff = Eff.type_of_const ceff in if (tdecl = teff ) then ceff else raise @@ -824,7 +824,7 @@ and (node_check_do: t -> Eff.node_key -> Lxm.t -> SymbolTab.t -> match toptdef with | None -> ceff | Some texp -> ( - let tdecl = GetEff.typ local_id_solver texp in + let tdecl = GetEff.of_type local_id_solver texp in let teff = Eff.type_of_const ceff in if (tdecl = teff ) then ceff else raise (Compile_error ( @@ -888,9 +888,9 @@ and (node_check_do: t -> Eff.node_key -> Lxm.t -> SymbolTab.t -> let is_polymorphic = ref false in let type_args id = let vi = find_var_info lxm vars id in - let t_eff = GetEff.typ node_id_solver vi.it.var_type in + let t_eff = GetEff.of_type node_id_solver vi.it.var_type in let _ = if Eff.is_polymorphic t_eff then is_polymorphic := true in - let c_eff = GetEff.clock node_id_solver vi.it in + let c_eff = GetEff.of_clock node_id_solver vi.it in let vi_eff = { var_name_eff = vi.it.var_name; var_nature_eff = vi.it.var_nature; @@ -986,10 +986,10 @@ and (node_check_do: t -> Eff.node_key -> Lxm.t -> SymbolTab.t -> after the local_env.lenv_vars has been filled *) - let eq_eff = List.map (GetEff.eq node_id_solver) nb.eqs in + let eq_eff = List.map (GetEff.of_eq node_id_solver) nb.eqs in BodyEff { asserts_eff = - List.map (GetEff.assertion node_id_solver) nb.asserts; + List.map (GetEff.of_assertion node_id_solver) nb.asserts; eqs_eff = eq_eff; } ) @@ -1012,7 +1012,7 @@ and (node_check_do: t -> Eff.node_key -> Lxm.t -> SymbolTab.t -> predef_op_eff | CALL_n(node_alias) -> - GetEff.node node_id_solver node_alias + GetEff.of_node node_id_solver node_alias | (MERGE_n _|ARRAY_SLICE_n _|ARRAY_ACCES_n _|STRUCT_ACCESS_n _ |IDENT_n _|ARRAY_n|HAT_n|CONCAT_n|WITH_n(_)|TUPLE_n|WHEN_n _ |CURRENT_n|FBY_n|ARROW_n|PRE_n) @@ -1031,7 +1031,7 @@ and (node_check_do: t -> Eff.node_key -> Lxm.t -> SymbolTab.t -> List.map (fun id -> find_var_info lxm vars id) vars.SyntaxTreeCore.inlist, List.map (fun id -> find_var_info lxm vars id) vars.SyntaxTreeCore.outlist in - let aux vi = GetEff.typ node_id_solver vi.it.var_type in + let aux vi = GetEff.of_type node_id_solver vi.it.var_type in let (il_decl, ol_decl) = List.map aux vi_il, List.map aux vi_ol in let i_unif_res = UnifyType.f il_decl il and o_unif_res = UnifyType.f ol_decl ol