[Soot-list] How to create the statement: "v[i] = new Type(); " ?

Eric Bodden bodden at st.informatik.tu-darmstadt.de
Sun Dec 12 05:09:17 EST 2010


> Can I declare the tmp
> inside the loop? For example:
>
> Type tmp = new Type();
> v[i] = tmp;

In Jimple, local variables are always declared for the entire method
body. But why would that be a problem?

> I don't know if I can do that. When I introduce a variable I use
> derivLocalsChain.add(newVariable) and the new variable will be added at the
> beginning of the function. But if I do that then I will have a lot of "tmp"
> variables (tmp0,tmp1,...) and is no reason as long I use them once in my
> source code.

In practice this won't be a problem. During subsequent
transformations, Soot will "pack" all these different local variables
together, re-using them when necessary. Hence there's no problem with
using lots of them.

Eric


More information about the Soot-list mailing list