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