01: package net.sf.jdec.jvminstructions.commands;
02:
03: import net.sf.jdec.reflection.Behaviour;
04: import net.sf.jdec.util.Util;
05: import net.sf.jdec.blockhelpers.BranchHelper;
06: import net.sf.jdec.core.GlobalVariableStore;
07: import net.sf.jdec.core.JvmOpCodes;
08: import net.sf.jdec.core.OperandStack;
09:
10: import java.util.HashMap;
11: import java.util.Iterator;
12: import java.util.Map;
13:
14: public class ReturnCommand extends AbstractInstructionCommand {
15:
16: public ReturnCommand(Behaviour context) {
17: super (context);
18:
19: }
20:
21: public int getSkipBytes() {
22: return 0;
23: }
24:
25: public void execute() {
26: Behaviour behaviour = getContext();
27: java.lang.String temp = behaviour.getReturnType();
28: // Empty Stack Of This method
29: OperandStack currentstack = behaviour.getOpStack();
30: boolean check = currentstack.emptyMe();
31:
32: boolean oktoadd = true;
33: HashMap returnsAtI = GlobalVariableStore.getReturnsAtI();
34: Iterator mapIT = returnsAtI.entrySet().iterator();
35: int currentForIndex = getCurrentInstPosInCode();
36: int prev = currentForIndex - 1;
37: if (getGenericFinder().isThisInstrStart(prev)) {
38: if (getCode()[prev] == JvmOpCodes.ATHROW) {
39: oktoadd = false;
40: }
41: }
42:
43: if (oktoadd) {
44: while (mapIT.hasNext()) {
45: Map.Entry entry = (Map.Entry) mapIT.next();
46: Object key = entry.getKey();
47: Object retStatus = entry.getValue().toString();
48: if (key instanceof Integer) {
49: Integer position = (Integer) key;
50: int posValue = position.intValue();
51: if (posValue == currentForIndex) {
52: if (retStatus.equals("true")) {
53:
54: oktoadd = false;
55: break;
56: }
57: }
58: }
59:
60: }
61: }
62:
63: if (!oktoadd) {
64: returnsAtI.remove(new Integer(currentForIndex));
65: }
66:
67: Behaviour behavior = getContext();
68: if (oktoadd
69: && behaviour.getBehaviourName().equals("static") == false) {
70: oktoadd = BranchHelper.addReturnInIfBlock(currentForIndex);
71: if (oktoadd) {
72: java.lang.String tempString = Util
73: .formatDecompiledStatement("return;\n");
74: behavior.appendToBuffer(tempString);
75: returnsAtI.put(new Integer(currentForIndex), "true");
76: }
77: }
78:
79: }
80:
81: }
|