use of soot.toolkits.graph.MHGDominatorsFinder in project soot by Sable.
the class LoopFinder method internalTransform.
protected void internalTransform(Body b, String phaseName, Map options) {
g = new ExceptionalUnitGraph(b);
MHGDominatorsFinder a = new MHGDominatorsFinder(g);
loops = new HashMap<Stmt, List<Stmt>>();
Iterator<Unit> stmtsIt = b.getUnits().iterator();
while (stmtsIt.hasNext()) {
Stmt s = (Stmt) stmtsIt.next();
List<Unit> succs = g.getSuccsOf(s);
Collection<Unit> dominaters = (Collection<Unit>) a.getDominators(s);
ArrayList<Stmt> headers = new ArrayList<Stmt>();
Iterator<Unit> succsIt = succs.iterator();
while (succsIt.hasNext()) {
Stmt succ = (Stmt) succsIt.next();
if (dominaters.contains(succ)) {
// header succeeds and dominates s, we have a loop
headers.add(succ);
}
}
Iterator<Stmt> headersIt = headers.iterator();
while (headersIt.hasNext()) {
Stmt header = headersIt.next();
List<Stmt> loopBody = getLoopBodyFor(header, s);
// System.out.println("FOUND LOOP: Header: "+header+" Body: "+loopBody);
if (loops.containsKey(header)) {
// merge bodies
List<Stmt> lb1 = loops.get(header);
loops.put(header, union(lb1, loopBody));
} else {
loops.put(header, loopBody);
}
}
}
}
use of soot.toolkits.graph.MHGDominatorsFinder in project soot by Sable.
the class DominatorsTagger method internalTransform.
protected void internalTransform(Body b, String phaseName, Map opts) {
MHGDominatorsFinder analysis = new MHGDominatorsFinder(new ExceptionalUnitGraph(b));
Iterator it = b.getUnits().iterator();
while (it.hasNext()) {
Stmt s = (Stmt) it.next();
List dominators = analysis.getDominators(s);
Iterator dIt = dominators.iterator();
while (dIt.hasNext()) {
Stmt ds = (Stmt) dIt.next();
String info = ds + " dominates " + s;
s.addTag(new LinkTag(info, ds, b.getMethod().getDeclaringClass().getName(), "Dominators"));
}
}
}
Aggregations