[Soot-list] Local variables with the same name/type in Jimple?

Yi Lin qinsoon at gmail.com
Mon Feb 25 00:40:57 EST 2013


Hi,

For example, for this code:

         public static void main(String[] args) {
             int sum = 0;
             for (int i = 1; i < 5; i++)
                 sum += i;
             for (int i = 5; i < 10; i++)
                 sum += i;
         }

in Jimple IR:

    <void main(java.lang.String[])>{
    Locals:
    [java.lang.String[]]args
    [int]i
    [int]temp$3
    [int]i
    [int]temp$7
    Locals end.
       [class soot.jimple.internal.JIdentityStmt]:args := @parameter0:
    java.lang.String[]
       [class soot.jimple.internal.JAssignStmt]:i = 1
       [class soot.jimple.internal.JIfStmt]:if i < 5 goto temp$3 = i + 1
       [class soot.jimple.internal.JGotoStmt]:goto [?= i = 5]
       [class soot.jimple.internal.JAssignStmt]:temp$3 = i + 1
       [class soot.jimple.internal.JAssignStmt]:i = temp$3
       [class soot.jimple.internal.JGotoStmt]:goto [?= (branch)]
       [class soot.jimple.internal.JAssignStmt]:i = 5
       [class soot.jimple.internal.JIfStmt]:if i < 10 goto temp$7 = i + 1
       [class soot.jimple.internal.JGotoStmt]:goto [?= return]
       [class soot.jimple.internal.JAssignStmt]:temp$7 = i + 1
       [class soot.jimple.internal.JAssignStmt]:i = temp$7
       [class soot.jimple.internal.JGotoStmt]:goto [?= (branch)]
       [class soot.jimple.internal.JReturnVoidStmt]:return
    }

there are two local variables for i as int type. Though it seems 
harmless in this case (and maybe in all the cases), I am wondering why 
this is allowed instead of renaming the second appearance of the same 
variable.

Thanks very much.

Regards,
Yi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20130225/6fbcb844/attachment.html 


More information about the Soot-list mailing list