public void BuildIdomTree Debug Assert StartVertex null BUFVertex Star

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
public void BuildIdomTree()
{
Debug.Assert(StartVertex != null);
BUFVertex = StartVertex;
CalculateTime();
int i, j;
var G = AllVerts.ToArray();
Array.Sort(G);
var n = G.Length;
for (i = 0; i < n; i++)
{
G[i].attributes.sdom = G[i];
G[i].attributes.label = G[i];
G[i].attributes.ancestor = null;
G[i].attributes.bucket = new List<CVDescr<VProperties>>();
}
for (i = n - 1; i >= 0; i--)
{
if (G[i] == StartVertex) continue;
var iter = this.GetInEdges(G[i]);
CEDescr<VProperties, EProperties>[] inEdges = iter.ToArray();
for (j = 0; j < inEdges.Length; j++)
{
var u = FindMin(inEdges[j].VBegin);
if (u.attributes.sdom.attributes.time < G[i].attributes.sdom.attributes.time)
{
G[i].attributes.sdom = u.attributes.sdom;
}
}
G[i].attributes.ancestor = G[i].attributes.parent;
G[i].attributes.sdom.attributes.bucket.Add(G[i]);
for (j = 0; j < G[i].attributes.parent.attributes.bucket.Count; j++)
{
var u = FindMin(G[i].attributes.parent.attributes.bucket[j]);
if (u.attributes.sdom == G[i].attributes.parent.attributes.bucket[j].attributes.sdom)
{
G[i].attributes.parent.attributes.bucket[j].idom = G[i].attributes.parent;
}
else
{
G[i].attributes.parent.attributes.bucket[j].idom = u;
}
}
G[i].attributes.parent.attributes.bucket = new List<CVDescr<VProperties>>();
}
for (i = 0; i < n; i++)
{
if (G[i] == StartVertex) continue;
if (G[i].idom != G[i].attributes.sdom)
{
G[i].idom = G[i].idom.idom;
}
}
StartVertex.idom = null;
}