[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SootField referencing in a method body
On Wed, Nov 05, 2003 at 05:31:52PM +0100, Emil Slusanschi wrote:
> Hi,
>
> I am using a SceneTransformer to create a new Method (from an old one
> through a clone() ) and a new global Field (at the moment it's just a
By global field, do you mean a static field?
> double). Then I am modifying the new/cloned Method with a
> BodyTransformer and I try to save a result, another double, in that
> global Field I defined in the SceneTransformer. The problem is, I cannot
> seem to get a Value from a SootField no matter what. And for a
> newAssignStmt I need one. I also tried with newInstanceFieldRef but how
> can I get a statement out of that? What I want is to have a global Field
> = method local. I guess that you got it by now that I have a problem
So you want a Jimple statement like:
C.f = l;
(or if it's a non-static field, l1.f = l;).
You need to do:
Jimple.v().newAssignStmt(
Jimple.v().newStaticFieldRef(f),
l
);
where f is a SootField and l is a Local.
If it's a non-static field, you want:
Jimple.v().newAssignStmt(
Jimple.v().newInstanceFieldRef(l1, f),
l
);
where l1 and l are Locals and f is a SootField.
Ondrej
> with the call-by-value that Java uses :) and that I need to return to a
> method more than the original return value, and I would like to avoid
> using an Array(new return Type) with the old return value plus the new
> stuff that I create through the transformations that I am doing in the
> BodyTransformer. I hope I have been clear enough and if anybody has an
> ideea of how can I achieve what I want, I would be very grateful. And if
> you have a better idea of doing what I described, that would be even
> better...
>
> Cheers,
>
> Emil
>
> PS. And by the way, Soot is a really good piece of work ;-)
>
>