01: package net.sf.jdec.jvminstructions.commands;
02:
03: import net.sf.jdec.core.DecompilerHelper;
04: import net.sf.jdec.core.GlobalVariableStore;
05: import net.sf.jdec.core.JvmOpCodes;
06: import net.sf.jdec.core.Operand;
07: import net.sf.jdec.core.OperandStack;
08: import net.sf.jdec.reflection.Behaviour;
09:
10: public class Dup2Command extends AbstractInstructionCommand {
11:
12: public Dup2Command(Behaviour context) {
13: super (context);
14:
15: }
16:
17: public int getSkipBytes() {
18: return 0;
19: }
20:
21: public void execute() {
22: //Behaviour behaviour = getContext();
23: int currentForIndex = getCurrentInstPosInCode();
24: OperandStack opStack = getStack();
25: byte[] info = getCode();
26: boolean dupnothandled = GlobalVariableStore.isDupnothandled();
27: boolean embeddedANEWARRAY = GlobalVariableStore
28: .isEmbeddedANEWARRAY();
29: boolean embeddedNEWARRAY = GlobalVariableStore
30: .isEmbeddedNEWARRAY();
31: boolean doNotPop = GlobalVariableStore.isDoNotPop();
32: if ((getGenericFinder().isThisInstrStart((currentForIndex - 3)) && info[(currentForIndex - 3)] == JvmOpCodes.ANEWARRAY)
33: && newfound()) {
34: dupnothandled = true;
35: } else if (newfound()
36: && (DecompilerHelper.checkForSizeOfArrayTimesStack()
37: || DecompilerHelper.prevNewPresent() || GlobalVariableStore
38: .getTernList().size() > 0)) {
39: dupnothandled = true;
40: } else {
41: if (!embeddedANEWARRAY && !embeddedNEWARRAY
42: && (opStack.size() > 0)) {
43: Operand op1 = (Operand) opStack.pop();
44: Operand op2 = (Operand) opStack.pop();
45: opStack.push(op2);
46: opStack.push(op1);
47: opStack.push(op2);
48: opStack.push(op1);
49: } else {
50: if (embeddedANEWARRAY)
51: embeddedANEWARRAY = false;
52: if (embeddedNEWARRAY)
53: embeddedNEWARRAY = false;
54:
55: }
56: dupnothandled = false;
57: if (doNotPop) {
58: doNotPop = false;
59: }
60:
61: }
62: GlobalVariableStore.setDoNotPop(doNotPop);
63: GlobalVariableStore.setDupnothandled(dupnothandled);
64: GlobalVariableStore.setEmbeddedANEWARRAY(embeddedANEWARRAY);
65: GlobalVariableStore.setEmbeddedNEWARRAY(embeddedNEWARRAY);
66: }
67:
68: }
|