[Soot-list] Bad use of primitive type when performing transformations needed
Zeinab Lashkaripour
lashkaripour at yahoo.com
Sun Jun 9 09:55:36 EDT 2013
Thanks for the reply Quentin.
The actual code that I have written is as below:
tmpInt = Jimple.v().newLocal("tmpInt", RefType.v("java.lang.Integer"));
body.getLocals().add(tmpInt);
newExpr = Jimple.v().newNewExpr(RefType.v("java.lang.Integer"));
assign = Jimple.v().newAssignStmt(tmpInt, newExpr);
chainToAdd.add(assign);
invokeExpr = Jimple.v().newSpecialInvokeExpr(tmpInt, integerConstructorRef, IntConstant.v(inputLoc));
chainToAdd.add(Jimple.v().newInvokeStmt(invokeExpr));
length = Jimple.v().newLocal("j", RefType.v("int"));
body.getLocals().add(length);
assign = Jimple.v().newAssignStmt(length, Jimple.v().newVirtualInvokeExpr(localVar, lengthRef));
chainToAdd.add(assign);
AddExpr addExpr = Jimple.v().newAddExpr(tmpInt, length);
assign = Jimple.v().newAssignStmt(tmpInt, addExpr);
chainToAdd.add(assign);
arguments.add(tmpInt);
invokeExpr = Jimple.v().newStaticInvokeExpr(integerValueOfRef, arguments);
assign = Jimple.v().newAssignStmt(tmpInt, invokeExpr);
chainToAdd.add(assign);
exprAddValueToList = Jimple.v().newVirtualInvokeExpr(infoLocal, addToListRef, tmpInt);
chainToAdd.add(Jimple.v().newInvokeStmt(exprAddValueToList));
The resulted transformations are: (The produced jimple is as I want)
tmpInt = new java.lang.Integer
specialinvoke tmpInt.<java.lang.Integer: void <init>(int)>(17)
j = virtualinvoke var1.<java.lang.String: int length()>()
tmpInt = tmpInt + j
tmpInt = staticinvoke <java.lang.Integer: java.lang.Integer valueOf(int)>(tmpInt)
virtualinvoke info.<java.util.ArrayList: boolean add(java.lang.Object)>(tmpInt)
Regards,
Zeinab
________________________________
From: Quentin Sabah <quentin.sabah at inria.fr>
To: "soot-list at sable.mcgill.ca list" <soot-list at sable.mcgill.ca>
Sent: Sunday, June 9, 2013 6:07 PM
Subject: Re: [Soot-list] Bad use of primitive type when performing transformations needed
>
> $i0 = virtualinvoke a.<java.lang.String: int length()>();
> $i1 = 4 + $i0;
> $r1 = staticinvoke <java.lang.Integer: java.lang.Integer valueOf(int)>($i1);
> interfaceinvoke info.<java.util.List: boolean add(java.lang.Object)>($r1);
>
> I used the same way in creating my jimple in order to get the equivalent code that I want (in this example: info.add(4 + a.length());) but, I get the exception in [1] where 'j' (a local with RefType.v("int")) has the same role as $i0.
Why don't you just show us the actual jimple code leading to that exception? It looks like you have somewhere the following statements:
int j;
...
interfaceinvoke info.<java.util.List: boolean add(java.lang.Object)>(j);
Regards.
--
Quentin Sabah, CIFRE Ph.D. student
Grenoble University
INRIA-SARDES | STMicroelectronics/AST
Montbonnot, France | Grenoble, France
mailto:quentin.sabah at inria.fr | mailto:quentin.sabah at st.com
phone: +33 476 61 52 42 | phone: +33 476 58 44 14
_______________________________________________
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/20130609/3ed3bfd7/attachment-0001.html
More information about the Soot-list
mailing list