| 1 |
(* |
| 2 |
* This module implements Tarjan's fast path computation algorithm. |
| 3 |
* |
| 4 |
* -- Allen |
| 5 |
*) |
| 6 |
|
| 7 |
functor TarjanFastPath(Dom : DOMINATOR_TREE) : TARJAN_FAST_PATH = |
| 8 |
struct |
| 9 |
|
| 10 |
structure Dom = Dom |
| 11 |
structure G = Graph |
| 12 |
structure A = Array |
| 13 |
|
| 14 |
datatype 'e pexp = |
| 15 |
NULLSET |
| 16 |
| LAMBDA |
| 17 |
| EDGE of 'e Graph.edge |
| 18 |
| || of 'e pexp * 'e pexp |
| 19 |
| ++ of 'e pexp * 'e pexp |
| 20 |
|
| 21 |
type 'e pseq = ('e pexp * int * int) list |
| 22 |
|
| 23 |
infix || ++ |
| 24 |
|
| 25 |
fun simp (NUL || x) = x |
| 26 |
| simp (x || NUL) = x |
| 27 |
| simp (NUL ++ x) = NUL |
| 28 |
| simp (x ++ NUL) = NUL |
| 29 |
| simp (EMP ++ x) = x |
| 30 |
| simp x = x |
| 31 |
|
| 32 |
fun solve P s = |
| 33 |
|
| 34 |
fun decompose_and_sequence (G as G.GRAPH G,Dom as G.GRAPH dom) = |
| 35 |
let val N = #capacity dom () |
| 36 |
val ancestor = A.array(N,~1) |
| 37 |
val derived = A.array(N,~1) |
| 38 |
val S = A.array(N,LAMBDA) |
| 39 |
val R = A.array(N,NULLSET) |
| 40 |
fun eliminate (G.GRAPH G) = |
| 41 |
|
| 42 |
fun walk(u,lvl,sequence) = |
| 43 |
in |
| 44 |
end |
| 45 |
|
| 46 |
end |