Fixed some analysis problems...
[repair.git] / Repair / RepairCompiler / MCC / IR / GraphNode.java
index d8d2649a939ae86c0e69adc7e0e7cc8ec9cc0c1b..8c5c119ae852ac88b875f5cef1491abca29c575f 100755 (executable)
@@ -113,6 +113,30 @@ public class GraphNode {
        }
     }
 
+    public static void boundedcomputeclosure(Collection nodes, Collection removed,int depth) {
+       Stack tovisit=new Stack();
+       Stack newvisit=new Stack();
+       tovisit.addAll(nodes);
+       for(int i=0;i<depth&&!tovisit.isEmpty();i++) {
+           while(!tovisit.isEmpty()) {
+               GraphNode gn=(GraphNode)tovisit.pop();
+               for(Iterator it=gn.edges();it.hasNext();) {
+                   Edge edge=(Edge)it.next();
+                   GraphNode target=edge.getTarget();
+                   if (!nodes.contains(target)) {
+                       if ((removed==null)||
+                           (!removed.contains(target))) {
+                           nodes.add(target);
+                           newvisit.push(target);
+                       }
+                   }
+               }
+           }
+           tovisit=newvisit;
+           newvisit=new Stack();
+       }
+    }
+
     public void setDotNodeParameters(String param) {
         if (param == null) {
             throw new NullPointerException();