Source Code Cross Referenced for IFACMPEQCommand.java in  » Development » jdec » net » sf » jdec » jvminstructions » commands » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Development » jdec » net.sf.jdec.jvminstructions.commands 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.jdec.jvminstructions.commands;
002:
003:        import net.sf.jdec.blockhelpers.BranchHelper;
004:        import net.sf.jdec.blockhelpers.IFHelper;
005:        import net.sf.jdec.blockhelpers.LoopHelper;
006:        import net.sf.jdec.blocks.IFBlock;
007:        import net.sf.jdec.blocks.Loop;
008:        import net.sf.jdec.core.GlobalVariableStore;
009:        import net.sf.jdec.core.JvmOpCodes;
010:        import net.sf.jdec.core.Operand;
011:        import net.sf.jdec.core.OperandStack;
012:        import net.sf.jdec.reflection.Behaviour;
013:        import net.sf.jdec.util.Util;
014:
015:        import java.util.ArrayList;
016:        import java.util.Iterator;
017:
018:        public class IFACMPEQCommand extends AbstractInstructionCommand {
019:
020:            public IFACMPEQCommand(Behaviour context) {
021:                super (context);
022:
023:            }
024:
025:            public int getSkipBytes() {
026:                return 2;
027:            }
028:
029:            public void execute() {
030:                int currentForIndex = getCurrentInstPosInCode();
031:                OperandStack opStack = getStack();
032:                int i = currentForIndex;
033:                Operand op = (Operand) opStack.pop();
034:                Operand op1 = (Operand) opStack.pop();
035:                /*
036:                 * classIndex = ((info[++i] << 8) | info[++i]); classIndex += i - 2;
037:                 */
038:                Loop this Loop;
039:                boolean encounteredAndOrComp = GlobalVariableStore
040:                        .isEncounteredAndOrComp();
041:                boolean isIfInScope = GlobalVariableStore.isIfInScope();
042:                int classIndex = getGenericFinder().getJumpAddress(i);
043:                i++;
044:                i++;
045:                String tempString = "";
046:                IFBlock ifst = new IFBlock();
047:                ifst.setIfStart(currentForIndex);
048:                ifst.setHasIfBeenGenerated(true);
049:                getContext().getMethodIfs().add(ifst);
050:                boolean addBreak = LoopHelper.checkForParentLoopForIF(ifst);
051:                byte[] info = getCode();
052:                BranchHelper.addBranchLabel(classIndex, i, ifst,
053:                        currentForIndex, info);
054:                ArrayList list = getContext().getBehaviourLoops();
055:                boolean isEndOfLoop = LoopHelper.isIndexEndOfLoop(list, ifst
056:                        .getIfCloseLineNumber());
057:                int loopstart = -1;
058:                boolean correctIf = false;
059:                Behaviour behaviour = getContext();
060:
061:                boolean beyondLoop = LoopHelper.isBeyondLoop(ifst
062:                        .getIfCloseLineNumber(), list, info);
063:                this Loop = GlobalVariableStore.getThisLoop();
064:                boolean processIF = true;//checkForTernaryIf(ifst, info, op1.getOperandValue()	+ "!=" + op.getOperandValue());
065:                if (processIF) {
066:
067:                    if (ifst.getDonotclose() == false
068:                            && ifst.getIfCloseLineNumber() == -1) {
069:                        int end = IFHelper.checkIFEndIfUnset(ifst, info,
070:                                currentForIndex);
071:                        ifst.setIfCloseLineNumber(end);
072:                    }
073:
074:                    if (isEndOfLoop) {
075:                        loopstart = LoopHelper.getLoopStartForEnd(ifst
076:                                .getIfCloseLineNumber(), list);
077:                        if (currentForIndex > loopstart) {
078:                            boolean ifinstcodepresent = IFHelper.getIfinst(
079:                                    loopstart, info, currentForIndex);
080:                            if (ifinstcodepresent) {
081:                                correctIf = false;
082:                            } else
083:                                correctIf = true;
084:                        }
085:                    }
086:                    // StringBuffer
087:                    if ((ifst.getIfCloseLineNumber() > 0 && ifst
088:                            .getIfCloseLineNumber() < info.length)
089:                            && info[ifst.getIfCloseLineNumber()] == JvmOpCodes.GOTO
090:                            && isEndOfLoop && correctIf) {
091:                        int t = ifst.getIfCloseLineNumber();
092:                        int gotoIndex = getGenericFinder().getJumpAddress(t);// (info[t+1] << 8) |
093:                        // info[t+2]) +
094:                        // (ifst.getIfCloseLineNumber());
095:                        if (gotoIndex < (t + 3)) {
096:                            boolean isInfiniteLoop = false;
097:                            Iterator infLoop = getContext().getBehaviourLoops()
098:                                    .iterator();
099:                            while (infLoop.hasNext()) {
100:                                Loop iloop = (Loop) infLoop.next();
101:                                if (iloop.getStartIndex() == gotoIndex
102:                                        && iloop.isInfinite()) {
103:                                    isInfiniteLoop = true;
104:                                    /*
105:                                     * ifLevel++; ifst = new IFBlock();
106:                                     * ifst.setIfStart(currentForIndex);
107:                                     * ifst.setHasIfBeenGenerated(true);
108:                                     */
109:                                    // ifst.setIfCloseLineNumber(classIndex-3);
110:                                    ifst.setElseCloseLineNumber(gotoIndex);
111:                                    /*
112:                                     * ifHashTable.put(""+(ifLevel),ifst);
113:                                     * addBranchLabel(classIndex,i,ifst,currentForIndex,info);
114:                                     */
115:                                    boolean bb = LoopHelper.isBeyondLoop(
116:                                            getGenericFinder().getJumpAddress(
117:                                                    currentForIndex),
118:                                            getContext().getBehaviourLoops(),
119:                                            info);
120:                                    this Loop = GlobalVariableStore
121:                                            .getThisLoop();
122:                                    boolean print = true;
123:                                    boolean addifbreak = false;
124:                                    if (bb && this Loop != null
125:                                            && this Loop.isInfinite()
126:                                            && !encounteredAndOrComp
127:                                            && addBreak) {
128:                                        Loop dowl = LoopHelper.isIfInADoWhile(
129:                                                currentForIndex, ifst,
130:                                                getContext()
131:                                                        .getBehaviourLoops());
132:                                        if (dowl != null) {
133:                                            tempString = "";
134:                                        } else {
135:                                            tempString = "\nif("
136:                                                    + op1.getOperandValue()
137:                                                    + "=="
138:                                                    + op.getOperandValue()
139:                                                    + ")\n{\nbreak;\n}\n";
140:                                            // codeStatements
141:                                            // +=Util.formatDecompiledStatement(tempString);
142:                                            addifbreak = true;
143:                                        }
144:                                        // ifst.setIfHasBeenClosed(true);
145:                                        print = false;
146:                                    }
147:                                    isIfInScope = true;
148:                                    boolean c;
149:                                    boolean last = IFHelper
150:                                            .lastIFinShortCutChain(info, ifst,
151:                                                    currentForIndex);
152:                                    c = IFHelper.addCodeStatementWRTShortcutOR(
153:                                            ifst, op1.getOperandValue()
154:                                                    + " == "
155:                                                    + op.getOperandValue(),
156:                                            print, "if", last, op1
157:                                                    .getOperandValue()
158:                                                    + " != "
159:                                                    + op.getOperandValue());
160:                                    if (c) {
161:                                        if (addifbreak) {
162:                                            behaviour
163:                                                    .appendToBuffer(Util
164:                                                            .formatDecompiledStatement(tempString));
165:                                        }
166:
167:                                        tempString = "\nif(!"
168:                                                + op1.getOperandValue() + "=="
169:                                                + op.getOperandValue()
170:                                                + "))\n{\n";
171:                                        behaviour
172:                                                .appendToBuffer(Util
173:                                                        .formatDecompiledStatement(tempString));
174:                                    } else {
175:                                        boolean firstIfForLoop = LoopHelper
176:                                                .isIfFirstIfInLoopCondition(
177:                                                        info, currentForIndex);
178:                                        if (firstIfForLoop) {
179:                                            IFHelper
180:                                                    .registerElseBreakForIfChain(currentForIndex);
181:                                        }
182:                                    }
183:                                    break;
184:                                }
185:                            }
186:                            if (isInfiniteLoop) {
187:                                GlobalVariableStore
188:                                        .setEncounteredAndOrComp(encounteredAndOrComp);
189:                                GlobalVariableStore.setIfInScope(isIfInScope);
190:                                GlobalVariableStore.setThisLoop(this Loop);
191:
192:                                return;
193:                            }
194:                            boolean last = IFHelper.lastIFinShortCutChain(info,
195:                                    ifst, currentForIndex);
196:                            boolean c = IFHelper.addCodeStatementWRTShortcutOR(
197:                                    ifst, op1.getOperandValue() + " == "
198:                                            + op.getOperandValue(), true,
199:                                    "while", last, op1.getOperandValue()
200:                                            + " != " + op.getOperandValue());
201:                            if (c) {
202:                                tempString = "\nwhile(!"
203:                                        + op1.getOperandValue() + "=="
204:                                        + op.getOperandValue() + "))\n{\n";
205:                                behaviour.appendToBuffer(Util
206:                                        .formatDecompiledStatement(tempString));
207:                            }
208:                            /*isWhileInScope = true;
209:                            whileIndex++;*/
210:
211:                        }
212:                        // int x = 0;
213:                        else {
214:
215:                            /*
216:                             * ifLevel++; ifst = new IFBlock();
217:                             * ifst.setIfStart(currentForIndex);
218:                             * ifst.setHasIfBeenGenerated(true);
219:                             * //ifst.setIfCloseLineNumber(classIndex-3);
220:                             */
221:
222:                            ifst.setElseCloseLineNumber(gotoIndex);
223:                            /*
224:                             * ifHashTable.put(""+(ifLevel),ifst); isIfInScope = true;
225:                             */
226:
227:                            // addBranchLabel(classIndex,i,ifst,currentForIndex,info);
228:                            isIfInScope = true;
229:                            boolean bb = LoopHelper.isBeyondLoop(
230:                                    getGenericFinder().getJumpAddress(
231:                                            currentForIndex), getContext()
232:                                            .getBehaviourLoops(), info);
233:                            this Loop = GlobalVariableStore.getThisLoop();
234:                            boolean print = true;
235:                            boolean addifbreak = false;
236:                            if (bb && this Loop != null && this Loop.isInfinite()
237:                                    && !encounteredAndOrComp && addBreak) {
238:                                Loop dowl = LoopHelper.isIfInADoWhile(
239:                                        currentForIndex, ifst, getContext()
240:                                                .getBehaviourLoops());
241:                                if (dowl != null) {
242:                                    tempString = "";
243:                                } else {
244:                                    tempString = "\nif("
245:                                            + op1.getOperandValue() + "=="
246:                                            + op.getOperandValue()
247:                                            + ")\n{\nbreak;\n}\n";
248:                                    // codeStatements
249:                                    // +=Util.formatDecompiledStatement(tempString);
250:                                    addifbreak = true;
251:                                }
252:                                print = false;
253:
254:                            }
255:                            boolean last = IFHelper.lastIFinShortCutChain(info,
256:                                    ifst, currentForIndex);
257:                            boolean c = IFHelper.addCodeStatementWRTShortcutOR(
258:                                    ifst, op1.getOperandValue() + " == "
259:                                            + op.getOperandValue(), print,
260:                                    "if", last, op1.getOperandValue() + " != "
261:                                            + op.getOperandValue());
262:                            if (c) {
263:                                if (addifbreak) {
264:                                    behaviour
265:                                            .appendToBuffer(Util
266:                                                    .formatDecompiledStatement(tempString));
267:                                }
268:
269:                                tempString = "\nif(!" + op1.getOperandValue()
270:                                        + "==" + op.getOperandValue()
271:                                        + "))\n{\n";
272:                                behaviour.appendToBuffer(Util
273:                                        .formatDecompiledStatement(tempString));
274:                            } else {
275:                                boolean firstIfForLoop = LoopHelper
276:                                        .isIfFirstIfInLoopCondition(info,
277:                                                currentForIndex);
278:                                if (firstIfForLoop) {
279:                                    IFHelper
280:                                            .registerElseBreakForIfChain(currentForIndex);
281:                                }
282:                            }
283:
284:                        }
285:                    } else {
286:                        /*
287:                         * ifLevel++; ifst = new IFBlock();
288:                         * ifst.setIfStart(currentForIndex);
289:                         * ifst.setHasIfBeenGenerated(true); isIfInScope = true;
290:                         * ifHashTable.put(""+(ifLevel),ifst);
291:                         * 
292:                         * addBranchLabel(classIndex,i,ifst,currentForIndex,info);
293:                         */
294:                        isIfInScope = true;
295:                        boolean bb = LoopHelper.isBeyondLoop(getGenericFinder()
296:                                .getJumpAddress(currentForIndex), getContext()
297:                                .getBehaviourLoops(), info);
298:                        boolean print = true;
299:                        this Loop = GlobalVariableStore.getThisLoop();
300:                        boolean addifbreak = false;
301:                        if (bb && this Loop != null && this Loop.isInfinite()
302:                                && !encounteredAndOrComp && addBreak) {
303:                            Loop dowl = LoopHelper.isIfInADoWhile(
304:                                    currentForIndex, ifst, getContext()
305:                                            .getBehaviourLoops());
306:                            if (dowl != null) {
307:                                tempString = "";
308:                            } else {
309:                                tempString = "\nif(" + op1.getOperandValue()
310:                                        + "==" + op.getOperandValue()
311:                                        + ")\n{\nbreak;\n}\n";
312:                                // odeStatements
313:                                // +=Util.formatDecompiledStatement(tempString);
314:                                addifbreak = true;
315:                            }
316:                            print = false;
317:                            // ifst.setIfHasBeenClosed(true);
318:
319:                        }
320:                        boolean last = IFHelper.lastIFinShortCutChain(info,
321:                                ifst, currentForIndex);
322:                        boolean c = IFHelper.addCodeStatementWRTShortcutOR(
323:                                ifst, op1.getOperandValue() + " == "
324:                                        + op.getOperandValue(), print, "if",
325:                                last, op1.getOperandValue() + " != "
326:                                        + op.getOperandValue());
327:                        if (c) {
328:                            if (addifbreak) {
329:                                behaviour.appendToBuffer(Util
330:                                        .formatDecompiledStatement(tempString));
331:                            }
332:                            if (op1.getOperandValue().equals("null")) {
333:                                tempString = "\nif(" + op1.getOperandValue()
334:                                        + " !=" + op.getOperandValue()
335:                                        + "))\n{\n";
336:                            } else
337:                                tempString = "\nif(!" + op1.getOperandValue()
338:                                        + "==" + op.getOperandValue()
339:                                        + "))\n{\n";
340:                            behaviour.appendToBuffer(Util
341:                                    .formatDecompiledStatement(tempString));
342:                        } else {
343:                            boolean firstIfForLoop = LoopHelper
344:                                    .isIfFirstIfInLoopCondition(info,
345:                                            currentForIndex);
346:                            if (firstIfForLoop) {
347:                                IFHelper
348:                                        .registerElseBreakForIfChain(currentForIndex);
349:                            }
350:                        }
351:                    }
352:                }
353:
354:                GlobalVariableStore
355:                        .setEncounteredAndOrComp(encounteredAndOrComp);
356:                GlobalVariableStore.setIfInScope(isIfInScope);
357:                GlobalVariableStore.setThisLoop(thisLoop);
358:
359:            }
360:
361:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.