public Local getParam(int i) { return body.getParameterLocal(i); }
retStmts.add(ret); retStmts.add(Jimple.v().newReturnStmt(retLocal)); Value cond = Jimple.v().newEqExpr(body.getParameterLocal(0), IntConstant.v(i)); body.getUnits().add(Jimple.v().newIfStmt(cond, ret)); Unit asn = Jimple.v().newAssignStmt( Jimple.v().newInstanceFieldRef(body.getThisLocal(), arrFields[i].makeRef()), body.getParameterLocal(1)); updates.add(asn); updates.add(Jimple.v().newReturnVoidStmt()); Value cond = Jimple.v().newEqExpr(body.getParameterLocal(0), IntConstant.v(i)); body.getUnits().add(Jimple.v().newIfStmt(cond, asn)); Unit asn = Jimple.v().newAssignStmt( Jimple.v().newInstanceFieldRef(body.getThisLocal(), elemField.makeRef()), body.getParameterLocal(1)); body.getUnits().add(asn); body.getParameterLocal(0));
private void handleFinalLocalInits() { ArrayList<SootField> finalsList = ((PolyglotMethodSource) body.getMethod().getSource()).getFinalsList(); if (finalsList == null) { return; } int paramCount = paramRefCount - finalsList.size(); Iterator<SootField> it = finalsList.iterator(); while (it.hasNext()) { soot.SootField sf = it.next(); soot.jimple.FieldRef fieldRef = soot.jimple.Jimple.v().newInstanceFieldRef(specialThisLocal, sf.makeRef()); soot.jimple.AssignStmt stmt = soot.jimple.Jimple.v().newAssignStmt(fieldRef, body.getParameterLocal(paramCount)); body.getUnits().add(stmt); paramCount++; } }
InstanceFieldRef fieldRef = Jimple.v().newInstanceFieldRef(body.getParameterLocal(m.getParameterCount() - 1), Scene.v().makeFieldRef(c, ALREADY_CHECKED_FIELDNAME, BooleanType.v(), false)); Local alreadyCheckedLocal = localGen.generateLocal(BooleanType.v()); InstanceFieldRef fieldRef2 = Jimple.v().newInstanceFieldRef(body.getParameterLocal(m.getParameterCount() - 1), Scene.v().makeFieldRef(c, ALREADY_CHECKED_FIELDNAME, BooleanType.v(), false)); newUnits.add(Jimple.v().newAssignStmt(fieldRef2, IntConstant.v(1)));
intentLocal = body.getParameterLocal(0); localVarsForClasses.put(intentClass, intentLocal);
body.getUnits().add(Jimple.v().newAssignStmt(counter, IntConstant.v(0))); Stmt loopHead = Jimple.v().newIfStmt(Jimple.v().newGeExpr(counter, body.getParameterLocal(0)), returnStmt); body.getUnits().add(loopHead); List<Value> elConstructorArgs = new LinkedList<Value>(); for (int k=1; k<constructor.getParameterCount();k++) { elConstructorArgs.add(body.getParameterLocal(k));
/** * Creates an implementation of setResult() that writes the given intent into * the correct field */ private void createSetResultMethod() { // We need to create an implementation of "getIntent". If there is already such // an implementation, we don't touch it. if (component.declaresMethod("void setResult(int,android.content.Intent)")) return; Type intentType = RefType.v("android.content.Intent"); List<Type> params = new ArrayList<>(); params.add(IntType.v()); params.add(intentType); SootMethod sm = Scene.v().makeSootMethod("setResult", params, VoidType.v(), Modifier.PUBLIC); component.addMethod(sm); sm.addTag(SimulatedCodeElementTag.TAG); JimpleBody b = Jimple.v().newBody(sm); sm.setActiveBody(b); b.insertIdentityStmts(); Local lcIntent = b.getParameterLocal(1); b.getUnits().add(Jimple.v().newAssignStmt( Jimple.v().newInstanceFieldRef(b.getThisLocal(), resultIntentField.makeRef()), lcIntent)); b.getUnits().add(Jimple.v().newReturnVoidStmt()); // Activity.setResult() is final. We need to change that SootMethod smSetResult = Scene.v() .grabMethod("<android.app.Activity: void setResult(int,android.content.Intent)>"); if (smSetResult != null && smSetResult.getDeclaringClass().isApplicationClass()) smSetResult.setModifiers(smSetResult.getModifiers() & ~Modifier.FINAL); }
/** * Creates an implementation of setIntent() that writes the given intent into * the correct field */ private void createSetIntentMethod() { // We need to create an implementation of "getIntent". If there is already such // an implementation, we don't touch it. if (component.declaresMethod("void setIntent(android.content.Intent)")) return; Type intentType = RefType.v("android.content.Intent"); SootMethod sm = Scene.v().makeSootMethod("setIntent", Collections.singletonList(intentType), VoidType.v(), Modifier.PUBLIC); component.addMethod(sm); sm.addTag(SimulatedCodeElementTag.TAG); JimpleBody b = Jimple.v().newBody(sm); sm.setActiveBody(b); b.insertIdentityStmts(); Local lcIntent = b.getParameterLocal(0); b.getUnits().add(Jimple.v() .newAssignStmt(Jimple.v().newInstanceFieldRef(b.getThisLocal(), intentField.makeRef()), lcIntent)); b.getUnits().add(Jimple.v().newReturnVoidStmt()); }
final Local binderLocal = b.getParameterLocal(0); final Local binderLocal = b.getParameterLocal(0);