[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Naming of Jimple Locals
On Thu, 29 May 2003, Amit Manjhi wrote:
> I am trying to understand the naming of Jimple Locals, and am not
> clear about whether the name of a Local should begin with a $ (stack
> variable) or not. What are the differences? Moreover, if I need to
> introduce a new local, how should I name it?
Recall that Java bytecode is a stack-based intermediate language.
Each method also gets to specify a set of locals that it will use in the
code.
For instance, javap -c -verbose java.lang.Object might return
public boolean equals(java.lang.Object);
/* Stack=2, Locals=2, Args_size=2 */
The locals are read and written with instructions like aload_0 and
astore_1. (See, for instance,
http://www.javaworld.com/javaworld/jw-07-1997/hood/example.html).
Jimplification (converting bytecode to Jimple) involves assigning a local
variable name to each local variable declared for a method; the names are
assigned numerically and by object type e.g. i2, i3, b4. But that's not
enough, because the stack also plays a role in each bytecode statement.
We convert the stack into an additional set of 'virtual local' variables.
This is actually somewhat tricky, because all variables in Jimple are
typed, but the stack spaces actually can have different types over time.
For more information, see our CASCON '99 paper, which describes how Jimple
is produced, and our CC 2000 paper, which describes how we go from Jimple
back to bytecode.
http://www.sable.mcgill.ca/publications/papers/#cascon99
As for your question, you can give whatever names you like to variables
that you create. Soot doesn't care about whether things have $'s or not;
they're just there to help users understand the code that Soot spits out
and how it relates to the original bytecode. You can even (although this
is a pretty bad idea!) give the same name to different locals, and Soot
should handle it correctly. But don't count on it!
pat