// Do a DFS on the graph headed by this node, giving each node its time stamp tuple // that will be used for loop structuring as well as building the structure that will // be used for traversing the nodes in linear time. The inedges are also built during // this traversal. public void SetLoopStamps(ref int time, List <StructureNode> order) { //timestamp the current node with the current time and set its traversed flag traversed = travType.DFS_LNUM; loopStamps[0] = time; //recurse on unvisited children and set inedges for all children for (int i = 0; i < OutEdges.Count; i++) { // set the in edge from this child to its parent (the current node) OutEdges[i].InEdges.Add(this); // recurse on this child if it hasn't already been visited if (OutEdges[i].traversed != travType.DFS_LNUM) { ++time; OutEdges[i].SetLoopStamps(ref time, order); } } //set the the second loopStamp value loopStamps[1] = ++time; //add this node to the ordering structure as well as recording its position within the ordering Order = order.Count; order.Add(this); }
public StructureNode(Block block, int id) { if (block == null) { throw new ArgumentNullException("block"); } this.Block = block; this.Number = id; Order = -1; traversed = travType.UNTRAVERSED; ForceLabel = false; ImmPDom = null; CaseHead = null; usType = UnstructuredType.Structured; Interval = null; //initialize the two timestamp tuples loopStamps = new int[2]; revLoopStamps = new int[2]; for (int i = 0; i < 2; i++) { loopStamps[i] = revLoopStamps[i] = -1; } BlockType = TypeOfBlock(block); }
// Do a DFS on the graph headed by this node, simply tagging the nodes visited. //$move to GraphNode. public void DfsTag() { traversed = travType.DFS_TAG; for (int i = 0; i < OutEdges.Count; i++) { if (OutEdges[i].traversed != travType.DFS_TAG) { OutEdges[i].DfsTag(); } } }