Refactoring Ident -> Idents ( uniform with Names etc )

This commit is contained in:
Léonard Gérard 2010-07-23 19:45:19 +02:00
parent 689a10a328
commit f124bb4fd7
41 changed files with 90 additions and 89 deletions

View file

@ -9,11 +9,9 @@
(* causality check of scheduling constraints *)
(* $Id: causal.ml 615 2009-11-20 17:43:14Z pouzet $ *)
open Misc
open Names
open Ident
open Idents
open Heptagon
open Location
open Graph

View file

@ -13,7 +13,7 @@
open Misc
open Names
open Ident
open Idents
open Heptagon
open Location
open Graph

View file

@ -14,7 +14,7 @@
open Misc
open Names
open Ident
open Idents
open Heptagon
open Types
open Location

View file

@ -8,7 +8,7 @@
(**************************************************************************)
(* Read an interface *)
open Ident
open Idents
open Names
open Heptagon
open Signature
@ -110,7 +110,7 @@ struct
let print oc =
let ff = formatter_of_out_channel oc in
NamesEnv.iter (fun key typdesc -> deftype ff key typdesc) current.types;
NamesEnv.iter (fun key constdec -> constdef ff key constdec) current.consts;
NamesEnv.iter (fun key sigtype -> signature ff key sigtype) current.values;
NamesEnv.iter (fun key typdesc -> deftype ff key typdesc) current.types;
NamesEnv.iter (fun key constdec -> constdef ff key constdec) current.consts;
NamesEnv.iter (fun key sigtype -> signature ff key sigtype) current.values;
end

View file

@ -12,7 +12,7 @@
open Misc
open Names
open Ident
open Idents
open Location
open Signature
open Modules

View file

@ -11,7 +11,7 @@
open Location
open Misc
open Names
open Ident
open Idents
open Modules
open Static
open Format

View file

@ -10,7 +10,7 @@
open Location
open Misc
open Names
open Ident
open Idents
open Static
open Signature
open Types

View file

@ -5,7 +5,7 @@ open Location
open Types
open Hept_parsetree
open Names
open Ident
open Idents
open Format
open Printf
open Static

View file

@ -12,7 +12,7 @@
open Misc
open Names
open Ident
open Idents
open Heptagon
open Types
@ -100,11 +100,11 @@ and translate_automaton v eq_list handlers =
let tstatetype = Tid statetype in
let initial = Name(NamesEnv.find (List.hd handlers).s_state states) in
let statename = Ident.fresh "s" in
let next_statename = Ident.fresh "ns" in
let resetname = Ident.fresh "r" in
let next_resetname = Ident.fresh "nr" in
let pre_next_resetname = Ident.fresh "pnr" in
let statename = Idents.fresh "s" in
let next_statename = Idents.fresh "ns" in
let resetname = Idents.fresh "r" in
let next_resetname = Idents.fresh "nr" in
let pre_next_resetname = Idents.fresh "pnr" in
let name n = Name(NamesEnv.find n states) in
let state n = mk_exp (Econst (mk_static_exp

View file

@ -11,7 +11,7 @@
open Misc
open Types
open Names
open Ident
open Idents
open Heptagon
open Hept_mapfold
@ -64,11 +64,11 @@ let translate_automaton v eq_list handlers =
let tstatetype = Tid statetype in
let initial = Name(NamesEnv.find (List.hd handlers).s_state states) in
let statename = Ident.fresh "s" in
let next_statename = Ident.fresh "ns" in
let resetname = Ident.fresh "r" in
let next_resetname = Ident.fresh "nr" in
let pre_next_resetname = Ident.fresh "pnr" in
let statename = Idents.fresh "s" in
let next_statename = Idents.fresh "ns" in
let resetname = Idents.fresh "r" in
let next_resetname = Idents.fresh "nr" in
let pre_next_resetname = Idents.fresh "pnr" in
let name n = Name(NamesEnv.find n states) in
let state n = mk_exp (Econst (mk_static_exp

View file

@ -10,7 +10,7 @@
open Misc
open Heptagon
open Ident
open Idents
(* adds an equation [x = last(x)] for every partially defined variable *)
(* in a control structure *)

View file

@ -12,7 +12,7 @@ open Misc
open Heptagon
open Global_mapfold
open Hept_mapfold
open Ident
open Idents
(* adds an equation [x = last(x)] for every partially defined variable *)
(* in a control structure *)

View file

@ -12,7 +12,7 @@ open Misc
open Heptagon
open Global_mapfold
open Hept_mapfold
open Ident
open Idents
(* We first define a shallow pass,

View file

@ -16,7 +16,7 @@
*)
open Misc
open Ident
open Idents
open Heptagon
open Reset

View file

@ -8,7 +8,7 @@
(**************************************************************************)
open Misc
open Ident
open Idents
open Signature
open Types
open Names
@ -19,7 +19,7 @@ let to_be_inlined s = !Misc.flatten || (List.mem s !Misc.inline)
let mk_unique_node nd =
let mk_bind vd =
let id = Ident.fresh (Ident.sourcename vd.v_ident) in
let id = Idents.fresh (Idents.sourcename vd.v_ident) in
(vd.v_ident, { vd with v_ident = id; }) in
let subst = List.map mk_bind (nd.n_block.b_local
@ nd.n_input @ nd.n_output) in

View file

@ -10,7 +10,7 @@
open Misc
open Heptagon
open Ident
open Idents
(* introduce a fresh equation [last_x = pre(x)] for every *)
(* variable declared with a last *)
@ -18,7 +18,7 @@ let last (eq_list, env, v) { v_ident = n; v_type = t; v_last = last } =
match last with
| Var -> (eq_list, env, v)
| Last(default) ->
let lastn = Ident.fresh ("last" ^ (sourcename n)) in
let lastn = Idents.fresh ("last" ^ (sourcename n)) in
let eq = mk_equation (Eeq (Evarpat lastn,
mk_exp (Epre (default,
mk_exp (Evar n) t)) t)) in

View file

@ -9,7 +9,7 @@
(* removing accessed to shared variables (last x) *)
open Heptagon
open Hept_mapfold
open Ident
open Idents
(* introduce a fresh equation [last_x = pre(x)] for every *)
(* variable declared with a last *)
@ -17,7 +17,7 @@ let last (eq_list, env, v) { v_ident = n; v_type = t; v_last = last } =
match last with
| Var -> (eq_list, env, v)
| Last(default) ->
let lastn = Ident.fresh ("last" ^ (sourcename n)) in
let lastn = Idents.fresh ("last" ^ (sourcename n)) in
let eq = mk_equation (Eeq (Evarpat lastn,
mk_exp (Epre (default,
mk_exp (Evar n) t)) t)) in

View file

@ -10,7 +10,7 @@
open Misc
open Ident
open Idents
open Heptagon
open Types
@ -88,7 +88,7 @@ let ifres res e2 e3 =
(* add an equation *)
let equation v acc_eq_list e =
let n = Ident.fresh "r" in
let n = Idents.fresh "r" in
n,
(mk_bool_param n) :: v,
(mk_equation (Eeq(Evarpat n, e))) ::acc_eq_list
@ -170,7 +170,7 @@ and translate_eqs res v acc_eq_list eq_list =
and translate_switch res locals acc_eq_list switch_handlers =
(* introduce a reset bit for each branch *)
let tab_of_vars n = Array.init n (fun _ -> Ident.fresh "r") in
let tab_of_vars n = Array.init n (fun _ -> Idents.fresh "r") in
let n = List.length switch_handlers in
let m = tab_of_vars n in
let lm = tab_of_vars n in
@ -239,7 +239,8 @@ and translate res e =
| Eiterator(it, ({ a_op = Enode _ } as op), n, e_list, None) ->
let e_list = List.map (translate res) e_list in
if true_reset res then
{ e with e_desc = Eiterator(it, op, n, e_list, Some (exp_of_res res)) }
{ e
with e_desc = Eiterator(it, op, n, e_list, Some (exp_of_res res)) }
else
{ e with e_desc = Eiterator(it, op, n, e_list, None) }
| Eiterator(it, op, n, e_list, r) ->

View file

@ -10,7 +10,7 @@
open Misc
open Ident
open Idents
open Heptagon
open Hept_mapfold
open Types
@ -75,7 +75,7 @@ let ifres res e2 e3 =
(* add an equation *)
let equation v acc_eq_list e =
let n = Ident.fresh "r" in
let n = Idents.fresh "r" in
n,
(mk_bool_param n) :: v,
(mk_equation (Eeq(Evarpat n, e))) ::acc_eq_list
@ -135,8 +135,8 @@ let edesc funs (res, v, acc_eq_list) ed =
let switch_handlers funs (res, v, acc_eq_list) switch_handlers =
(* introduce a reset bit for each branch *)
let m_list = List.map (fun _ -> Ident.fresh "r") switch_handlers in
let lm_list = List.map (fun _ -> Ident.fresh "r") switch_handlers in
let m_list = List.map (fun _ -> Idents.fresh "r") switch_handlers in
let lm_list = List.map (fun _ -> Idents.fresh "r") switch_handlers in
let body i ({ w_block = b } as sh) m lm =
let defnames = List.fold_left (fun acc m ->

View file

@ -12,7 +12,7 @@
open Location
open Misc
open Names
open Ident
open Idents
open Static
open Types
open Format
@ -90,7 +90,7 @@ end
(* add an equation *)
let equation locals l_eqs e =
let n = Ident.fresh "ck" in
let n = Idents.fresh "ck" in
n,
(mk_var_dec n e.e_ty) :: locals,
(mk_equation (Evarpat n) e):: l_eqs
@ -252,7 +252,7 @@ let rec translate_pat = function
let rec rename_pat ni locals s_eqs = function
| Heptagon.Evarpat(n), ty ->
if IdentSet.mem n ni then (
let n_copy = Ident.fresh (sourcename n) in
let n_copy = Idents.fresh (sourcename n) in
Evarpat n_copy,
(mk_var_dec n_copy ty) :: locals,
add n (mk_exp ~exp_ty:ty (Evar n_copy)) s_eqs
@ -323,7 +323,7 @@ and translate_switch_handlers env ni (locals, l_eqs, s_eqs) e handlers =
[] -> IdentSet.empty
| { Heptagon.w_block = { Heptagon.b_defnames = env } } :: _ ->
(* Create set from env *)
(Ident.Env.fold
(Idents.Env.fold
(fun name _ set -> IdentSet.add name set)
env
IdentSet.empty) in

View file

@ -10,7 +10,7 @@
(* Translation from Minils to Obc. *)
open Misc
open Names
open Ident
open Idents
open Signature
open Obc
open Types
@ -189,7 +189,7 @@ let rec translate_eq map call_context { Minils.eq_lhs = pat; Minils.eq_rhs = e }
| Minils.Evarpat x,
Minils.Eapp ({ Minils.a_op = Minils.Eselect_slice;
Minils.a_params = [idx1; idx2] }, [e], _) ->
let cpt = Ident.fresh "i" in
let cpt = Idents.fresh "i" in
let e = translate map (si, j, s) e in
let idx = mk_exp (Eop (op_from_string "+",
[mk_evar cpt;
@ -236,7 +236,7 @@ let rec translate_eq map call_context { Minils.eq_lhs = pat; Minils.eq_rhs = e }
| Minils.Evarpat x,
Minils.Eapp ({ Minils.a_op = Minils.Earray_fill;
Minils.a_params = [n] }, [e], _) ->
let cpt = Ident.fresh "i" in
let cpt = Idents.fresh "i" in
let action =
Afor (cpt, mk_static_exp (Sint 0), n,
mk_block [Aassgn (mk_lhs (Larray (var_from_name map x,
@ -247,8 +247,8 @@ let rec translate_eq map call_context { Minils.eq_lhs = pat; Minils.eq_rhs = e }
| Minils.Evarpat x,
Minils.Eapp ({ Minils.a_op = Minils.Econcat }, [e1; e2], _) ->
let cpt1 = Ident.fresh "i" in
let cpt2 = Ident.fresh "i" in
let cpt1 = Idents.fresh "i" in
let cpt2 = Idents.fresh "i" in
let x = var_from_name map x in
(match e1.Minils.e_ty, e2.Minils.e_ty with
| Tarray (_, n1), Tarray (_, n2) ->
@ -288,7 +288,7 @@ let rec translate_eq map call_context { Minils.eq_lhs = pat; Minils.eq_rhs = e }
let name_list = translate_pat map pat in
let c_list =
List.map (translate map (si, j, s)) e_list in
let x = Ident.fresh "i" in
let x = Idents.fresh "i" in
let call_context = Oarray ("n", mk_lhs (Lvar x)), Some n in
let si', j', action = translate_iterator map call_context it
name_list app loc n x c_list in

View file

@ -9,7 +9,7 @@
(* clock checking *)
open Misc
open Ident
open Idents
open Minils
open Mls_printer
open Signature
@ -39,10 +39,11 @@ let gen_index () = (incr index; !index)
let new_var () = Cvar { contents = Cindex (gen_index ()); }
let rec repr ck =
match ck with
| Cbase | Con _ | Cvar { contents = Cindex _ } -> ck
| Cvar (({ contents = Clink ck } as link)) ->
(** return the canonic representant form of a [ck] *)
let rec repr ck = match ck with
| Cbase | Con _ | Cvar { contents = Cindex _ } -> ck
| Cvar (({ contents = Clink ck } as link)) ->
let ck = repr ck in (link.contents <- Clink ck; ck)
let rec occur_check index ck =

View file

@ -16,7 +16,7 @@
open Misc
open Names
open Ident
open Idents
open Minils
open Location
open Format

View file

@ -11,7 +11,7 @@
open Location
open Names
open Ident
open Idents
open Signature
open Static
open Types

View file

@ -1,6 +1,6 @@
open Names
open Ident
open Idents
open Types
open Static
open Format

View file

@ -3,7 +3,7 @@ open Mls_mapfold
open Mls_printer
open Location
open Names
open Ident
open Idents
open Signature
open Static
open Types

View file

@ -2,7 +2,7 @@
open Signature
open Names
open Ident
open Idents
open Types
open Location
open Minils

View file

@ -1,7 +1,7 @@
open Misc
open Minils
open Names
open Ident
open Idents
open Format
open Location
open Printf

View file

@ -161,7 +161,7 @@ let generate_new_name ln params =
| Modname { qual = q; id = id } ->
let new_ln =
Modname { qual = q;
id = id ^ (Ident.name (Ident.fresh "")) } in
id = id ^ (Idents.name (Idents.fresh "")) } in
Hashtbl.add info.nodes_names (ln, params) new_ln
| _ -> assert false)

View file

@ -23,7 +23,7 @@ let tuple_of_vd_list l =
let vd_of_arg ad =
let n = match ad.a_name with None -> "_v" | Some n -> n in
mk_var_dec (Ident.fresh n) ad.a_type
mk_var_dec (Idents.fresh n) ad.a_type
(** @return the lists of inputs and outputs (as var_dec) of
an app object. *)
@ -74,7 +74,7 @@ let edesc funs acc ed =
let new_inp, e, acc_eq_list = mk_call g acc_eq_list in
new_inp @ inp, acc_eq_list, e::largs, local_args @ args, true
| _ ->
let vd = mk_var_dec (Ident.fresh "_x") e.e_ty in
let vd = mk_var_dec (Idents.fresh "_x") e.e_ty in
let x = mk_exp (Evar vd.v_ident) in
vd::inp, acc_eq_list, x::largs, e::args, b
in

View file

@ -8,7 +8,7 @@
(**************************************************************************)
open Misc
open Names
open Ident
open Idents
open Signature
open Minils
open Mls_utils
@ -19,7 +19,7 @@ and cfalse = Name "false"
let equation (d_list, eq_list) e =
let add_one_var ty d_list =
let n = Ident.fresh "_v" in
let n = Idents.fresh "_v" in
let d_list = (mk_var_dec ~clock:e.e_ck n ty) :: d_list in
n, d_list
in

View file

@ -11,7 +11,7 @@ open Format
open List
open Misc
open Names
open Ident
open Idents
open Obc
open Types
open Modules

View file

@ -11,7 +11,7 @@ open Format
open List
open Misc
open Names
open Ident
open Idents
open Obc
open Types
open Modules
@ -25,8 +25,8 @@ open Compiler_utils
(** {1 Main C function generation} *)
(* Unique names for C variables handling step counts. *)
let step_counter = Ident.fresh "step_c"
and max_step = Ident.fresh "step_max"
let step_counter = Idents.fresh "step_c"
and max_step = Idents.fresh "step_max"
let assert_node_res cd =
let stepm = find_step_method cd in
@ -42,9 +42,11 @@ let assert_node_res cd =
cd.cd_name;
exit 1);
let mem =
(name (Ident.fresh ("mem_for_" ^ cd.cd_name)), Cty_id (cd.cd_name ^ "_mem"))
(name (Idents.fresh ("mem_for_" ^ cd.cd_name)),
Cty_id (cd.cd_name ^ "_mem"))
and out =
(name (Ident.fresh ("out_for_" ^ cd.cd_name)), Cty_id (cd.cd_name ^ "_out")) in
(name (Idents.fresh ("out_for_" ^ cd.cd_name)),
Cty_id (cd.cd_name ^ "_out")) in
let reset_i =
Cfun_call (cd.cd_name ^ "_reset", [Caddrof (Cvar (fst mem))]) in
let step_i =
@ -55,7 +57,7 @@ let assert_node_res cd =
return 1;
}
*)
let outn = Ident.name ((List.hd stepm.m_outputs).v_ident) in
let outn = Idents.name ((List.hd stepm.m_outputs).v_ident) in
Csblock
{ var_decls = [];
block_body =
@ -101,7 +103,7 @@ let main_def_of_class_def cd =
(** Generates scanf statements. *)
let rec read_lhs_of_ty lhs ty = match ty with
| Tarray (ty, n) ->
let iter_var = Ident.name (Ident.fresh "i") in
let iter_var = Idents.name (Idents.fresh "i") in
let lhs = Carray (lhs, Clhs (Cvar iter_var)) in
let (reads, bufs) = read_lhs_of_ty lhs ty in
([Cfor (iter_var, 0, int_of_static_exp n, reads)], bufs)
@ -127,7 +129,7 @@ let main_def_of_class_def cd =
match need_buf_for_ty ty with
| None -> ([scan_exp], [])
| Some tyn ->
let varn = Ident.name (Ident.fresh "buf") in
let varn = Idents.name (Idents.fresh "buf") in
([scan_exp;
Csexpr (Cfun_call (tyn ^ "_of_string",
[Clhs (Cvar varn)]))],
@ -137,14 +139,14 @@ let main_def_of_class_def cd =
resulting values of enum types. *)
let rec write_lhs_of_ty lhs ty = match ty with
| Tarray (ty, n) ->
let iter_var = Ident.name (Ident.fresh "i") in
let iter_var = Idents.name (Idents.fresh "i") in
let lhs = Carray (lhs, Clhs (Cvar iter_var)) in
let (reads, bufs) = write_lhs_of_ty lhs ty in
([cprint_string "[ ";
Cfor (iter_var, 0, int_of_static_exp n, reads);
cprint_string "]"], bufs)
| _ ->
let varn = Ident.name (Ident.fresh "buf") in
let varn = Idents.name (Idents.fresh "buf") in
let format_s = format_for_type ty in
let nbuf_opt = need_buf_for_ty ty in
let ep = match nbuf_opt with
@ -162,7 +164,7 @@ let main_def_of_class_def cd =
let stepm = find_step_method cd in
let (scanf_calls, scanf_decls) =
let read_lhs_of_ty_for_vd vd =
read_lhs_of_ty (Cvar (Ident.name vd.v_ident)) vd.v_type in
read_lhs_of_ty (Cvar (Idents.name vd.v_ident)) vd.v_type in
split (map read_lhs_of_ty_for_vd stepm.m_inputs) in
let (printf_calls, printf_decls) =

View file

@ -1,5 +1,5 @@
open C
open Ident
open Idents
open Names
let rec subst_stm map stm = match stm with

View file

@ -9,10 +9,9 @@
(* control optimisation *)
(* $Id$ *)
open Minils
open Ident
open Idents
open Misc
open Obc

View file

@ -14,7 +14,7 @@ open Format
open Obc
open Misc
open Names
open Ident
open Idents
open Pp_tools
let jname_of_name name =
@ -503,7 +503,7 @@ let print_step ff n s objs ts single =
(List.map (fun vd -> vd.v_ident) s.out) ts single;
fprintf ff "@ @ return ";
if single
then fprintf ff "%s" (jname_of_name (Ident.name (List.hd s.out).v_ident))
then fprintf ff "%s" (jname_of_name (Idents.name (List.hd s.out).v_ident))
else fprintf ff "step_ans";
fprintf ff ";@]@ }@ @]"

View file

@ -10,7 +10,7 @@
open Misc
open Names
open Ident
open Idents
open Types
open Signature
open Location

View file

@ -2,7 +2,7 @@ open Obc
open Format
open Pp_tools
open Types
open Ident
open Idents
open Names
let print_vd ff vd =

View file

@ -9,7 +9,7 @@
(* dependences between equations *)
open Graph
open Ident
open Idents
module type READ =
sig