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