001: /*
002: * IFinder.java Copyright (c) 2006,07 Swaroop Belur
003: *
004: * This program is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU General Public License
006: * as published by the Free Software Foundation; either version 2
007: * of the License, or (at your option) any later version.
008:
009: * This program is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013:
014: * You should have received a copy of the GNU General Public License
015: * along with this program; if not, write to the Free Software
016: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
017: *
018: */
019:
020: package net.sf.jdec.lookup;
021:
022: import net.sf.jdec.blocks.IFBlock;
023: import net.sf.jdec.blocks.Loop;
024: import net.sf.jdec.blocks.Switch;
025:
026: /*
027: * IFinder.java Copyright (c) 2006,07 Swaroop Belur
028: *
029: * This program is free software; you can redistribute it and/or
030: * modify it under the terms of the GNU General Public License
031: * as published by the Free Software Foundation; either version 2
032: * of the License, or (at your option) any later version.
033:
034: * This program is distributed in the hope that it will be useful,
035: * but WITHOUT ANY WARRANTY; without even the implied warranty of
036: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
037: * GNU General Public License for more details.
038:
039: * You should have received a copy of the GNU General Public License
040: * along with this program; if not, write to the Free Software
041: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
042: *
043: */
044:
045: /**
046: * Interface containing all find methods
047: * Basically some sort of look up of the
048: * concrete implementation is required.
049: * Then the returned finder can then be used
050: * to find what is exactly required.
051: * <p/>
052: * Example:
053: * <p/>
054: * IFinder finder = FinderFactory.getFinder(IFinder.LOAD);
055: * finder.<find_some_load_inst>(<any_params>);
056: *
057: * @author swaroop belur(belurs)
058: * @since 1.2.1
059: */
060:
061: public interface IFinder {
062:
063: static final int LOAD = 1;
064:
065: static final int STORE = 2;
066:
067: static final int TRY = 3;
068:
069: static final int BRANCH = 4;
070:
071: static final int BASE = 5;
072:
073: boolean isCategory1AddSub(int pos);
074:
075: boolean isCategory2AddSub(int pos);
076:
077: boolean isCurrentInstStore(int pos);
078:
079: boolean isGotoPrecededByDUPSTORE(int pos);
080:
081: boolean isHandlerEndPresentAtGuardEnd(int i);
082:
083: boolean isEndOfGuard(int pos);
084:
085: boolean isIfConditionForSomeOtherLoop(int pos, StringBuffer lend);
086:
087: boolean isIfFirstIfInLoopCondition(int pos);
088:
089: boolean isIfForLoadClass(IFBlock ifst);
090:
091: boolean isIFForThisElseATernaryIF(int pos, StringBuffer sb);
092:
093: Loop isIfInADoWhile(int pos, IFBlock ifst);
094:
095: Switch.Case isIFInCase(int pos, IFBlock ifs);
096:
097: boolean isIfPartOfTernaryIfCond(int pos);
098:
099: boolean isIFpresentInTernaryList(IFBlock ifst);
100:
101: boolean isIFShortcutORComp(int pos);
102:
103: boolean isIndexEndOfLoop(int pos);
104:
105: boolean isInstrPosAAload(int pos);
106:
107: int isInstAload(int pos, StringBuffer bf);
108:
109: boolean isInstAnyBasicPrimitiveOperation(int pos, StringBuffer sb);
110:
111: boolean isInstAnyCMPInst(int pos);
112:
113: int isInstAnyConstInst(int pos);
114:
115: int isInstdConstInst(int pos);
116:
117: int isInstDloadInst(int pos, StringBuffer sb2);
118:
119: boolean isInstDup(int pos);
120:
121: int isInstFConstInst(int pos);
122:
123: int isInstFloadInst(int pos, StringBuffer sb2);
124:
125: int isInstIConstInst(int pos);
126:
127: int isInstIloadInst(int pos, StringBuffer sb2);
128:
129: int isInstLConstInst(int pos);
130:
131: int isInstLloadInst(int pos, StringBuffer sb2);
132:
133: boolean isInstLoopStart(int pos);
134:
135: boolean isInstPrimitiveArrayStore(int inst);
136:
137: boolean isInstReturnInst(int pos, StringBuffer sb);
138:
139: boolean isInstructionAnyDUP(int inst);
140:
141: boolean isInstructionIF(int instructionpos);
142:
143: boolean isInstStore0(int pos);
144:
145: boolean isNextInstAStore(int pos);
146:
147: boolean isNextInstIINC(int pos, int index, java.lang.String type);
148:
149: boolean isNextInstructionAnyInvoke(int pos, StringBuffer sb);
150:
151: boolean isNextInstructionConversionInst(int pos);
152:
153: public int isNextInstructionConversionInst(int pos,
154: StringBuffer value);
155:
156: boolean isNextInstructionInvokeInterface(int nextInst);
157:
158: boolean isNextInstructionInvokeSpecial(int nextInst);
159:
160: boolean isNextInstructionInvokeStatic(int nextInst);
161:
162: boolean isNextInstructionInvokeVirtual(int nextInst);
163:
164: boolean isNextInstructionLoad(int pos);
165:
166: boolean isNextInstructionPop(int pos);
167:
168: boolean isNextInstructionPrimitiveStoreInst(int pos,
169: StringBuffer index);
170:
171: boolean isNextInstructionReturn(int nextInstruction);
172:
173: boolean isNextInstructionStore(int nextInstruction);
174:
175: boolean isPrevInstALOADInst(int pos, StringBuffer s);
176:
177: boolean isPrevInstIINC(int current, int index);
178:
179: boolean isPrevInstIloadInst(int s, StringBuffer sb2);
180:
181: boolean isPrevInstPrimitiveLoad(int pos, StringBuffer sb);
182:
183: boolean isPrevInstructionAload(int pos, StringBuffer sb);
184:
185: boolean isPreviousInst(int current, int lookfor);
186:
187: boolean isStoreInst(int index, StringBuffer varindex, StringBuffer t);
188:
189: boolean isStoreInst(int index, byte[] info);
190:
191: boolean isThisDUPSTOREAtEndOFTernaryIF(int pos,
192: java.lang.String type);
193:
194: boolean isThisIfALoopCondition(IFBlock IF);
195:
196: boolean isThisInstASTOREInst(int pos, StringBuffer sb);
197:
198: boolean isThisInstrStart(int pos);
199:
200: boolean isThisInstructionIStoreInst(int s, StringBuffer sb);
201:
202: boolean isThisInstructionIStoreInst(byte[] code, int s,
203: StringBuffer sb);
204:
205: boolean isThisLoopEndAlso(int i, int ifstart);
206:
207: boolean isThisLoopStart(IFBlock IF);
208:
209: boolean isThisTryStart(int i);
210:
211: boolean isPrevInstDup(int pos);
212:
213: boolean lastIFinShortCutChain(IFBlock ifst, int i);
214:
215: int getPrevStartOfInst(int current);
216:
217: int getOffset(int counter);
218:
219: int getJumpAddress(int counter);
220:
221: boolean isInstReturnInst(byte[] code, int pos, StringBuffer sb);
222:
223: boolean isNextInstructionIf(int nextInstruction);
224:
225: boolean checkForSomeSpecificInstructions(byte[] code, int i);
226: }
|