Beispiel #1
0
        public static NumeratedGraph StraightOrder(this TACode code)
        {
            var graph = new NumeratedGraph(code, null);

            graph.Numerator = GraphNumerator.BackOrder(graph).Reverse(graph);
            return(graph);
        }
Beispiel #2
0
        public static GraphNumerator BackOrder(ControlFlowGraph graph)
        {
            var root    = graph.CFGNodes.ElementAt(0);
            var num     = new GraphNumerator();
            var index   = graph.CFGNodes.Count;
            var openSet = new HashSet <BasicBlock>();

            void Iter(BasicBlock node)
            {
                openSet.Add(node);
                var children = node.Children;

                foreach (var c in children.Where(x => !openSet.Contains(x)))
                {
                    Iter(c);
                }
                num._num[node] = --index;
            }

            Iter(root);
            return(num);
        }
Beispiel #3
0
 public static IGraphNumerator Reverse(this GraphNumerator n, ControlFlowGraph g)
 => new ReverseNum(g, n);