001: package net.sf.jdec.jvminstructions.commands;
002:
003: import net.sf.jdec.core.DecompilerHelper;
004: import net.sf.jdec.core.LocalVariable;
005: import net.sf.jdec.core.Operand;
006: import net.sf.jdec.jvminstructions.util.TypeConstants;
007: import net.sf.jdec.reflection.Behaviour;
008:
009: /*
010: * ILoad_0Command.java Copyright (c) 2006,07 Swaroop Belur
011: *
012: * This program is free software; you can redistribute it and/or
013: * modify it under the terms of the GNU General Public License
014: * as published by the Free Software Foundation; either version 2
015: * of the License, or (at your option) any later version.
016:
017: * This program is distributed in the hope that it will be useful,
018: * but WITHOUT ANY WARRANTY; without even the implied warranty of
019: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020: * GNU General Public License for more details.
021:
022: * You should have received a copy of the GNU General Public License
023: * along with this program; if not, write to the Free Software
024: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
025: *
026: */
027: public class ILoad_3Command extends AbstractInstructionCommand {
028:
029: private static final int commandIndex = 3;
030:
031: public ILoad_3Command(Behaviour context) {
032: super (context);
033: }
034:
035: public int getSkipBytes() {
036: return 0;
037: }
038:
039: public void execute() {
040: LocalVariable local = DecompilerHelper.getLocalVariable(
041: commandIndex, TypeConstants.LOAD, TypeConstants.INT,
042: true, getCurrentInstPosInCode());
043: if (local != null) {
044: boolean terEnd = false;//isLoadTernaryEnd(getCurrentInstPosInCode());
045: Operand op = new Operand();
046: java.lang.String ltmp = local.getTempVarName();
047: boolean bo = getGenericFinder().isPrevInstIINC(
048: getCurrentInstPosInCode(), commandIndex);
049: boolean bo2 = false;
050: StringBuffer addsub = new StringBuffer("");
051: if (!bo) {
052: bo = getGenericFinder().isNextInstIINC(
053: getCurrentInstPosInCode(), commandIndex,
054: TypeConstants.SIMPLE);
055: }
056: if (!bo) {
057:
058: bo = DecompilerHelper.checkForPostIncrForLoadCase(
059: getCode(), getCurrentInstPosInCode(),
060: TypeConstants.CATEGORY1, false, commandIndex,
061: addsub);
062: bo2 = bo;
063: }
064: if (!terEnd) {
065: if (bo && ltmp != null) {
066: op.setOperandValue(ltmp);
067: } else {
068: if (!bo2)
069: op.setOperandValue(local.getVarName());
070: else {
071: op.setOperandValue(local.getVarName()
072: + addsub.toString());
073: }
074:
075: }
076: } else {
077: if (bo) {
078: java.lang.String v1 = getTopOfStack()
079: .getOperandValue();
080: op.setOperandValue(v1 + ltmp);
081: } else {
082: java.lang.String v1 = getTopOfStack()
083: .getOperandValue();
084: op.setOperandValue(v1 + local.getVarName());
085: }
086:
087: }
088:
089: op.setLocalVarIndex(commandIndex);
090: op.setLocalVarType(local.getDataType());
091: boolean r = false;//checkIFLoadInstIsPartOFTernaryCond(getCurrentInstPosInCode());
092: if (r) {
093: if (getStack().size() > 0) {
094: java.lang.String str = getStack().getTopOfStack()
095: .getOperandValue();
096: str = str + op.getOperandValue();
097: op.setOperandValue(str);
098: }
099: }
100: getStack().push(op);
101: }
102: }
103: }
|