1 19 20 25 26 27 package soot.jimple.toolkits.scalar.pre; 28 import soot.jimple.toolkits.graph.*; 29 import soot.toolkits.graph.*; 30 import soot.jimple.*; 31 import soot.*; 32 import java.util.*; 33 34 38 public class SootFilter { 39 40 47 public static EquivalentValue equiVal(Value val) { 48 if (val == null) return null; 49 return new EquivalentValue(val); 50 } 51 52 59 public static Value rhs(Unit unit) { 60 if (unit instanceof AssignStmt) 61 return ((AssignStmt)unit).getRightOp(); 62 else 63 return null; 64 } 65 66 73 public static Value binop(Value val) { 74 if (val == null) return null; 75 if (val instanceof BinopExpr) return val; 76 return null; 77 } 78 79 87 public static Value binopRhs(Unit unit) { 88 return binop(rhs(unit)); 89 } 90 91 100 public static Value concreteRef(Value val) { 101 if (val == null) return null; 102 if (val instanceof ConcreteRef) return val; 103 return null; 104 } 105 106 115 public static Value noExceptionThrowing(Value val) { 116 if (val == null) return null; 117 if (!throwsException(val)) 118 return val; 119 else 120 return null; 121 } 122 123 130 public static Value noExceptionThrowingRhs(Unit unit) { 131 return noExceptionThrowing(rhs(unit)); 132 } 133 134 141 public static Value noInvokeRhs(Unit unit) { 142 return noInvoke(rhs(unit)); 143 } 144 145 153 public static Value noInvoke(Value val) { 154 if (val == null || isInvoke(val)) 155 return null; 156 else 157 return val; 158 } 159 160 166 public static boolean isInvoke(Value val) { 167 val = getEquivalentValueRoot(val); 168 if (val instanceof InvokeExpr) 169 return true; 170 return false; 171 } 172 173 180 public static Value local(Value val) { 181 if (val != null && isLocal(val)) 182 return val; 183 else 184 return null; 185 } 186 187 194 public static Value noLocal(Value val) { 195 if (val != null && !isLocal(val)) 196 return val; 197 else 198 return null; 199 } 200 201 204 public static boolean isLocal(Value val) { 205 return (getEquivalentValueRoot(val) instanceof Local); 206 } 207 208 217 public static Value getEquivalentValueRoot(Value val) { 218 if (val == null) return null; 219 221 while (val instanceof EquivalentValue) 222 val = ((EquivalentValue)val).getValue(); 223 return val; 224 } 225 226 230 public static boolean throwsException(Value val) { 231 val = getEquivalentValueRoot(val); 232 233 234 if (val instanceof BinopExpr || 235 val instanceof UnopExpr || 236 val instanceof Local || 237 val instanceof Constant) { 238 if (val instanceof DivExpr || 239 val instanceof RemExpr || 240 val instanceof LengthExpr) 241 return true; 242 return false; 243 } 244 return true; 245 } 246 } 247 | Popular Tags |