/** * Constructs a NewVirtualInvokeExpr(Local base, SootMethodRef method, List of Immediate) grammar chunk. */ public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method, Value... args) { return newVirtualInvokeExpr(base, method, Arrays.asList(args)); }
public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method, Value arg) { return newVirtualInvokeExpr(base, method, Collections.<Value>singletonList(arg)); }
public VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method) { return newVirtualInvokeExpr(base, method, Collections.<Value>emptyList()); }
public soot.jimple.VirtualInvokeExpr newVirtualInvokeExpr(Local base, SootMethodRef method, java.util.List args, ASTNode location) { soot.jimple.VirtualInvokeExpr expr = Jimple.v().newVirtualInvokeExpr(base, method, args); createTag(expr, location); for(int i = 0; i < args.size(); i++) { soot.tagkit.Tag tag = getTag((Value)args.get(i)); if(tag != null) expr.getArgBox(i).addTag(tag); } return expr; }
public void outANonstaticInvokeExpr(ANonstaticInvokeExpr node) { List args; if (node.getArgList() != null) { args = (List) mProductions.removeLast(); } else { args = new ArrayList(); } SootMethodRef method = (SootMethodRef) mProductions.removeLast(); String local = (String) mProductions.removeLast(); Local l = mLocals.get(local); if (l == null) { throw new RuntimeException("did not find local: " + local); } Node invokeType = node.getNonstaticInvoke(); Expr invokeExpr; if (invokeType instanceof ASpecialNonstaticInvoke) { invokeExpr = Jimple.v().newSpecialInvokeExpr(l, method, args); } else if (invokeType instanceof AVirtualNonstaticInvoke) { invokeExpr = Jimple.v().newVirtualInvokeExpr(l, method, args); } else { if (debug) { if (!(invokeType instanceof AInterfaceNonstaticInvoke)) { throw new RuntimeException("expected interface invoke."); } } invokeExpr = Jimple.v().newInterfaceInvokeExpr(l, method, args); } mProductions.addLast(invokeExpr); }
/** Executes the "jimplify" operation for a virtual invocation */ protected void jimplifyVirtual(DexBody body) { // In some applications, InterfaceInvokes are disguised as VirtualInvokes. // We fix this silently SootMethodRef ref = getVirtualSootMethodRef(); if (ref.declaringClass().isInterface()) { jimplifyInterface(body); return; } // This is actually a VirtualInvoke MethodReference item = (MethodReference) ((ReferenceInstruction) instruction).getReference(); List<Local> parameters = buildParameters(body, item.getParameterTypes(), false); invocation = Jimple.v().newVirtualInvokeExpr(parameters.get(0), ref, parameters.subList(1, parameters.size())); body.setDanglingInstruction(this); }
/** * p unbox = fromLocal.pValue(); * * @param fromLocal * boxed * @param jb * @param us * @return */ private Local unbox(Local fromLocal, JimpleBody jb, PatchingChain<Unit> us, LocalGenerator lc) { RefType wrapperType = (RefType) fromLocal.getType(); PrimType primitiveType = wrapper.wrapperTypes.get(wrapperType); SootMethod primitiveValueMethod = wrapper.primitiveValue.get(wrapperType); Local lUnbox = lc.generateLocal(primitiveType); us.add(Jimple.v().newAssignStmt(lUnbox, Jimple.v().newVirtualInvokeExpr(fromLocal, primitiveValueMethod.makeRef()))); return lUnbox; }
private soot.Local createToString(soot.Local sb, polyglot.ast.Expr expr) { // invoke toString on local (type StringBuffer) soot.Local newString = lg.generateLocal(soot.RefType.v("java.lang.String")); soot.SootClass classToInvoke2 = soot.Scene.v().getSootClass("java.lang.StringBuffer"); soot.SootMethodRef methodToInvoke2 = soot.Scene.v().makeMethodRef(classToInvoke2, "toString", new ArrayList(), soot.RefType.v("java.lang.String"), false); soot.jimple.VirtualInvokeExpr toStringInvoke = soot.jimple.Jimple.v().newVirtualInvokeExpr(sb, methodToInvoke2); soot.jimple.Stmt lastAssign = soot.jimple.Jimple.v().newAssignStmt(newString, toStringInvoke); body.getUnits().add(lastAssign); Util.addLnPosTags(lastAssign, expr.position()); return newString; }
invocation = Jimple.v().newInterfaceInvokeExpr(invoker, ref, parms); } else { invocation = Jimple.v().newVirtualInvokeExpr(invoker, ref, parms);
Local thisLocal = (Local) arguments.get(0); arguments.remove(0); accExpr = Jimple.v().newVirtualInvokeExpr(thisLocal, method.makeRef(), arguments); } else if (expr instanceof SpecialInvokeExpr) { Local thisLocal = (Local) arguments.get(0);
VirtualInvokeExpr printStackTraceExpr = Jimple.v().newVirtualInvokeExpr(exceptionLocal, Scene.v() .getSootClass("java.lang.Throwable").getMethod("printStackTrace", Collections.<Type>emptyList()).makeRef()); InvokeStmt printStackTraceStmt = Jimple.v().newInvokeStmt(printStackTraceExpr);
private void insertCastOrUnboxingCode(Local lhs, Local rhs, Chain<Unit> newUnits) { // if assigning to a reference type then there's nothing to do if (lhs.getType() instanceof PrimType) { if ((rhs.getType() instanceof PrimType)) { // insert cast newUnits.add(Jimple.v().newAssignStmt(lhs, Jimple.v().newCastExpr(rhs, lhs.getType()))); } else { // reference type in rhs; insert unboxing code RefType boxedType = (RefType) rhs.getType(); SootMethodRef ref = Scene.v().makeMethodRef(boxedType.getSootClass(), lhs.getType().toString() + "Value", Collections.<Type>emptyList(), lhs.getType(), false); newUnits.add(Jimple.v().newAssignStmt(lhs, Jimple.v().newVirtualInvokeExpr(rhs, ref))); } } }
return Jimple.v().newInterfaceInvokeExpr(args.get(0), methodRef, rest(args)); case REF_INVOKE_VIRTUAL: return Jimple.v().newVirtualInvokeExpr(args.get(0), methodRef, rest(args)); case REF_INVOKE_SPECIAL: final SootClass currentClass = jb.getMethod().getDeclaringClass(); m.setModifiers(mod); return Jimple.v().newVirtualInvokeExpr(args.get(0), methodRef, rest(args));
list.add(Jimple.v().newInvokeStmt(Jimple.v().newVirtualInvokeExpr(tmpRef, toCall.makeRef(), StringConstant.v("Executing supposedly unreachable method:")))); list.add(Jimple.v().newInvokeStmt(Jimple.v().newVirtualInvokeExpr(tmpRef, toCall.makeRef(), StringConstant.v("\t" + method.getDeclaringClass().getName() + "." + method.getName()))));
invoke = soot.jimple.Jimple.v().newInterfaceInvokeExpr(baseLocal, methToCall, params); } else { invoke = soot.jimple.Jimple.v().newVirtualInvokeExpr(baseLocal, methToCall, params);
soot.RefType.v("java.lang.StringBuffer"), false); soot.jimple.VirtualInvokeExpr appendInvoke = soot.jimple.Jimple.v().newVirtualInvokeExpr(sb, methodToInvoke, params);
= soot.jimple.Jimple.v().newVirtualInvokeExpr(catchRefLocal, messageMethToInvoke, new ArrayList()); soot.jimple.Stmt messageAssign = soot.jimple.Jimple.v().newAssignStmt(messageLocal, messageInvoke); classBody.getUnits().add(messageAssign);
= soot.jimple.Jimple.v().newVirtualInvokeExpr(noClassDefLocal, messageMethToInvoke, params); soot.jimple.Stmt messageAssign = soot.jimple.Jimple.v().newAssignStmt(throwLocal, messageInvoke); classBody.getUnits().add(messageAssign);
AssignStmt cast = Jimple.v().newAssignStmt(castedLocal, Jimple.v().newCastExpr(boxedLocal, boxedType)); newUnits.add(cast); VirtualInvokeExpr unboxInvokeExpr = Jimple.v().newVirtualInvokeExpr(castedLocal, ref); assignStmt = Jimple.v().newAssignStmt(paramLocals[paramIndex], unboxInvokeExpr); } else {
"desiredAssertionStatus", new ArrayList(), soot.BooleanType.v(), false); soot.jimple.VirtualInvokeExpr vInvoke = soot.jimple.Jimple.v().newVirtualInvokeExpr(invokeLocal, vMethodToInvoke, new ArrayList());