1 19 20 package soot.toolkits.exceptions; 21 22 import soot.AnySubType; 23 import soot.G; 24 import soot.RefType; 25 import soot.Type; 26 import soot.Unit; 27 import soot.UnknownType; 28 import soot.NullType; 29 import soot.Value; 30 import soot.Singletons; 31 import soot.toolkits.exceptions.*; 32 import soot.baf.ThrowInst; 33 import soot.grimp.NewInvokeExpr; 34 import soot.jimple.ThrowStmt; 35 36 46 public abstract class AbstractThrowAnalysis implements ThrowAnalysis { 47 48 abstract public ThrowableSet mightThrow(Unit u); 49 50 51 public ThrowableSet mightThrowExplicitly(ThrowInst t) { 52 return ThrowableSet.Manager.v().ALL_THROWABLES; 54 } 55 56 57 public ThrowableSet mightThrowExplicitly(ThrowStmt t) { 58 Value thrownExpression = t.getOp(); 59 Type thrownType = thrownExpression.getType(); 60 if (thrownType == null || thrownType instanceof UnknownType) { 61 return ThrowableSet.Manager.v().ALL_THROWABLES; 63 } else if (thrownType instanceof NullType) { 64 ThrowableSet result = ThrowableSet.Manager.v().EMPTY; 65 result = result.add(ThrowableSet.Manager.v().NULL_POINTER_EXCEPTION); 66 return result; 67 } else if (! (thrownType instanceof RefType)) { 68 throw new IllegalStateException ("UnitThrowAnalysis StmtSwitch: type of throw argument is not a RefType!"); 69 } else { 70 ThrowableSet result = ThrowableSet.Manager.v().EMPTY; 71 if (thrownExpression instanceof NewInvokeExpr) { 72 result = result.add((RefType) thrownType); 75 } else { 76 result = result.add(AnySubType.v((RefType) thrownType)); 77 } 78 return result; 79 } 80 } 81 82 83 abstract public ThrowableSet mightThrowImplicitly(ThrowInst t); 84 85 86 abstract public ThrowableSet mightThrowImplicitly(ThrowStmt t); 87 } 88 89 | Popular Tags |