[prev in list] [next in list] [prev in thread] [next in thread]
List: soot-list
Subject: Re: [Soot-list] How can I define my own Body?
From: Marc Miltenberger <Marc.Miltenberger () cased ! de>
Date: 2015-04-16 7:14:42
Message-ID: 552F6162.8030108 () cased ! de
[Download RAW message or body]
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@CS.McGill.CA
> https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
>
_______________________________________________
Soot-list mailing list
Soot-list@CS.McGill.CA
https://mailman.CS.McGill.CA/mailman/listinfo/soot-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic