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