@Override
public void visitVarInsn(int opcode, int var) {
ReplacingBasicValue v;
if (opcode == Opcodes.ASTORE && (v = popCurrent(true)) != null) {
if (!v.isFunctionReturn) {
ValueHolderSub from = oldToNew.get(v.getIndex());
ReplacingBasicValue current = local(var);
// if local var is set, then transfer to it to the existing holders in the local position.
if (current != null) {
if (oldToNew.get(current.getIndex()).iden() == from.iden()) {
int targetFirst = oldToNew.get(current.index).first();
from.transfer(this, targetFirst);
return;
}
}
// if local var is not set, then check map to see if existing holders are mapped to local var.
if (oldLocalToFirst.containsKey(var)) {
ValueHolderSub sub = oldToNew.get(oldLocalToFirst.lget());
if (sub.iden() == from.iden()) {
// if they are, then transfer to that.
from.transfer(this, oldToNew.get(oldLocalToFirst.lget()).first());
return;
}
}
// map from variables to global space for future use.
oldLocalToFirst.put(var, v.getIndex());
} else {
// this is storage of a function return, we need to map the fields to the holder spots.
int first;
if (oldLocalToFirst.containsKey(var)) {
first = oldToNew.get(oldLocalToFirst.lget()).first();
v.iden.transferToLocal(adder, first);
} else {
first = v.iden.createLocalAndTrasfer(adder);
}
ValueHolderSub from = v.iden.getHolderSubWithDefinedLocals(first);
oldToNew.put(v.getIndex(), from);
v.disableFunctionReturn();
}
} else if (opcode == Opcodes.ALOAD && (v = getReturn()) != null) {