[Soot-list] Java-Jimple mapping using SourceLnPosTag
Marcus Mews
m.mews at tu-berlin.de
Fri Mar 9 13:24:19 EST 2012
Hello everybody,
I am Marcus Mews (TU-Berlin) and about to use Soot in an academic
prototype to perform semantic preserving refactorings. Therfor, I need
to know certain details about Soot's mapping between Java Expressions
and Jimple Units. For various reasons, Soot splits up Java Expressions
like from
void JavaFoo() {
x++;
}
to
void JimpleFoo() {
temp$1 = this.<some.Clazz: int x>; //sline=134, eline=134, spos=1,
epos=1
temp$2 = temp$1 + 1; //sline=134, eline=134, spos=1,
epos=1
this.<some.Clazz: int x> = temp$2; //sline=134, eline=134, spos=1,
epos=1
}
Another - slightly different - case is the following example: From
void JavaBar() {
x=x+1;
}
to
void JimpleBar() {
temp$3 = this.<some.Clazz: int x>; //sline=135, eline=135,
spos=3, epos=3
temp$4 = temp$3 + 1; //sline=135, eline=135,
spos=3, epos=3
this.<some.Clazz: int x> = temp$4; //sline=135, eline=135,
spos=1, epos=1
}
In the first example above, the expression "x++" is substituted by
three other expressions in the Jimple code, since there is no equivalent
in the Jimple language, I assume. In the second example, the expression
"x=x+1" is just split up into more trivial expressions.
I'd like to know where each Jimple unit comes from.
I considered using the SourceLnPosTag, but I'm not sure, whether
this is the right thing to do; in the examples above, I also stated the
SourceLnPosTags: In the "x++"-example, all the SourceLnPosTags point to
the same Java code text snippet, which is as I expected (although I it
seems odd that epos=1 instead of epos=3). But in the second example I
don't understand the position numbers, since some Jimple units have
equal SourceLnPosTags. Maybe the tags are incorrect or maybe I'm off the
track here and there is a better way to retrieve each unit's Java origin?
Anyway, I appreciate any advice or links to manuals, etc.
Thanks and regards,
Marcus
More information about the Soot-list
mailing list