[Soot-list] extracing actual value from local variable

Paris Yiapanis yiapanip at cs.man.ac.uk
Tue Jun 8 05:38:56 EDT 2010


Hi Eric,

First of all thank you very much for the reply.

I was trying to cast the value to an IntConstant after it has been assigned
but I was getting an error that 'JimpleLocal' cannot be cast to
'IntConstant'.

In the program I am parsing, I have a for loop and I a trying to get the
number of iterations it has to run.

in Jimple it looks like:

if i1 < 1

and i1 was assigned a constant int 5 (for instance) before that use.

So I read the Stmt as a 'JIfStmt' and then I extract the Op1 which is i1 but
I cannot cast it to IntConstant. Maybe I am following the wrong steps.
Is there a way to get this value?


Thank you in advance,

Paris


On Tue, Jun 8, 2010 at 8:14 AM, Eric Bodden <
bodden at st.informatik.tu-darmstadt.de> wrote:

> Hi Paris.
>
> A value is a runtime thing. At compile time, a variable has no value.
> But you can walk through different assignments to i1. Then,
> immediately after an assignment you know that i1 has to have the
> assigned value *at this position*. If the assigned value is a
> constant, then in Soot you can just cast it to this constant (e.g. an
> IntConstant) and retrieve its value from there.
>
> Constant propagation may help you to find more constants than usual.
>
> Eric
>
> --
> Dr. Eric Bodden
> Software Technology Group, Technische Universität Darmstadt, Germany
> Tel: +49 6151 16-5478    Fax: +49 6151 16-5410
> Mailing Address: S2|02 A209, Hochschulstraße 10, 64289 Darmstadt
>
>
>
> On 7 June 2010 18:12, Paris Yiapanis <yiapanip at cs.man.ac.uk> wrote:
> > Hi,
> >
> > How can I extract the actual value of a local variable in Jimple?
> >
> > For instance I have:
> >
> > if i1 < 5
> >
> > and I want to extract the value of local variable i1.
> >
> > Thank you in advance,
> >
> > Paris
> >
> > _______________________________________________
> > Soot-list mailing list
> > Soot-list at sable.mcgill.ca
> > http://mailman.cs.mcgill.ca/mailman/listinfo/soot-list
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20100608/dc8e6be8/attachment.html 


More information about the Soot-list mailing list