Beispiel #1
0
        public BasicBlock createNode(int name)
        {
            BasicBlock node;
            if (!basicBlockMap.ContainsKey(name))
            {
                node = new BasicBlock(name);
                basicBlockMap.Add(name, node);
            }
            else
            {
                node = basicBlockMap[name];
            }

            if (getNumNodes() == 1)
            {
                startNode = node;
            }

            return node;
        }
Beispiel #2
0
 public CFG()
 {
     startNode = null;
     basicBlockMap = new Dictionary<int, BasicBlock>();
     edgeList = new List<BasicBlockEdge>();
 }
 public void addInEdge(BasicBlock from)
 {
     inEdges.Add(from);
 }
 public void addOutEdge(BasicBlock to)
 {
     outEdges.Add(to);
 }
 // Initialize this node.
 //
 public void initNode(BasicBlock bb, int dfsNumber)
 {
     this.parent = this;
     this.bb = bb;
     this.dfsNumber = dfsNumber;
     this.loop = null;
 }
        //
        // DFS - Depth-First-Search
        //
        // DESCRIPTION:
        // Simple depth first traversal along out edges with node numbering.
        //
        int doDFS(BasicBlock currentNode,
                  UnionFindNode[] nodes,
                  Dictionary<BasicBlock, int> number,
                  int[] last,
                  /*final*/ int current)
        {
            nodes[current].initNode(currentNode, current);
            number.Add(currentNode, current);

            int lastid = current;
            // for (BasicBlock target : currentNode.getOutEdges()) {
            int len = currentNode.getOutEdges().size();
            for (int i = 0; i < len; i++)
            {
                BasicBlock target = currentNode.getOutEdges().get(i);
                if (number[target] == UNVISITED)
                {
                    lastid = doDFS(target, nodes, number, last, lastid + 1);
                }
            }
            last[number[currentNode]] = lastid;
            return lastid;
        }
 public LoopTesterApp()
 {
     cfg = new CFG();
     lsg = new LSG();
     root = cfg.createNode(0);
 }
 public void addNode(BasicBlock bb)
 {
     basicBlocks.Add(bb);
 }
 public void setHeader(BasicBlock bb)
 {
     basicBlocks.Add(bb);
     header = bb;
 }