[Soot-list] How to create the statement: "v[i] = new Type();" ?

Cristina Ilie crysgirlro at yahoo.com
Sat Dec 11 12:36:00 EST 2010


Hi,

How can I to construct the following initialization: "v[i] = new Type();" ? (v 
is an array)

For the statement "x = new DerivType()" it's easy:

SootMethod initMethod =
                derivTypeClass.getMethodByName("<init>");

derivUnits.insertBefore(
                    Jimple.v().newInvokeStmt(
                            Jimple.v().newSpecialInvokeExpr(
                                    xVariable,
                                    initMethod.makeRef())),
                     stmt);

derivUnits.insertBefore(
                    Grimp.v().newAssignStmt(
                            xVariable,
                            Jimple.v().newNewExpr(derivTypeClass.getType())),
                    stmt);

But if I have "v[i] = .." instead of  "x = .." then I should to apply the "init" 
invokation on an ArrayRef object: 
"Jimple.v().newArrayRef(vvariable,iVariable).getIndex()" and 
Jimple.v().newInvokeStmt expects a JimpleLocal as the first parameter.

Thank you,
Cristina


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20101211/05ffabd1/attachment.html 


More information about the Soot-list mailing list