1 19 20 package soot.shimple; 21 22 import soot.*; 23 import soot.util.*; 24 import java.util.*; 25 import soot.shimple.*; 26 import soot.shimple.internal.*; 27 import soot.shimple.toolkits.scalar.*; 28 import soot.shimple.toolkits.graph.*; 29 import soot.options.*; 30 import soot.jimple.*; 31 import soot.jimple.internal.*; 32 import soot.jimple.toolkits.base.*; 33 import soot.jimple.toolkits.callgraph.*; 34 import soot.jimple.toolkits.pointer.*; 35 import soot.jimple.toolkits.scalar.*; 36 import soot.toolkits.graph.*; 37 import soot.toolkits.scalar.*; 38 39 42 public class DefaultShimpleFactory implements ShimpleFactory 43 { 44 protected Body body; 45 protected BlockGraph bg; 46 protected UnitGraph ug; 47 protected DominatorsFinder dFinder; 48 protected DominatorTree dTree; 49 protected DominanceFrontier dFrontier; 50 protected PointsToAnalysis pta; 51 protected CallGraph cg; 52 protected SideEffectAnalysis sea; 53 protected GlobalValueNumberer gvn; 54 55 protected ReversibleGraph rbg; 56 protected DominatorTree rdTree; 57 protected DominanceFrontier rdFrontier; 58 protected DominatorsFinder rdFinder; 59 60 public DefaultShimpleFactory() 61 { 62 } 63 64 public void clearCache() 65 { 66 bg = null; 67 ug = null; 68 dFinder = null; 69 dTree = null; 70 dFrontier = null; 71 pta = null; 72 cg = null; 73 sea = null; 74 gvn = null; 75 rbg = null; 76 rdTree = null; 77 rdFinder = null; 78 rdFrontier = null; 79 } 80 81 public void setBody(Body body) 82 { 83 this.body = body; 84 clearCache(); 85 } 86 87 public Body getBody() 88 { 89 if(body == null) 90 throw new RuntimeException ("Assertion failed: Call setBody() first."); 91 92 return body; 93 } 94 95 public ReversibleGraph getReverseBlockGraph() 96 { 97 if(rbg != null) 98 return rbg; 99 100 BlockGraph bg = getBlockGraph(); 101 rbg = new HashReversibleGraph(bg); 102 rbg.reverse(); 103 return rbg; 104 } 105 106 public DominatorsFinder getReverseDominatorsFinder() 107 { 108 if(rdFinder != null) 109 return rdFinder; 110 111 rdFinder = new SimpleDominatorsFinder(getReverseBlockGraph()); 112 return rdFinder; 113 } 114 115 public DominatorTree getReverseDominatorTree() 116 { 117 if(rdTree != null) 118 return rdTree; 119 120 rdTree = new DominatorTree(getReverseDominatorsFinder()); 121 return rdTree; 122 } 123 124 public DominanceFrontier getReverseDominanceFrontier() 125 { 126 if(rdFrontier != null) 127 return rdFrontier; 128 129 rdFrontier = new CytronDominanceFrontier(getReverseDominatorTree()); 130 return rdFrontier; 131 } 132 133 public BlockGraph getBlockGraph() 134 { 135 if(bg != null) 136 return bg; 137 138 bg = new ExceptionalBlockGraph((ExceptionalUnitGraph)getUnitGraph()); 139 BlockGraphConverter.addStartStopNodesTo(bg); 140 return bg; 141 } 142 143 public UnitGraph getUnitGraph() 144 { 145 if(ug != null) 146 return ug; 147 148 ug = new ExceptionalUnitGraph(getBody()); 149 return ug; 150 } 151 152 public DominatorsFinder getDominatorsFinder() 153 { 154 if(dFinder != null) 155 return dFinder; 156 157 dFinder = new SimpleDominatorsFinder(getBlockGraph()); 158 return dFinder; 159 } 160 161 public DominatorTree getDominatorTree() 162 { 163 if(dTree != null) 164 return dTree; 165 166 dTree = new DominatorTree(getDominatorsFinder()); 167 return dTree; 168 } 169 170 public DominanceFrontier getDominanceFrontier() 171 { 172 if(dFrontier != null) 173 return dFrontier; 174 175 dFrontier = new CytronDominanceFrontier(getDominatorTree()); 176 return dFrontier; 177 } 178 179 public GlobalValueNumberer getGlobalValueNumberer() 180 { 181 if(gvn != null) 182 return gvn; 183 184 gvn = new SimpleGlobalValueNumberer(getBlockGraph()); 185 return gvn; 186 } 187 } 188 | Popular Tags |