Source Code Cross Referenced for IFLECommand.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 IFLECommand extends AbstractInstructionCommand {
019:
020:            public IFLECommand(Behaviour context) {
021:                super (context);
022:
023:            }
024:
025:            public int getSkipBytes() {
026:                return 2;
027:            }
028:
029:            public void execute() {
030:                String tempString = "";
031:                String tempstr = "";
032:                byte[] info = getCode();
033:                int currentForIndex = getCurrentInstPosInCode();
034:                int prevStart = getGenericFinder().getPrevStartOfInst(
035:                        currentForIndex);
036:                OperandStack opStack = getStack();
037:                Behaviour behavior = getContext();
038:
039:                Loop this Loop;
040:                boolean encounteredAndOrComp = GlobalVariableStore
041:                        .isEncounteredAndOrComp();
042:                boolean isIfInScope = GlobalVariableStore.isIfInScope();
043:                Operand op = (Operand) opStack.pop();
044:
045:                // op1 = (Operand)opStack.pop();
046:                int i = currentForIndex;
047:
048:                int classIndex = getGenericFinder().getJumpAddress(i);
049:                i += 2;
050:
051:                // int s=info[classIndex-3];
052:                ArrayList list = getContext().getBehaviourLoops();
053:
054:                IFBlock ifst = new IFBlock();
055:                ifst.setIfStart(currentForIndex);
056:                ifst.setHasIfBeenGenerated(true);
057:                getContext().getMethodIfs().add(ifst);
058:                boolean addBreak = LoopHelper.checkForParentLoopForIF(ifst);
059:                BranchHelper.addBranchLabel(classIndex, i, ifst,
060:                        currentForIndex, info);
061:
062:                boolean isEndOfLoop = LoopHelper.isIndexEndOfLoop(list, ifst
063:                        .getIfCloseLineNumber());
064:                boolean beyondLoop = LoopHelper.isBeyondLoop(ifst
065:                        .getIfCloseLineNumber(), list, info);
066:                this Loop = GlobalVariableStore.getThisLoop();
067:                boolean correctIf = false;
068:                if (info[currentForIndex - 1] != JvmOpCodes.DCMPG
069:                        && info[currentForIndex - 1] != JvmOpCodes.DCMPL
070:                        && info[currentForIndex - 1] != JvmOpCodes.FCMPG
071:                        && info[currentForIndex - 1] != JvmOpCodes.FCMPL
072:                        && info[currentForIndex - 1] != JvmOpCodes.LCMP) {
073:
074:                    tempstr = op.getOperandValue() + " <= 0";
075:                } else {
076:
077:                    tempstr = op.getOperandValue();
078:                }
079:                boolean processIF = true;// checkForTernaryIf(ifst, info, tempstr);
080:                if (processIF) {
081:                    if (ifst.getDonotclose() == false
082:                            && ifst.getIfCloseLineNumber() == -1) {
083:                        int if_end = IFHelper.checkIFEndIfUnset(ifst, info,
084:                                currentForIndex);
085:                        ifst.setIfCloseLineNumber(if_end);
086:                    }
087:                    if (isEndOfLoop) {
088:                        int loopstart = LoopHelper.getLoopStartForEnd(ifst
089:                                .getIfCloseLineNumber(), list);
090:                        if (currentForIndex > loopstart) {
091:                            boolean ifinstcodepresent = IFHelper.getIfinst(
092:                                    loopstart, info, currentForIndex);
093:                            if (ifinstcodepresent) {
094:                                correctIf = false;
095:                            } else
096:                                correctIf = true;
097:                        } else {
098:                            correctIf = false;
099:                        }
100:
101:                    }
102:
103:                    /*
104:                     * if(ifst.getIfStart()==ifst.getIfCloseLineNumber()){
105:                     * ifst.setIfCloseLineNumber(-1); ifst.setDonotclose(true);
106:                     * continue; } if(ifst.getIfStart()+3==ifst.getIfCloseLineNumber()){
107:                     * ifst.setIfCloseLineNumber(-1); ifst.setDonotclose(true);
108:                     * continue; }
109:                     */
110:
111:                    if ((ifst.getIfCloseLineNumber() > 0 && ifst
112:                            .getIfCloseLineNumber() < info.length)
113:                            && info[ifst.getIfCloseLineNumber()] == JvmOpCodes.GOTO
114:                            && isEndOfLoop && correctIf) {
115:                        int t = ifst.getIfCloseLineNumber();
116:                        int gotoIndex = getGenericFinder().getJumpAddress(t);// ((info[t+1]
117:                        // << 8)
118:                        // |
119:                        // info[t+2]) +
120:                        // (ifst.getIfCloseLineNumber());
121:                        if (gotoIndex < (t + 3))
122:                            if (gotoIndex < classIndex) {
123:                                boolean isInfiniteLoop = false;
124:                                Iterator infLoop = getContext()
125:                                        .getBehaviourLoops().iterator();
126:                                while (infLoop.hasNext()) {
127:                                    Loop iloop = (Loop) infLoop.next();
128:                                    if (iloop.getStartIndex() == gotoIndex
129:                                            && iloop.isInfinite()) {
130:                                        isInfiniteLoop = true;
131:                                        /*
132:                                         * ifLevel++; ifst = new IFBlock();
133:                                         * ifst.setIfStart(currentForIndex);
134:                                         * ifst.setHasIfBeenGenerated(true);
135:                                         */
136:
137:                                        ifst.setElseCloseLineNumber(gotoIndex);
138:
139:                                        /*
140:                                         * ifHashTable.put(""+(ifLevel),ifst); int
141:                                         * resetVal=checkIfElseCloseNumber(classIndex-3,ifst);
142:                                         * ifst.setIfCloseLineNumber(resetVal);
143:                                         */
144:
145:                                        isIfInScope = true;
146:
147:                                        boolean bb = LoopHelper
148:                                                .isBeyondLoop(
149:                                                        getGenericFinder()
150:                                                                .getJumpAddress(
151:                                                                        currentForIndex),
152:                                                        getContext()
153:                                                                .getBehaviourLoops(),
154:                                                        info);
155:                                        this Loop = GlobalVariableStore
156:                                                .getThisLoop();
157:                                        boolean print = true;
158:                                        boolean addifbreak = false;
159:                                        java.lang.String tempString2 = "";
160:                                        if (bb && this Loop != null
161:                                                && this Loop.isInfinite()
162:                                                && !encounteredAndOrComp
163:                                                && addBreak) {
164:                                            Loop dowl = LoopHelper
165:                                                    .isIfInADoWhile(
166:                                                            currentForIndex,
167:                                                            ifst,
168:                                                            getContext()
169:                                                                    .getBehaviourLoops());
170:                                            if (dowl != null) {
171:                                                tempString = "";
172:                                            } else {
173:                                                if (info[currentForIndex - 1] != JvmOpCodes.DCMPG
174:                                                        && info[currentForIndex - 1] != JvmOpCodes.DCMPL
175:                                                        && info[currentForIndex - 1] != JvmOpCodes.FCMPG
176:                                                        && info[currentForIndex - 1] != JvmOpCodes.FCMPL
177:                                                        && info[currentForIndex - 1] != JvmOpCodes.LCMP)
178:                                                    tempString = "\nif("
179:                                                            + op
180:                                                                    .getOperandValue()
181:                                                            + "<=0)\n{\nbreak;\n}\n";
182:
183:                                                else
184:                                                    tempString = "\nif("
185:                                                            + op
186:                                                                    .getOperandValue()
187:                                                            + ")\n{\nbreak;\n}\n";
188:                                                // codeStatements
189:                                                // +=Util.formatDecompiledStatement(tempString);
190:                                                addifbreak = true;
191:                                                tempString2 = tempString;
192:                                            }
193:                                            print = false;
194:                                            // ifst.setIfHasBeenClosed(true);
195:                                        }
196:
197:                                        tempstr = "";
198:                                        boolean bc = false;
199:
200:                                        if (info[currentForIndex - 1] != JvmOpCodes.DCMPG
201:                                                && info[currentForIndex - 1] != JvmOpCodes.DCMPL
202:                                                && info[currentForIndex - 1] != JvmOpCodes.FCMPG
203:                                                && info[currentForIndex - 1] != JvmOpCodes.FCMPL
204:                                                && info[currentForIndex - 1] != JvmOpCodes.LCMP) {
205:                                            tempString = "\nif("
206:                                                    + op.getOperandValue()
207:                                                    + " > 0)\n{\n";
208:                                            tempstr = op.getOperandValue()
209:                                                    + "<= 0";
210:                                        } else {
211:                                            tempString = "\nif("
212:                                                    + op.getOperandValue()
213:                                                    + " )\n{\n";
214:                                            tempstr = op.getOperandValue();
215:                                            bc = true;
216:                                        }
217:
218:                                        java.lang.String alt;
219:                                        if (bc == false) {
220:                                            alt = op.getOperandValue() + "> 0";
221:                                            ;
222:                                        } else {
223:                                            alt = op.getOperandValue();
224:                                        }
225:
226:                                        boolean last = IFHelper
227:                                                .lastIFinShortCutChain(info,
228:                                                        ifst, currentForIndex);
229:                                        boolean c = IFHelper
230:                                                .addCodeStatementWRTShortcutOR(
231:                                                        ifst, tempstr, print,
232:                                                        "if", last, alt);
233:                                        if (c) {
234:                                            if (addifbreak) {
235:                                                behavior
236:                                                        .appendToBuffer(Util
237:                                                                .formatDecompiledStatement(tempString2));
238:                                            }
239:                                            behavior
240:                                                    .appendToBuffer(Util
241:                                                            .formatDecompiledStatement(tempString));
242:                                        } else {
243:                                            boolean firstIfForLoop = LoopHelper
244:                                                    .isIfFirstIfInLoopCondition(
245:                                                            info,
246:                                                            currentForIndex);
247:                                            if (firstIfForLoop) {
248:                                                IFHelper
249:                                                        .registerElseBreakForIfChain(currentForIndex);
250:                                            }
251:                                        }
252:
253:                                        break;
254:                                    }
255:                                }
256:                                if (isInfiniteLoop) {
257:                                    GlobalVariableStore
258:                                            .setEncounteredAndOrComp(encounteredAndOrComp);
259:                                    GlobalVariableStore
260:                                            .setIfInScope(isIfInScope);
261:                                    GlobalVariableStore.setThisLoop(this Loop);
262:
263:                                    return;
264:                                }
265:                                tempstr = "";
266:                                boolean bc = false;
267:                                if (info[currentForIndex - 1] != JvmOpCodes.DCMPG
268:                                        && info[currentForIndex - 1] != JvmOpCodes.DCMPL
269:                                        && info[currentForIndex - 1] != JvmOpCodes.FCMPG
270:                                        && info[currentForIndex - 1] != JvmOpCodes.FCMPL
271:                                        && info[currentForIndex - 1] != JvmOpCodes.LCMP) {
272:                                    tempString = "\nwhile("
273:                                            + op.getOperandValue()
274:                                            + " > 0)\n{\n";
275:                                    tempstr = op.getOperandValue() + " <= 0";
276:                                } else {
277:                                    tempString = "\nwhile("
278:                                            + op.getOperandValue() + ")\n{\n";
279:                                    tempstr = op.getOperandValue();
280:                                    bc = true;
281:                                }
282:                                java.lang.String alt;
283:                                if (bc == false) {
284:                                    alt = op.getOperandValue() + "> 0";
285:                                    ;
286:                                } else {
287:                                    alt = op.getOperandValue();
288:                                }
289:
290:                                boolean last = IFHelper.lastIFinShortCutChain(
291:                                        info, ifst, currentForIndex);
292:                                boolean c = IFHelper
293:                                        .addCodeStatementWRTShortcutOR(ifst,
294:                                                tempstr, true, "while", last,
295:                                                alt);
296:                                if (c)
297:                                    behavior
298:                                            .appendToBuffer(Util
299:                                                    .formatDecompiledStatement(tempString));
300:
301:                            } else {
302:                                /*
303:                                 * ifLevel++; ifst = new IFBlock();
304:                                 * ifst.setIfStart(currentForIndex);
305:                                 * ifst.setHasIfBeenGenerated(true);
306:                                 */
307:                                ifst.setElseCloseLineNumber(gotoIndex);
308:                                /*
309:                                 * ifHashTable.put(""+(ifLevel),ifst); int
310:                                 * resetVal=checkIfElseCloseNumber(classIndex-3,ifst);
311:                                 * ifst.setIfCloseLineNumber(resetVal); isIfInScope =
312:                                 * true;
313:                                 */
314:                                isIfInScope = true;
315:                                // addBranchLabel(classIndex,i,ifst,currentForIndex,info);
316:                                boolean bb = LoopHelper.isBeyondLoop(
317:                                        getGenericFinder().getJumpAddress(
318:                                                currentForIndex), getContext()
319:                                                .getBehaviourLoops(), info);
320:                                this Loop = GlobalVariableStore.getThisLoop();
321:                                boolean print = true;
322:                                boolean addifbreak = false;
323:                                java.lang.String tempString2 = "";
324:
325:                                if (bb && this Loop != null
326:                                        && this Loop.isInfinite()
327:                                        && !encounteredAndOrComp && addBreak) {
328:                                    Loop dowl = LoopHelper.isIfInADoWhile(
329:                                            currentForIndex, ifst, getContext()
330:                                                    .getBehaviourLoops());
331:                                    if (dowl != null) {
332:                                        tempString = "";
333:                                    } else {
334:                                        if (info[currentForIndex - 1] != JvmOpCodes.DCMPG
335:                                                && info[currentForIndex - 1] != JvmOpCodes.DCMPL
336:                                                && info[currentForIndex - 1] != JvmOpCodes.FCMPG
337:                                                && info[currentForIndex - 1] != JvmOpCodes.FCMPL
338:                                                && info[currentForIndex - 1] != JvmOpCodes.LCMP)
339:                                            tempString = "\nif("
340:                                                    + op.getOperandValue()
341:                                                    + "<=0)\n{\nbreak;\n}\n";
342:
343:                                        else
344:                                            tempString = "\nif("
345:                                                    + op.getOperandValue()
346:                                                    + ")\n{\nbreak;\n}\n";
347:                                        // codeStatements
348:                                        // +=Util.formatDecompiledStatement(tempString);
349:                                        tempString2 = tempString;
350:                                        addifbreak = true;
351:                                    }
352:                                    print = false;
353:                                    // ifst.setIfHasBeenClosed(true);
354:                                }
355:
356:                                tempstr = "";
357:                                boolean bc = false;
358:                                if (info[currentForIndex - 1] != JvmOpCodes.DCMPG
359:                                        && info[currentForIndex - 1] != JvmOpCodes.DCMPL
360:                                        && info[currentForIndex - 1] != JvmOpCodes.FCMPG
361:                                        && info[currentForIndex - 1] != JvmOpCodes.FCMPL
362:                                        && info[currentForIndex - 1] != JvmOpCodes.LCMP) {
363:                                    tempString = "\nif(" + op.getOperandValue()
364:                                            + " > 0)\n{\n";
365:                                    tempstr = op.getOperandValue() + " <= 0";
366:                                } else {
367:                                    tempString = "\nif(" + op.getOperandValue()
368:                                            + " )\n{\n";
369:                                    tempstr = op.getOperandValue();
370:                                    bc = true;
371:                                }
372:                                java.lang.String alt;
373:                                if (bc == false) {
374:                                    alt = op.getOperandValue() + "> 0";
375:                                    ;
376:                                } else {
377:                                    alt = op.getOperandValue();
378:                                }
379:
380:                                boolean last = IFHelper.lastIFinShortCutChain(
381:                                        info, ifst, currentForIndex);
382:                                boolean c = IFHelper
383:                                        .addCodeStatementWRTShortcutOR(ifst,
384:                                                tempstr, print, "if", last, alt);
385:                                if (c) {
386:                                    if (addifbreak) {
387:                                        behavior
388:                                                .appendToBuffer(Util
389:                                                        .formatDecompiledStatement(tempString2));
390:                                    }
391:                                    behavior
392:                                            .appendToBuffer(Util
393:                                                    .formatDecompiledStatement(tempString));
394:                                } else {
395:                                    boolean firstIfForLoop = LoopHelper
396:                                            .isIfFirstIfInLoopCondition(info,
397:                                                    currentForIndex);
398:                                    if (firstIfForLoop) {
399:                                        IFHelper
400:                                                .registerElseBreakForIfChain(currentForIndex);
401:                                    }
402:                                }
403:
404:                            }
405:
406:                    } else {
407:                        /*
408:                         * ifLevel++; ifst = new IFBlock();
409:                         * ifst.setIfStart(currentForIndex);
410:                         * ifst.setHasIfBeenGenerated(true);
411:                         * ifHashTable.put(""+(ifLevel),ifst);
412:                         */
413:                        isIfInScope = true;
414:                        // addBranchLabel(classIndex,i,ifst,currentForIndex,info);
415:                        boolean bb = LoopHelper.isBeyondLoop(getGenericFinder()
416:                                .getJumpAddress(currentForIndex), getContext()
417:                                .getBehaviourLoops(), info);
418:                        this Loop = GlobalVariableStore.getThisLoop();
419:                        boolean print = true;
420:                        boolean addifbreak = false;
421:                        java.lang.String tempString2 = "";
422:                        if (bb && this Loop != null && this Loop.isInfinite()
423:                                && !encounteredAndOrComp && addBreak) {
424:                            Loop dowl = LoopHelper.isIfInADoWhile(
425:                                    currentForIndex, ifst, getContext()
426:                                            .getBehaviourLoops());
427:                            if (dowl != null) {
428:                                tempString = "";
429:                            } else {
430:                                if (info[currentForIndex - 1] != JvmOpCodes.DCMPG
431:                                        && info[currentForIndex - 1] != JvmOpCodes.DCMPL
432:                                        && info[currentForIndex - 1] != JvmOpCodes.FCMPG
433:                                        && info[currentForIndex - 1] != JvmOpCodes.FCMPL
434:                                        && info[currentForIndex - 1] != JvmOpCodes.LCMP)
435:                                    tempString = "\nif(" + op.getOperandValue()
436:                                            + "<=0)\n{\nbreak;\n}\n";
437:
438:                                else
439:                                    tempString = "\nif(" + op.getOperandValue()
440:                                            + ")\n{\nbreak;\n}\n";
441:                                tempString2 = tempString;
442:                                addifbreak = true;
443:                                // codeStatements
444:                                // +=Util.formatDecompiledStatement(tempString);
445:                            }
446:                            print = false;
447:                        }
448:                        // ifst.setIfHasBeenClosed(true);
449:                        tempstr = "";
450:                        boolean bc = false;
451:                        if (info[currentForIndex - 1] != JvmOpCodes.DCMPG
452:                                && info[currentForIndex - 1] != JvmOpCodes.DCMPL
453:                                && info[currentForIndex - 1] != JvmOpCodes.FCMPG
454:                                && info[currentForIndex - 1] != JvmOpCodes.FCMPL
455:                                && info[currentForIndex - 1] != JvmOpCodes.LCMP) {
456:                            tempString = "\nif(" + op.getOperandValue()
457:                                    + " > 0)\n{\n";
458:                            tempstr = op.getOperandValue() + " <= 0";
459:                        } else {
460:                            tempString = "\nif(" + op.getOperandValue()
461:                                    + " )\n{\n";
462:                            tempstr = op.getOperandValue();
463:                            bc = true;
464:                        }
465:                        java.lang.String alt;
466:                        if (bc == false) {
467:                            alt = op.getOperandValue() + "> 0";
468:                            ;
469:                        } else {
470:                            alt = op.getOperandValue();
471:                        }
472:
473:                        boolean last = IFHelper.lastIFinShortCutChain(info,
474:                                ifst, currentForIndex);
475:                        boolean c = IFHelper.addCodeStatementWRTShortcutOR(
476:                                ifst, tempstr, print, "if", last, alt);
477:                        if (c) {
478:                            if (addifbreak) {
479:                                behavior
480:                                        .appendToBuffer(Util
481:                                                .formatDecompiledStatement(tempString2));
482:                            }
483:                            behavior.appendToBuffer(Util
484:                                    .formatDecompiledStatement(tempString));
485:                        }
486:
487:                        else {
488:                            boolean firstIfForLoop = LoopHelper
489:                                    .isIfFirstIfInLoopCondition(info,
490:                                            currentForIndex);
491:                            if (firstIfForLoop) {
492:                                IFHelper
493:                                        .registerElseBreakForIfChain(currentForIndex);
494:                            }
495:                        }
496:
497:                    }
498:                }
499:                GlobalVariableStore
500:                        .setEncounteredAndOrComp(encounteredAndOrComp);
501:                GlobalVariableStore.setIfInScope(isIfInScope);
502:                GlobalVariableStore.setThisLoop(thisLoop);
503:
504:            }
505:
506:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.