public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method, Value... args) { return newStaticInvokeExpr(method, Arrays.asList(args)); }
public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method) { return newStaticInvokeExpr(method, Collections.<Value>emptyList()); }
public StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method, Value arg) { return newStaticInvokeExpr(method, Collections.singletonList(arg)); }
public soot.jimple.StaticInvokeExpr newStaticInvokeExpr(SootMethodRef method, java.util.List args, ASTNode location) { soot.jimple.StaticInvokeExpr expr = Jimple.v().newStaticInvokeExpr(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 outAStaticInvokeExpr(AStaticInvokeExpr node) { List args; if (node.getArgList() != null) { args = (List) mProductions.removeLast(); } else { args = new ArrayList(); } SootMethodRef method = (SootMethodRef) mProductions.removeLast(); method = Scene.v().makeMethodRef(method.declaringClass(), method.name(), method.parameterTypes(), method.returnType(), true); mProductions.addLast(Jimple.v().newStaticInvokeExpr(method, args)); }
/** * P box = P.valueOf(fromLocal); * * @param fromLocal * primitive * @param jb * @param us * @return */ private Local box(Local fromLocal, JimpleBody jb, PatchingChain<Unit> us, LocalGenerator lc) { PrimType primitiveType = (PrimType) fromLocal.getType(); RefType wrapperType = primitiveType.boxedType(); SootMethod valueOfMethod = wrapper.valueOf.get(primitiveType); Local lBox = lc.generateLocal(wrapperType); if (lBox == null || valueOfMethod == null || us == null) { throw new NullPointerException(String.format("%s,%s,%s,%s", valueOfMethod, primitiveType, wrapper.valueOf.entrySet(), wrapper.valueOf.get(primitiveType))); } us.add(Jimple.v().newAssignStmt(lBox, Jimple.v().newStaticInvokeExpr(valueOfMethod.makeRef(), fromLocal))); return lBox; }
public Value createJimpleConstantValue(cp_info[] constant_pool) { CONSTANT_Class_info cc = (CONSTANT_Class_info) (constant_pool[class_index]); CONSTANT_NameAndType_info cn = (CONSTANT_NameAndType_info) (constant_pool[name_and_type_index]); String className = cc.toString(constant_pool); String nameAndType = cn.toString(constant_pool); String name = nameAndType.substring(0, nameAndType.indexOf(":")); String typeName = nameAndType.substring(nameAndType.indexOf(":") + 1); List parameterTypes; Type returnType; // Generate parameters & returnType & parameterTypes { Type[] types = Util.v().jimpleTypesOfFieldOrMethodDescriptor(typeName); parameterTypes = new ArrayList(); for (int k = 0; k < types.length - 1; k++) { parameterTypes.add(types[k]); } returnType = types[types.length - 1]; } return Jimple.v().newStaticInvokeExpr( Scene.v().makeMethodRef(Scene.v().getSootClass(className), name, parameterTypes, returnType, true)); }
/** Executes the "jimplify" operation for a static invocation */ protected void jimplifyStatic(DexBody body) { MethodReference item = (MethodReference) ((ReferenceInstruction) instruction).getReference(); invocation = Jimple.v().newStaticInvokeExpr(getStaticSootMethodRef(), buildParameters(body, item.getParameterTypes(), true)); body.setDanglingInstruction(this); }
public static soot.Local getPrivateAccessFieldInvoke(soot.SootMethodRef toInvoke, ArrayList params, soot.Body body, LocalGenerator lg) { soot.jimple.InvokeExpr invoke = soot.jimple.Jimple.v().newStaticInvokeExpr(toInvoke, params); soot.Local retLocal = lg.generateLocal(toInvoke.returnType()); soot.jimple.AssignStmt stmt = soot.jimple.Jimple.v().newAssignStmt(retLocal, invoke); body.getUnits().add(stmt); return retLocal; }
@Override protected soot.Local handlePrivateFieldSet(polyglot.ast.Expr expr, soot.Value right, soot.Value base) { // in normal j2j its always a field (and checked before call) // only has an expr for param for extensibility polyglot.ast.Field fLeft = (polyglot.ast.Field) expr; soot.SootClass containClass = ((soot.RefType) Util.getSootType(fLeft.target().type())).getSootClass(); soot.SootMethod methToUse = addSetAccessMeth(containClass, fLeft, right); ArrayList params = new ArrayList(); if (!fLeft.flags().isStatic()) { // this is the this ref if needed // params.add(getThis(Util.getSootType(fLeft.target().type()))); params.add(base); } params.add(right); soot.jimple.InvokeExpr invoke = soot.jimple.Jimple.v().newStaticInvokeExpr(methToUse.makeRef(), params); soot.Local retLocal = lg.generateLocal(right.getType()); soot.jimple.AssignStmt assignStmt = soot.jimple.Jimple.v().newAssignStmt(retLocal, invoke); body.getUnits().add(assignStmt); return retLocal; }
units.addFirst(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(reset.makeRef()))); units.insertBefore(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(report.makeRef())), stmt); units.insertBefore(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(report.makeRef())), stmt);
private void insertCastOrBoxingCode(Local lhs, Local rhs, Chain<Unit> newUnits) { // if assigning to a primitive type then there's nothing to do if (lhs.getType() instanceof RefLikeType) { if ((rhs.getType() instanceof RefLikeType)) { // insert cast newUnits.add(Jimple.v().newAssignStmt(lhs, Jimple.v().newCastExpr(rhs, lhs.getType()))); } else { // primitive type in rhs; insert boxing code RefType boxedType = ((PrimType) rhs.getType()).boxedType(); SootMethodRef ref = Scene.v().makeMethodRef(boxedType.getSootClass(), "valueOf", Collections.<Type>singletonList(rhs.getType()), boxedType, true); newUnits.add(Jimple.v().newAssignStmt(lhs, Jimple.v().newStaticInvokeExpr(ref, rhs))); } } }
private soot.Local getSpecialSuperQualifierLocal(polyglot.ast.Expr expr) { soot.SootClass classToInvoke; ArrayList methodParams = new ArrayList(); if (expr instanceof polyglot.ast.Call) { polyglot.ast.Special target = (polyglot.ast.Special) ((polyglot.ast.Call) expr).target(); classToInvoke = ((soot.RefType) Util.getSootType(target.qualifier().type())).getSootClass(); methodParams = getSootParams((polyglot.ast.Call) expr); } else if (expr instanceof polyglot.ast.Field) { polyglot.ast.Special target = (polyglot.ast.Special) ((polyglot.ast.Field) expr).target(); classToInvoke = ((soot.RefType) Util.getSootType(target.qualifier().type())).getSootClass(); } else { throw new RuntimeException("Trying to create special super qualifier for: " + expr + " which is not a field or call"); } // make an access method soot.SootMethod methToInvoke = makeSuperAccessMethod(classToInvoke, expr); // invoke it soot.Local classToInvokeLocal = Util.getThis(classToInvoke.getType(), body, getThisMap, lg); methodParams.add(0, classToInvokeLocal); soot.jimple.InvokeExpr invokeExpr = soot.jimple.Jimple.v().newStaticInvokeExpr(methToInvoke.makeRef(), methodParams); // return the local of return type if not void if (!methToInvoke.getReturnType().equals(soot.VoidType.v())) { soot.Local retLocal = lg.generateLocal(methToInvoke.getReturnType()); soot.jimple.AssignStmt stmt = soot.jimple.Jimple.v().newAssignStmt(retLocal, invokeExpr); body.getUnits().add(stmt); return retLocal; } else { body.getUnits().add(soot.jimple.Jimple.v().newInvokeStmt(invokeExpr)); return null; } }
units.insertBefore(ifStmt = Jimple.v().newIfStmt(Jimple.v().newNeExpr(l, NullConstant.v()), target), target); units.insertBefore(Jimple.v().newAssignStmt(l, Jimple.v().newStaticInvokeExpr(getClassFetcherFor(sc).makeRef(), Arrays.asList(new Value[] { StringConstant.v(sc.getName()) }))), target); units.insertBefore(Jimple.v().newAssignStmt(Jimple.v().newStaticFieldRef(classCacher.makeRef()), l), target);
list.add(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(toCall.makeRef()))); list.add(Jimple.v().newInvokeStmt(Jimple.v().newStaticInvokeExpr(toCall.makeRef(), IntConstant.v(1))));
invoke = soot.jimple.Jimple.v().newStaticInvokeExpr(meth, methParams); } else { invoke = soot.jimple.Jimple.v().newSpecialInvokeExpr(base, meth, methParams);
switch (k) { case REF_INVOKE_STATIC: return Jimple.v().newStaticInvokeExpr(methodRef, args); case REF_INVOKE_INTERFACE: return Jimple.v().newInterfaceInvokeExpr(args.get(0), methodRef, rest(args));
args.add(((InstanceFieldRef) ref).getBase()); InvokeExpr newExpr = Jimple.v().newStaticInvokeExpr(accessor.makeRef(), args);
invoke = soot.jimple.Jimple.v().newStaticInvokeExpr(methToCall, params); } else if (soot.Modifier.isInterface(receiverTypeClass.getModifiers()) && call.methodInstance().flags().isAbstract()) { invoke = soot.jimple.Jimple.v().newInterfaceInvokeExpr(baseLocal, methToCall, params);
InvokeExpr newExpr = Jimple.v().newStaticInvokeExpr(accessor.makeRef(), args);