[Soot-list] Generating invalid code
mbatch at cs.mcgill.ca
mbatch at cs.mcgill.ca
Thu Feb 9 19:34:29 EST 2006
On Thu, February 9, 2006 1:26 pm, Marc Hull (Imperial College) wrote:
> Hi,
> I'm trying to use Soot to add code to the start of certain methods, but
> I keep generating bytecode that fails verifier checks when I run it.
> I've narrowed it down to the statement that ties the 'this' reference to
> a local:
Marc,
I think what you want is a ThisRef:
ThisRef thisRef = new ThisRef(method.getDeclaringClass().getType());
I then do something like this:
Local thisLocal = Jimple.v().newLocal("ths", thisRef.getType());
locals.add(thisLocal);
units.add(Jimple.v().newIdentityStmt(thisLocal,
Jimple.v().newThisRef((RefType)thisRef.getType())));
>
> Local a0 = Jimple.v().newLocal("a0",
> RefType.v(method.getDeclaringClass()));
> body.getLocals().add(a0);
>
> units.add( Jimple.v().newIdentityStmt(
> a0, Jimple.v().newThisRef(
> RefType.v(method.getDeclaringClass())
> )
> )
> );
More information about the Soot-list
mailing list