01: package net.sf.jdec.jvminstructions.commands;
02:
03: import net.sf.jdec.constantpool.ClassDescription;
04: import net.sf.jdec.constantpool.FieldRef;
05: import net.sf.jdec.core.DecompilerHelper;
06: import net.sf.jdec.core.GlobalVariableStore;
07: import net.sf.jdec.core.Operand;
08: import net.sf.jdec.core.OperandStack;
09: import net.sf.jdec.reflection.Behaviour;
10: import net.sf.jdec.util.Util;
11:
12: public class PutfieldCommand extends AbstractInstructionCommand {
13:
14: public PutfieldCommand(Behaviour context) {
15: super (context);
16:
17: }
18:
19: public int getSkipBytes() {
20: return 2;
21: }
22:
23: public void execute() {
24: boolean doNotPop = GlobalVariableStore.isDoNotPop();
25: Behaviour behavior = getContext();
26: byte[] info = getCode();
27: if (doNotPop == false) {
28: int i = getCurrentInstPosInCode();
29: int pos = getGenericFinder().getOffset(i);
30: i += 2;
31: ClassDescription cd = getContext().getClassRef().getCd();
32: OperandStack opStack = getStack();
33: FieldRef fref = cd.getFieldRefAtCPoolPosition(pos);
34: Operand value = opStack.getTopOfStack();
35: Operand objRef = opStack.getTopOfStack();
36:
37: java.lang.String freftype = fref.getTypeoffield();
38: StringBuffer sb = new StringBuffer("");
39: DecompilerHelper.checkForImport(objRef.getOperandValue(),
40: sb);
41: java.lang.String v = value.getOperandValue();
42: if (fref.isBooleanField()) {
43: if (v != null && v.equals("1")) {
44: v = "true";
45: }
46: if (v != null && v.equals("0")) {
47: v = "false";
48: }
49: }
50:
51: java.lang.String temp = sb.toString().replaceAll("/", ".")
52: + "." + fref.getFieldName() + " =" + v + ";";
53:
54: behavior.appendToBuffer("\n"
55: + Util.formatDecompiledStatement(temp) + "\n");
56: }
57: if (doNotPop)
58: doNotPop = false;
59:
60: GlobalVariableStore.setDoNotPop(doNotPop);
61: }
62:
63: }
|