Commit bc96cafb authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2004-12-23 00:33:43 by afrisch] comments

Original author: afrisch
Date: 2004-12-23 00:33:43+00:00
parent 41949d9f
......@@ -1658,6 +1658,28 @@ x=(1,2)
| TConj of Types.t * fv * ('a,'b) t * ('a,'b) t
| TOther of descr * Types.t * fv * 'b
let capt pr p =
if IdMap.is_empty pr then p else match p with
| TCapt (pr2,p) -> TCapt (TargExpr.merge pr pr2,p)
| TFail -> TFail
| p -> TCapt (pr,p)
let rec conj a1 fv1 r1 r2 = match (r1,r2) with
| TSucceed,r | r,TSucceed -> r
| TFail,r | r,TFail -> TFail
| TCapt (f,r1), r2 | r2, TCapt (f,r1) -> capt f (conj a1 fv1 r1 r2)
| r1,r2 -> TConj (a1,fv1,r1,r2)
let alt p a1 r1 r2 = match (r1,r2) with
| TFail,r | r,TFail -> r
| TSucceed, _ -> assert false
(* Note: this cannot happen because if the lhs succeeds,
then the rhs must fail (it is evaluated under
the assumption that the lhs fails, so the static
assumption is empty in this case). *)
| r1,r2 -> TAlt (p,a1,r1,r2)
let get_result = function
| TCapt (r,TSucceed) -> Some r
| TFail -> None
......@@ -1692,23 +1714,6 @@ x=(1,2)
| Record (l,q) -> oth (`Record (l,q))
| Dummy -> assert false
let capt pr p =
if IdMap.is_empty pr then p else match p with
| TCapt (pr2,p) -> TCapt (TargExpr.merge pr pr2,p)
| TFail -> TFail
| p -> TCapt (pr,p)
let rec conj a1 fv1 r1 r2 = match (r1,r2) with
| TSucceed,r | r,TSucceed -> r
| TFail,r | r,TFail -> TFail
| TCapt (f,r1), r2 | r2, TCapt (f,r1) -> capt f (conj a1 fv1 r1 r2)
| r1,r2 -> TConj (a1,fv1,r1,r2)
let alt p a1 r1 r2 = match (r1,r2) with
| TFail,r | r,TFail -> r
| r1,r2 -> TAlt (p,a1,r1,r2)
let factorize ((a,_,_) as p) t xs f =
if Types.disjoint a t then TFail
else
......@@ -1730,6 +1735,10 @@ x=(1,2)
(fun xs ->
alt p a1 (optimize t xs p1) (optimize (Types.diff t a1) xs p2))
| TConj (a1,fv1,p1,p2) ->
(* We don't factorize above a & pattern eagerly, because
if factorization would occur, it would also
occur below and be lifted by the conj function, which
produces the same effect. *)
conj a1 fv1
(optimize t (IdSet.cap xs fv1) p1)
(optimize (Types.cap t a1) (IdSet.diff xs fv1) p2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment