[Soot-list] How can I define my own Body?
Marc Miltenberger
Marc.Miltenberger at cased.de
Thu Apr 16 03:14:42 EDT 2015
Hi there,
I guess you do want to modify an already existing body rather than
declare a new, own body?
Using getUnits() on the body returns a PatchingChain of units.
Use the insertBefore-method to insert a new JAssignmentStmt ($i = 123).
For the Invoke Stmts, you can get the invoke expression through
getInvokeExpr(). Afterwards, you can set the concrete argument via setArg.
Your code could look like this
//Create and add a new local i
Local iLocal = new JimpleLocal("$i", IntType.v());
body.getLocals().add(iLocal);
InvokeStmt invokeStmt = ...;
//Replace the actual parameter of the invoke expr
InvokeExpr expr = invokeStmt.getInvokeExpr();
Value arg = expr.getArg(0);
expr.setArg(0, iLocal);
//Adds the assignment to i right before the invoke expression.
JAssignStmt assign = new JAssignStmt(iLocal, arg);
body.getUnits().insertBefore(assign, invokeStmt);
Adapt the code as you like.
Marc
Am 16.04.2015 um 08:30 schrieb 润青杨:
> Hello guys,
> I meet some problems.
> Jimple is great. But now I need to modify jimple to adapt my system.
> for example:
>
> Jimple body:
> method(123); --> virtualinvoke <xxx, method(123)>
>
> What I want:
> method(123); ---> $i = 123;
> virtualinvoke <xxx, method($i)>
>
>
> how can I do that?
>
> Thanks,
> Rainkin
>
>
>
> _______________________________________________
> Soot-list mailing list
> Soot-list at CS.McGill.CA
> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>
More information about the Soot-list
mailing list