public void visitStatementList(StatementList sl) { if (sl.Count() > 0) { // use this to determine if we need to link the node succeeding // this statement list to be linked to it bool link = true; Node linkNode; // the basic block representing the current point in the statement list CFGBasicBlock slbb = new CFGBasicBlock(); linkNode = slbb; // add this basic block as the child to the current node // and then set it as the current node this.currentNode.add(slbb); this.currentNode = slbb; for (int i = 0; i < sl.Count(); i++) { // if this statement list has been broken // create a new basic block and link it if (this.currentNode != slbb) { // do not link this block to the successer of the statement list link = false; // if there are more statements to come CFGBasicBlock bb = new CFGBasicBlock(); // we've just exited out of some kind of branch, make this new block a child of it this.currentNode.add(bb); // now make this new block a child of the original statement list slbb.add(bb); // now the new block becomes the representative statement list slbb = bb; this.currentNode = bb; // why does this work????? clearLinkNodes(); } // handle the next statement Node nextStatement = sl.get(i); if (nextStatement.GetType() == typeof(While)) { // a while statement needs a basic block of its own CFGBasicBlock bb = new CFGBasicBlock(); this.currentNode.add(bb); slbb = bb; this.currentNode = slbb; } sl.get(i).accept(this); } if (link == true) { linkNodes.Add(linkNode); } } }