iin.var = iin.var + 1;
log("Incremented iinc var to " + iin.var);
}
}
InsnList pre = new InsnList();
// pre.add(vStart);
if (isStatic) {
pre.add(new LdcInsnNode(cn.name));
} else {
pre.add(new VarInsnNode(ALOAD, 0)); // "this" is index 0 locvar.
}
pre.add(new MethodInsnNode(INVOKESTATIC, classDesc, BEFORE,
ONE_OBJECT_PARAM + OBJECT_DESC));
pre.add(new VarInsnNode(ASTORE, purrSecretIndex));
pre.add(fStart);
mn.instructions.insert(mStart, pre);
List<AbstractInsnNode> terminalNodes = new ArrayList<AbstractInsnNode>();
for (int i = 0; i < mn.instructions.size(); i++) {
AbstractInsnNode insn = mn.instructions.get(i);
int opcode = insn.getOpcode();
if (isReturnOpcode(opcode)) {
terminalNodes.add(insn);
}
}
LabelNode okReturnLabel = new LabelNode( new Label() );
// LabelNode throwReturnLabel = new LabelNode( new Label() );
Integer returnOpcode = null;
for (AbstractInsnNode ain : terminalNodes) {
// mn.instructions.insertBefore(ain,
// preExitInsns(cn, mn, purrSecretIndex));
// if ( ain.getOpcode() == ATHROW ) {
// mn.instructions.insert( ain, new JumpInsnNode( GOTO, throwReturnLabel ));
// }
// else {
mn.instructions.insert( ain, new JumpInsnNode( GOTO, okReturnLabel ));
if ( returnOpcode == null ) {
returnOpcode = ain.getOpcode();
}
else {
if ( returnOpcode.intValue() != ain.getOpcode() ) {
throw new RuntimeException( "Multiple return types: " + returnOpcode + " and " + ain.getOpcode() );
}
// }
}
mn.instructions.remove( ain );
}
InsnList coda = new InsnList();
coda.add( okReturnLabel );
coda.add( preExitInsns( cn, mn, purrSecretIndex ));
coda.add( new InsnNode( returnOpcode ));
coda.add(fEnd);
// coda.add( throwReturnLabel );
coda.add(preExitInsns(cn, mn, purrSecretIndex));
coda.add(new InsnNode(ATHROW));
mn.instructions.insertBefore(mEnd, coda);
for (Object o : mn.tryCatchBlocks) {
TryCatchBlockNode tcbn = (TryCatchBlockNode) o;
if (tcbn.start == mStart) {