1 19 20 package soot.jimple.toolkits.annotation; 21 22 import soot.*; 23 import java.util.*; 24 import soot.jimple.*; 25 import soot.tagkit.*; 26 27 public class LineNumberAdder extends SceneTransformer { 28 29 public LineNumberAdder( Singletons.Global g) {} 30 public static LineNumberAdder v() { return G.v().soot_jimple_toolkits_annotation_LineNumberAdder();} 31 32 public void internalTransform(String phaseName, Map opts){ 33 34 Iterator it = Scene.v().getApplicationClasses().iterator(); 35 while (it.hasNext()){ 36 SootClass sc = (SootClass)it.next(); 37 HashMap lineToMeth = new HashMap(); 39 Iterator methIt = sc.getMethods().iterator(); 40 while (methIt.hasNext()){ 41 SootMethod meth = (SootMethod)methIt.next(); 42 if (!meth.isConcrete()) continue; 43 Body body = meth.retrieveActiveBody(); 44 Stmt s = (Stmt)body.getUnits().getFirst(); 45 while (s instanceof IdentityStmt){ 46 s = (Stmt)body.getUnits().getSuccOf(s); 47 } 48 if (s.hasTag("LineNumberTag")){ 49 LineNumberTag tag = (LineNumberTag)s.getTag("LineNumberTag"); 50 lineToMeth.put(new Integer (tag.getLineNumber()), meth); 51 } 52 } 53 Iterator methIt2 = sc.getMethods().iterator(); 54 while (methIt2.hasNext()){ 55 SootMethod meth = (SootMethod)methIt2.next(); 56 if (!meth.isConcrete()) continue; 57 Body body = meth.retrieveActiveBody(); 58 Stmt s = (Stmt)body.getUnits().getFirst(); 59 while (s instanceof IdentityStmt){ 60 s = (Stmt)body.getUnits().getSuccOf(s); 61 } 62 if (s.hasTag("LineNumberTag")){ 63 LineNumberTag tag = (LineNumberTag)s.getTag("LineNumberTag"); 64 int line_num = tag.getLineNumber() - 1; 65 if (lineToMeth.containsKey(new Integer (line_num))){ 67 meth.addTag(new LineNumberTag(line_num + 1)); 68 } 69 else { 71 meth.addTag(new LineNumberTag(line_num)); 72 } 73 } 74 } 75 76 } 77 } 78 } 79 | Popular Tags |