1 19 20 25 26 27 package soot.toolkits.graph; 28 29 import soot.*; 30 import soot.util.*; 31 import java.util.*; 32 import soot.options.Options; 33 34 35 78 public class TrapUnitGraph extends UnitGraph 79 { 80 84 public TrapUnitGraph(Body body) 85 { 86 super(body); 87 int size = unitChain.size(); 88 89 if(Options.v().time()) 90 Timers.v().graphTimer.start(); 91 92 unitToSuccs = new HashMap(size * 2 + 1, 0.7f); 93 unitToPreds = new HashMap(size * 2 + 1, 0.7f); 94 buildUnexceptionalEdges(unitToSuccs, unitToPreds); 95 buildExceptionalEdges(unitToSuccs, unitToPreds); 96 makeMappedListsUnmodifiable(unitToSuccs); 97 makeMappedListsUnmodifiable(unitToPreds); 98 99 buildHeadsAndTails(); 100 101 if(Options.v().time()) 102 Timers.v().graphTimer.end(); 103 104 soot.util.PhaseDumper.v().dumpGraph(this, body); 105 } 106 107 108 128 protected void buildExceptionalEdges(Map unitToSuccs, Map unitToPreds) { 129 for (Iterator trapIt = body.getTraps().iterator(); 130 trapIt.hasNext(); ) { 131 Trap trap = (Trap) trapIt.next(); 132 Unit first = trap.getBeginUnit(); 133 Unit last = (Unit) unitChain.getPredOf(trap.getEndUnit()); 134 Unit catcher = trap.getHandlerUnit(); 135 for (Iterator unitIt = unitChain.iterator(first, last); 136 unitIt.hasNext(); ) { 137 Unit trapped = (Unit) unitIt.next(); 138 addEdge(unitToSuccs, unitToPreds, trapped, catcher); 139 } 140 } 141 } 142 } 143 | Popular Tags |