aboutsummaryrefslogtreecommitdiffhomepage
path: root/checker/declarations.ml
diff options
context:
space:
mode:
authorGravatar barras <barras@85f007b7-540e-0410-9357-904b9bb8a0f7>2008-05-07 16:13:37 +0000
committerGravatar barras <barras@85f007b7-540e-0410-9357-904b9bb8a0f7>2008-05-07 16:13:37 +0000
commitfa5fbb3625452dd560ffb5bfe5493d26b730b402 (patch)
tree357d6fe295e25a2c8b27d2d6911506ba3a6d590c /checker/declarations.ml
parent335c779987e4b845e6700d5df81fe248e6e940f7 (diff)
fixed bug with aliases
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@10896 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'checker/declarations.ml')
-rw-r--r--checker/declarations.ml42
1 files changed, 42 insertions, 0 deletions
diff --git a/checker/declarations.ml b/checker/declarations.ml
index 94388f4ac..71b6c9ca0 100644
--- a/checker/declarations.ml
+++ b/checker/declarations.ml
@@ -306,6 +306,48 @@ let join_alias (subst1 : substitution) (subst2 : substitution) =
Umap.mapi (apply_subst subst2) subst1
+let update_subst subst1 subst2 =
+ let subst_inv key (mp,_) l =
+ let newmp =
+ match key with
+ | MBI msid -> MPbound msid
+ | MSI msid -> MPself msid
+ | MPI mp -> mp
+ in
+ match mp with
+ | MPbound mbid -> ((MBI mbid),newmp)::l
+ | MPself msid -> ((MSI msid),newmp)::l
+ | _ -> ((MPI mp),newmp)::l
+ in
+ let subst_mbi = Umap.fold subst_inv subst2 [] in
+ let alias_subst key (mp,_) sub=
+ let newsetkey =
+ match key with
+ | MPI mp1 ->
+ let compute_set_newkey l (k,mp') =
+ let mp_from_key = match k with
+ | MBI msid -> MPbound msid
+ | MSI msid -> MPself msid
+ | MPI mp -> mp
+ in
+ let new_mp1 = replace_mp_in_mp mp_from_key mp' mp1 in
+ if new_mp1 == mp1 then l else (MPI new_mp1)::l
+ in
+ begin
+ match List.fold_left compute_set_newkey [] subst_mbi with
+ | [] -> None
+ | l -> Some (l)
+ end
+ | _ -> None
+ in
+ match newsetkey with
+ | None -> sub
+ | Some l ->
+ List.fold_left (fun s k -> Umap.add k (mp,None) s)
+ sub l
+ in
+ Umap.fold alias_subst subst1 empty_subst
+
let subst_substituted s r =
match !r with