From c2ebaec784c7b9c787ad09b76ca24138b3a900ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Pasteur?= Date: Wed, 28 Jul 2010 09:39:31 +0200 Subject: [PATCH] Correct normalization of Ctuple It was not that hard, just had to stop and really take the time to understand the problem... --- compiler/heptagon/analysis/causal.ml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/compiler/heptagon/analysis/causal.ml b/compiler/heptagon/analysis/causal.ml index 6d6351b..6b51de3 100644 --- a/compiler/heptagon/analysis/causal.ml +++ b/compiler/heptagon/analysis/causal.ml @@ -116,27 +116,22 @@ let rec cand nc1 nc2 = | Aac(ac1), Aac(ac2) -> Aac(Aand(ac1, ac2)) let rec ctuple l = - let rec conv = function - | Cwrite(n) -> Awrite(n) - | Cread(n) -> Aread(n) - | Clastread(n) -> Alastread(n) - | Ctuple(l) -> Atuple (ctuple l) - | Cand (c1, c2) -> Aand (conv c1, conv c2) - | Cseq (c1, c2) -> Aseq (conv c1, conv c2) - | Cor (Cempty, c2) -> conv c2 - | Cor (c1, Cempty) -> conv c1 - | Cempty -> assert false + let rec norm_or l res = match l with + | [] -> Aac (Atuple (List.rev res)) + | Aempty::l -> norm_or l res + | Aor (Aempty, nc2)::l -> norm_or (nc2::l) res + | Aor (nc1, Aempty)::l -> norm_or (nc1::l) res + | Aor(nc1, nc2)::l -> + Aor(norm_or (nc1::l) res, norm_or (nc2::l) res) + | (Aac ac)::l -> norm_or l (ac::res) in - match l with - | [] -> [] - | Cempty::l -> ctuple l - | v::l -> (conv v)::(ctuple l) + norm_or l [] and norm = function | Cor(c1, c2) -> cor (norm c1) (norm c2) | Cand(c1, c2) -> cand (norm c1) (norm c2) | Cseq(c1, c2) -> cseq (norm c1) (norm c2) - | Ctuple l -> Aac(Atuple (ctuple l)) + | Ctuple l -> ctuple (List.map norm l) | Cwrite(n) -> Aac(Awrite(n)) | Cread(n) -> Aac(Aread(n)) | Clastread(n) -> Aac(Alastread(n))