expr.setBaseType(RefType
.v(PtolemyUtilities.runtimeExceptionClass));
}
} else if (value instanceof CastExpr) {
CastExpr expr = (CastExpr) value;
Type castType = expr.getCastType();
if (castType instanceof RefType
&& _isPtolemyException(((RefType) castType)
.getSootClass())) {
expr.setCastType(RefType
.v(PtolemyUtilities.runtimeExceptionClass));
}
} else if (value instanceof SpecialInvokeExpr) {
// Fix the exception constructors.
SpecialInvokeExpr expr = (SpecialInvokeExpr) value;
SootClass exceptionClass = ((RefType) expr.getBase()
.getType()).getSootClass();
if (_isPtolemyException(exceptionClass)) {
Value foundArg = null;
for (Iterator args = expr.getArgs().iterator(); args
.hasNext();) {
Value arg = (Value) args.next();
if (arg.getType().equals(
RefType.v(PtolemyUtilities.stringClass))) {
foundArg = arg;
break;
}
}
if ((foundArg == null) || _obfuscate) {
box
.setValue(Jimple
.v()
.newSpecialInvokeExpr(
(Local) expr.getBase(),
PtolemyUtilities.runtimeExceptionConstructor
.makeRef(),
Collections.EMPTY_LIST));
} else {
box
.setValue(Jimple
.v()
.newSpecialInvokeExpr(
(Local) expr.getBase(),
PtolemyUtilities.runtimeExceptionStringConstructor
.makeRef(),
foundArg));
}
}
} else if (value instanceof VirtualInvokeExpr) {
VirtualInvokeExpr expr = (VirtualInvokeExpr) value;
Type exceptionType = expr.getBase().getType();
if (exceptionType instanceof RefType) {
SootClass exceptionClass = ((RefType) exceptionType)
.getSootClass();