[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Soot API: VerifyError when using Chain.insertBefore() methods
Hi, I was confused by the code constructing params. Are you modifying the
method signature or just printing out the parameters?
If you only need to print out method parameters, you can use
JimpleBody.getParameterLocal(int i) to get the corresponding Local object
instead of creating a new local in your code.
for (int j=0; j<xParameterNames; j++) {
params.add(activeBody.getParameterLocal(j));
}
> > How do you construct the params list?
>
>
> // creating local vars array
> Local [] argv = new Local[xParameterNames.length];
WHERE DID YOU GET xParameterNames?
>
> int j = 0;
> // iterate through each method parameter
> for (;j < xParameterNames.length; j++) {
> Type sootType = getSootType(xParameterTypes[j]);
>
> // Declare new local that will reference a method
> param
> argv[j] = Jimple.v().newLocal(xParameterNames[j],
> sootType);
>
> // Add it to locals list
> locals.add(argv[j]);
> // Make the new local reference a method param
> Unit currentUnit =
> Jimple.v().newIdentityStmt(argv[j], Jimple.v().newParameterRef(sootType,
> j));
>
> // Insert param reference into chain
> units.insertAfter(currentUnit, prevUnits[j]);
>
> // Update reference array
> prevUnits[j+1] = currentUnit;
>
> // Add to param to list
> params.add((Value)argv[j]);
> }
>
Can be done by :
for (int j=0; j<xParameterNames.length; j++) {
params.add(activeBody.getParameterLocal(j));
}