use of soot.dava.internal.javaRep.DVirtualInvokeExpr in project soot by Sable.
the class SuperFirstStmtHandler method createCallToSuper.
/*
* super( (CAST-TYPE)handler.get(0),
* ((CAST-TYPE)handler.get(1)).CONVERSION(), .......);
*
* returns false if we cant create the call to super
*/
private boolean createCallToSuper() {
// check that whether this call is even to be made or not
if (originalConstructorExpr == null) {
// System.out.println("originalConstructorExpr is null");
return false;
}
// System.out.println("ConstructorExpr is non null...call to super has
// to be made");
// find the parent class of the current method being decompiled
SootClass parentClass = originalSootClass.getSuperclass();
// super method
if (!(parentClass.declaresMethod("<init>", argsTwoTypes))) {
// this name and ParamTypes");
return false;
}
SootMethod superConstructor = parentClass.getMethod("<init>", argsTwoTypes);
// create InstanceInvokeExpr
// need Value base: this??
// need SootMethod Ref...make sootmethoref of the super constructor
// found
// need list of thisLocals.........try empty arrayList since it doesnt
// seem to be used anywhere??
List argsForConstructor = new ArrayList();
int count = 0;
// have to make arg as "handler.get(0)"
// create new ReftType for DavaSuperHandler
RefType type = (new SootClass("DavaSuperHandler")).getType();
// make JimpleLocal to be used in each arg
// takes care of
Local jimpleLocal = new JimpleLocal("handler", type);
// handler
// make reference to a method of name get takes one int arg belongs to
// DavaSuperHandler
ArrayList tempList = new ArrayList();
tempList.add(IntType.v());
SootMethodRef getMethodRef = makeMethodRef("get", tempList);
List tempArgList = null;
Iterator typeIt = argsTwoTypes.iterator();
while (typeIt.hasNext()) {
Type tempType = (Type) typeIt.next();
// takes care
DIntConstant arg = DIntConstant.v(count, IntType.v());
// of the
// index
count++;
tempArgList = new ArrayList();
tempArgList.add(arg);
DVirtualInvokeExpr tempInvokeExpr = new DVirtualInvokeExpr(jimpleLocal, getMethodRef, tempArgList, new HashSet<Object>());
// NECESASARY CASTING OR RETRIEVAL OF PRIM TYPES TO BE DONE HERE
Value toAddExpr = getProperCasting(tempType, tempInvokeExpr);
if (toAddExpr == null)
throw new DecompilationException("UNABLE TO CREATE TOADDEXPR:" + tempType);
// the above virtualInvokeExpr is one of the args for the
// constructor
argsForConstructor.add(toAddExpr);
}
mustInitializeIndex = count;
// we are done with creating all necessary args to the virtualinvoke
// expr constructor
DVirtualInvokeExpr virtualInvoke = new DVirtualInvokeExpr(originalConstructorExpr.getBase(), superConstructor.makeRef(), argsForConstructor, new HashSet<Object>());
// set the constructors constructorExpr
newConstructorDavaBody.set_ConstructorExpr(virtualInvoke);
// create Invoke Stmt with virtualInvoke as the expression
GInvokeStmt s = new GInvokeStmt(virtualInvoke);
newConstructorDavaBody.set_ConstructorUnit(s);
// return true if super call created
return true;
}
use of soot.dava.internal.javaRep.DVirtualInvokeExpr in project soot by Sable.
the class MonitorConverter method convert.
public void convert(DavaBody body) {
for (AugmentedStmt mas : body.get_MonitorFacts()) {
MonitorStmt ms = (MonitorStmt) mas.get_Stmt();
body.addToImportList("soot.dava.toolkits.base.DavaMonitor.DavaMonitor");
ArrayList arg = new ArrayList();
arg.add(ms.getOp());
if (ms instanceof EnterMonitorStmt)
mas.set_Stmt(new GInvokeStmt(new DVirtualInvokeExpr(new DStaticInvokeExpr(v.makeRef(), new ArrayList()), enter.makeRef(), arg, new HashSet<Object>())));
else
mas.set_Stmt(new GInvokeStmt(new DVirtualInvokeExpr(new DStaticInvokeExpr(v.makeRef(), new ArrayList()), exit.makeRef(), arg, new HashSet<Object>())));
}
}
Aggregations