/** Helper that updates the dex statistics. */ private static void updateDexStatistics( CfOptions cfOptions, DexOptions dexOptions, RopMethod optRmeth, RopMethod nonOptRmeth, LocalVariableInfo locals, int paramSize, int originalByteCount) { /* * Run rop->dex again on optimized vs. non-optimized method to * collect statistics. We have to totally convert both ways, * since converting the "real" method getting added to the * file would corrupt it (by messing with its constant pool * indices). */ DalvCode optCode = RopTranslator.translate(optRmeth, cfOptions.positionInfo, locals, paramSize, dexOptions); DalvCode nonOptCode = RopTranslator.translate(nonOptRmeth, cfOptions.positionInfo, locals, paramSize, dexOptions); /* * Fake out the indices, so code.getInsns() can work well enough * for the current purpose. */ DalvCode.AssignIndicesCallback callback = new DalvCode.AssignIndicesCallback() { public int getIndex(Constant cst) { // Everything is at index 0! return 0; } }; optCode.assignIndices(callback); nonOptCode.assignIndices(callback); CodeStatistics.updateDexStatistics(nonOptCode, optCode); CodeStatistics.updateOriginalByteCount(originalByteCount); }