1 19 20 25 26 27 package soot.jimple.toolkits.callgraph; 28 29 import soot.*; 30 import soot.util.*; 31 import java.util.*; 32 33 34 public class TopologicalOrderer 35 { 36 CallGraph cg; 37 List order = new ArrayList(); 38 NumberedSet visited = new NumberedSet( Scene.v().getMethodNumberer() ); 39 public TopologicalOrderer( CallGraph cg ) { 40 this.cg = cg; 41 } 42 43 public void go() { 44 Iterator methods = cg.sourceMethods(); 45 while( methods.hasNext() ) { 46 SootMethod m = (SootMethod) methods.next(); 47 dfsVisit( m ); 48 } 49 } 50 51 private void dfsVisit( SootMethod m ) { 52 if( visited.contains( m ) ) return; 53 visited.add( m ); 54 Iterator targets = new Targets( cg.edgesOutOf(m) ); 55 while( targets.hasNext() ) { 56 SootMethod target = (SootMethod) targets.next(); 57 dfsVisit( target ); 58 } 59 order.add( m ); 60 } 61 62 public List order() { return order; } 63 } 64 | Popular Tags |