001: package net.sf.jdec.jvminstructions.commands;
002:
003: import java.util.ArrayList;
004:
005: import net.sf.jdec.core.DecompilerHelper;
006: import net.sf.jdec.core.GlobalVariableStore;
007: import net.sf.jdec.core.JvmOpCodes;
008: import net.sf.jdec.core.LocalVariable;
009: import net.sf.jdec.core.Operand;
010: import net.sf.jdec.core.OperandStack;
011: import net.sf.jdec.reflection.Behaviour;
012: import net.sf.jdec.util.Util;
013:
014: public class LstoreCommand extends AbstractInstructionCommand {
015:
016: public LstoreCommand(Behaviour context) {
017: super (context);
018:
019: }
020:
021: public int getSkipBytes() {
022: return 1;
023: }
024:
025: public void execute() {
026: int currentForIndex = getCurrentInstPosInCode();
027: int i = currentForIndex;
028: byte[] info = getCode();
029: int pos = info[++i];
030: if (pos < 0)
031: pos += 256;
032: boolean doNotPop = GlobalVariableStore.isDoNotPop();
033: OperandStack opStack = getStack();
034: Behaviour behavior = getContext();
035: boolean dupnothandled = GlobalVariableStore.isDupnothandled();
036: LocalVariable local = DecompilerHelper.getLocalVariable(pos,
037: "store", "long", false, currentForIndex);
038: if (local != null && !doNotPop) {
039: Operand operand1 = opStack.getTopOfStack();
040: boolean push = getGenericFinder().isPrevInstDup(
041: currentForIndex);
042: if (!push) {
043: if (!local.isDeclarationGenerated()) {
044: Object vaf = DecompilerHelper.newVariableAtFront(
045: local.getVarName(), local.getDataType(),
046: "0L");
047: GlobalVariableStore.getVariablesatfront().add(vaf);
048: String tempString = local.getVarName() + "="
049: + operand1.getOperandValue() + ";\n";
050: behavior.appendToBuffer(Util
051: .formatDecompiledStatement(tempString));
052: local.setDeclarationGenerated(true);
053: } else {
054: String tempString = local.getVarName() + "="
055: + operand1.getOperandValue() + ";\n";
056: behavior.appendToBuffer(Util
057: .formatDecompiledStatement(tempString));
058: }
059: } else {
060: if (info[currentForIndex - 1] == JvmOpCodes.DUP
061: && !dupnothandled)
062: opStack.getTopOfStack();
063: if (info[currentForIndex - 1] == JvmOpCodes.DUP2
064: && !dupnothandled) {
065: opStack.getTopOfStack();
066: opStack.getTopOfStack();
067: }
068: if (dupnothandled)
069: dupnothandled = false;
070: if (!DecompilerHelper.isTernaryCondition(
071: currentForIndex, info)) {
072: if (!newfound()) {
073: java.lang.String decl = "";
074: if (!local.isDeclarationGenerated()) {
075: Object vaf = DecompilerHelper
076: .newVariableAtFront(local
077: .getVarName(), local
078: .getDataType(), "0L");
079: GlobalVariableStore.getVariablesatfront()
080: .add(vaf);
081: // decl=local.getDataType()+"\t";//+local.getVarName()+"="+"#VALUE"+classIndex+"#"+op.getOperandValue()+";\n";
082: local.setDeclarationGenerated(true);
083: }
084: behavior.appendToBuffer(Util
085: .formatDecompiledStatement(decl
086: + local.getVarName() + "="
087: + operand1.getOperandValue()
088: + ";\n"));
089: Operand op = createOperand(local.getVarName());
090: opStack.push(op);
091: } else {
092: Operand op = createOperand(local.getVarName()
093: + "=" + operand1.getOperandValue());
094: opStack.push(op);
095: }
096: } else {
097: boolean ternEndfoundForParentIF = false;// isThisTernaryListEndForParentIF(currentForIndex);
098: boolean ternEndfound = false;// isThisTernaryListEnd(currentForIndex);
099:
100: boolean dupStoreForTerIf = false;// isThisDUPSTOREAtEndOFTernaryIF(currentForIndex,info,"store");
101: boolean n = false;// anydupstoreinternarybesidesthis(currentForIndex,info);
102: if (ternEndfound && n) {
103: opStack.push(operand1);
104: } else {
105: Operand p = opStack.getTopOfStack();
106: boolean end = false;// isTernaryEnd(currentForIndex);
107: if (dupStoreForTerIf) {
108: if (!end)
109: p.setOperandValue(p.getOperandValue()
110: + local.getVarName() + "="
111: + operand1.getOperandValue());
112: else
113: p.setOperandValue(p.getOperandValue()
114: + local.getVarName() + "="
115: + operand1.getOperandValue()
116: + ")");
117: }
118: if (!dupStoreForTerIf) {
119: if (!end)
120: p.setOperandValue(p.getOperandValue()
121: + operand1.getOperandValue());
122: else
123: p.setOperandValue(p.getOperandValue()
124: + operand1.getOperandValue()
125: + ")");
126: }
127: opStack.push(p);
128: }
129: if (ternEndfoundForParentIF)
130: GlobalVariableStore
131: .setTernList(new ArrayList());
132:
133: }
134: }
135: }
136: if (doNotPop == true)
137: doNotPop = false;
138:
139: GlobalVariableStore.setDoNotPop(doNotPop);
140: GlobalVariableStore.setDupnothandled(dupnothandled);
141:
142: }
143:
144: }
|