1 19 20 package soot.jimple.toolkits.callgraph; 21 22 import soot.*; 23 import soot.util.*; 24 import java.util.*; 25 import soot.jimple.*; 26 import soot.toolkits.graph.*; 27 import soot.toolkits.scalar.*; 28 29 public class ClinitElimAnalysis extends ForwardFlowAnalysis { 30 31 private UnitGraph g; 32 33 public ClinitElimAnalysis(UnitGraph g) { 34 super(g); 35 this.g = g; 36 37 doAnalysis(); 38 } 39 40 public void merge(Object in1, Object in2, Object out) { 41 42 FlowSet inSet1 = (FlowSet) in1; 43 FlowSet inSet2 = (FlowSet) in2; 44 FlowSet outSet = (FlowSet) out; 45 46 inSet1.intersection(inSet2, outSet); 47 } 48 49 public void copy(Object src, Object dest) { 50 51 FlowSet srcIn = (FlowSet) src; 52 FlowSet destOut = (FlowSet) dest; 53 54 srcIn.copy(destOut); 55 } 56 57 58 protected void flowThrough(Object inVal, Object stmt, Object outVal) { 60 FlowSet in = (FlowSet) inVal; 61 FlowSet out = (FlowSet) outVal; 62 Stmt s = (Stmt) stmt; 63 64 in.copy(out); 65 66 CallGraph cg = Scene.v().getCallGraph(); 67 68 Iterator edges = cg.edgesOutOf(s); 69 70 while (edges.hasNext()){ 71 Edge e = (Edge)edges.next(); 72 if (e.isClinit()) { 73 out.add(e.tgt()); 74 } 75 } 76 } 77 78 protected Object entryInitialFlow(){ 79 80 return new ArraySparseSet(); 81 82 83 } 84 85 protected Object newInitialFlow(){ 86 ArraySparseSet set = new ArraySparseSet(); 87 CallGraph cg = Scene.v().getCallGraph(); 88 89 Iterator mIt = cg.edgesOutOf(g.getBody().getMethod()); 90 while (mIt.hasNext()){ 91 Edge edge = (Edge)mIt.next(); 92 if (edge.isClinit()){ 93 set.add(edge.tgt()); 94 } 95 } 96 97 return set; 98 } 99 } 100 | Popular Tags |