[Soot-list] how to add primitive java types to Local?
Eric Bodden
eric.bodden at mail.mcgill.ca
Fri Aug 15 09:31:05 EDT 2008
> but what if I want to create a statement like "a = 1;" only? No idea on how to create the object with constant value. Thanks.
That would be:
AssignStmt toAdd1 = Jimple.v().newAssignStmt(tmpLocal,
IntConstant.v(1));
Also please be careful when adding new locals because of name clashes
with existing locals. soot.javaToJimple.LocalGenerator takes care of
this, creating fresh locals:
LocalGenerator lg = new LocalGenerator(body);
Local tmpLocal = lg.generateLocal(IntType.v());
body.getLocals().add(tmpLocal);
AssignStmt toAdd1 = Jimple.v().newAssignStmt(tmpLocal,
IntConstant.v(1));;
units.insertBefore(toAdd1, stmt);
Eric
2008/8/15 Gerald Sit <Gerald.Sit at student.cityu.edu.hk>:
> Hi all,
>
> I'm looking into adding statements to specific java programs. It seems it's relatively easy to add statements before or after specific statement using Chain.insertBefore and Chain.insertAfter, but I didn't figure out how to instantiate objects of Value type. Some of the Value subclass objects could be created with Jimple.v().newXXX(...) like the following code snippets:
>
> Local tmpLocal = Jimple.v().newLocal("tmp", LongType.v());
> body.getLocals().add(tmpLocal);
>
> AssignStmt toAdd1 = Jimple.v().newAssignStmt(tmpLocal,
> Jimple.v().newStaticFieldRef(gotoCounter.makeRef()));
> units.insertBefore(toAdd1, stmt);
>
>
>
> but what if I want to create a statement like "a = 1;" only? No idea on how to create the object with constant value. Thanks.
>
> Gerald
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
>
--
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada
More information about the Soot-list
mailing list