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