Esempio n. 1
0
        // Constructor from CFGraph
        public DepthSpanningTree(CFGraph cfg)
        {
            visited = new HashSet <CFGNode>();
            Tree    = new BidirectionalGraph <CFGNode, Edge <CFGNode> >();
            Numbers = new Dictionary <CFGNode, int>();

            var root  = cfg.GetRoot();
            int start = 0;

            BuildTree(root, ref start);
        }
Esempio n. 2
0
        public DepthSpanningTree(CFGraph cfg)
        {
            int numberOfVertices = cfg.NumberOfVertices() - 1;

            visited      = new HashSet <CFGNode>();
            SpanningTree = new BidirectionalGraph <CFGNode, Edge <CFGNode> >();
            Numbers      = new Dictionary <CFGNode, int>();

            var root = cfg.GetRoot();

            BuildTree(root, ref numberOfVertices);
        }
Esempio n. 3
0
        public static CFGraph Build(List <IBaseBlock> blocks)
        {
            CFGNode root        = new CFGNode(blocks.First());
            var     currentNode = root;

            foreach (var block in blocks.Skip(1))
            {
                var directChild = new CFGNode(block);
                currentNode.SetDirectChild(directChild);

                var lastOp = currentNode.Value.Enumerate().Last();
                if (lastOp.IsGoto())
                {
                    var gotoBlock = blocks.First(b => b.Enumerate().First().Label.Equals(lastOp.Destination));
                    var gotoChild = new CFGNode(gotoBlock);
                    currentNode.SetGotoChild(gotoChild);
                }
                currentNode = directChild;
            }

            var graph = new CFGraph(blocks);

            return(graph);
        }
Esempio n. 4
0
 public NaturalCycleGraph(CFGraph cfg)
 {
     this.cfGraph = cfg;
 }