01: package net.sf.jdec.jvminstructions.commands;
02:
03: import java.util.Iterator;
04: import java.util.Map;
05:
06: import net.sf.jdec.core.DecompilerHelper;
07: import net.sf.jdec.core.GlobalVariableStore;
08: import net.sf.jdec.core.Operand;
09: import net.sf.jdec.core.OperandStack;
10: import net.sf.jdec.reflection.Behaviour;
11: import net.sf.jdec.util.Util;
12:
13: public class IReturnCommand extends AbstractInstructionCommand {
14:
15: public IReturnCommand(Behaviour context) {
16: super (context);
17:
18: }
19:
20: public int getSkipBytes() {
21: return 0;
22: }
23:
24: public void execute() {
25: boolean oktoadd = true;
26: Behaviour behavior = getContext();
27:
28: String tempString = "";
29: OperandStack opStack = getStack();
30: int currentForIndex = getCurrentInstPosInCode();
31: int i = currentForIndex;
32: Map returnsAtI = GlobalVariableStore.getReturnsAtI();
33: Iterator mapIT = returnsAtI.entrySet().iterator();
34: while (mapIT.hasNext()) {
35: Map.Entry entry = (Map.Entry) mapIT.next();
36: Object key = entry.getKey();
37: Object retStatus = entry.getValue().toString();
38: if (key instanceof Integer) {
39: Integer pos = (Integer) key;
40: int temp = pos.intValue();
41: if (temp == i) {
42: if (retStatus.equals("true")) {
43:
44: oktoadd = false;
45: break;
46: }
47: }
48: }
49:
50: }
51:
52: if (!oktoadd) {
53: returnsAtI.remove(new Integer(i));
54: }
55:
56: if (oktoadd && opStack.size() > 0) {
57: Operand op = (Operand) opStack.pop();
58: boolean bool = DecompilerHelper
59: .isMethodRetBoolean(getContext());
60: if (bool) {
61: if (op.getOperandValue().equals("1")) {
62: op.setOperandValue("true");
63: } else if (op.getOperandValue().equals("0")) {
64: op.setOperandValue("false");
65: }
66: }
67: tempString = "return " + op.getOperandValue() + ";\n";
68: behavior.appendToBuffer(Util
69: .formatDecompiledStatement(tempString));
70: }
71:
72: }
73:
74: }
|