1 19 20 25 26 package soot.jimple; 27 28 import soot.*; 29 import soot.toolkits.scalar.*; 30 import soot.util.*; 31 import java.util.*; 32 import java.io.*; 33 34 35 public class JimpleBody extends StmtBody 36 { 37 40 41 JimpleBody(SootMethod m) 42 { 43 super(m); 44 } 45 46 49 50 JimpleBody() 51 { 52 } 53 54 55 public Object clone() 56 { 57 Body b = new JimpleBody(getMethod()); 58 b.importBodyContentsFrom(this); 59 return b; 60 } 61 62 65 public void validate() 66 { 67 super.validate(); 68 69 73 91 } 92 93 94 public void insertIdentityStmts() 95 { 96 int i = 0; 97 98 if (!getMethod().isStatic()) 99 { 100 Local l = Jimple.v().newLocal("this", 101 RefType.v(getMethod().getDeclaringClass())); 102 getLocals().add(l); 103 getUnits().addFirst(Jimple.v().newIdentityStmt(l, Jimple.v().newThisRef((RefType)l.getType()))); 104 } 105 106 Iterator parIt = getMethod().getParameterTypes().iterator(); 107 while (parIt.hasNext()) 108 { 109 Type t = (Type)parIt.next(); 110 Local l = Jimple.v().newLocal("parameter"+i, t); 111 getLocals().add(l); 112 getUnits().addFirst(Jimple.v().newIdentityStmt(l, Jimple.v().newParameterRef(l.getType(), i))); 113 i++; 114 } 115 } 116 117 118 public Stmt getFirstNonIdentityStmt() 119 { 120 Iterator it = getUnits().iterator(); 121 Object o = null; 122 while (it.hasNext()) 123 if (!((o = it.next()) instanceof IdentityStmt)) 124 break; 125 if (o == null) 126 throw new RuntimeException ("no non-id statements!"); 127 return (Stmt)o; 128 } 129 } 130 131 132 133 | Popular Tags |