let rename_entities file =
let add_variable v =
v.vname <- unique_name v.vname;
match v.vlogic_var_assoc with
| None -> ()
| Some lv -> lv.lv_name <- v.vname
in
let add_logic_variable v =
match v.lv_origin with
None ->
v.lv_name <- unique_logic_name v.lv_name
| Some _ -> ()
in
Globals.Vars.iter (fun v _init -> add_variable v);
Globals.Functions.iter
(fun kf ->
add_variable (Globals.Functions.get_vi kf);
List.iter add_variable (Globals.Functions.get_params kf));
Globals.Annotations.replace_all
(fun annot gen ->
let rec replace_annot annot = match annot with
| Dfun_or_pred _ -> annot
| Daxiomatic(id, l) -> Daxiomatic(id, List.map replace_annot l)
| Dtype(infos) ->
Dtype({ infos with
lt_name = unique_logic_name infos.lt_name;
lt_ctors =
opt_map
(List.map
(fun x ->
{ x with ctor_name =
unique_logic_name x.ctor_name}))
infos.lt_ctors;})
| Dlemma(name,is_axiom,labels,poly,property) ->
Dlemma(unique_logic_name name,is_axiom,labels,poly,property)
| Dtype_annot _info | Dinvariant _info ->
annot
in replace_annot annot,gen
);
Logic_env.LogicInfo.iter
(fun name _li ->
try
let x = Hashtbl.find logic_names_overloading name in
x := true
with
Not_found ->
Hashtbl.add logic_names_overloading name (ref false)
);
let visitor = new renameEntities (add_variable) (add_logic_variable) in
visitFramacFile visitor file