Source Code Cross Referenced for IFNONNULLCommand.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 IFNONNULLCommand extends AbstractInstructionCommand {
019:
020:            public IFNONNULLCommand(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;
039:                boolean encounteredAndOrComp = GlobalVariableStore
040:                        .isEncounteredAndOrComp();
041:                boolean isIfInScope = GlobalVariableStore.isIfInScope();
042:                Operand op = (Operand) opStack.pop();
043:                // op1 = (Operand)opStack.pop();
044:                int i = currentForIndex;
045:
046:                int classIndex = getGenericFinder().getJumpAddress(i);
047:                i += 2;
048:
049:                ArrayList list = getContext().getBehaviourLoops();
050:
051:                IFBlock ifst = new IFBlock();
052:                ifst.setIfStart(currentForIndex);
053:                ifst.setHasIfBeenGenerated(true);
054:                getContext().getMethodIfs().add(ifst);
055:                boolean addBreak = LoopHelper.checkForParentLoopForIF(ifst);
056:                BranchHelper.addBranchLabel(classIndex, i, ifst,
057:                        currentForIndex, info);
058:                boolean isEndOfLoop = LoopHelper.isIndexEndOfLoop(list, ifst
059:                        .getIfCloseLineNumber());
060:                boolean beyondLoop = LoopHelper.isBeyondLoop(ifst
061:                        .getIfCloseLineNumber(), list, info);
062:                boolean correctIf = false;
063:                this Loop = GlobalVariableStore.getThisLoop();
064:                boolean process = IFHelper.isIfForLoadClass(ifst, info);
065:                if (process) {
066:                    process = true;//IFHelper.checkForTernaryIf(ifst, info, op.getOperandValue()					+ " == null");
067:                }
068:                if (ifst.getDonotclose() == false
069:                        && ifst.getIfCloseLineNumber() == -1) {
070:                    int if_end = IFHelper.checkIFEndIfUnset(ifst, info,
071:                            currentForIndex);
072:                    ifst.setIfCloseLineNumber(if_end);
073:                }
074:                if (isEndOfLoop) {
075:                    int 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:                if (process) {
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:                            if (gotoIndex < classIndex) {
097:                                boolean isInfiniteLoop = false;
098:                                Iterator infLoop = getContext()
099:                                        .getBehaviourLoops().iterator();
100:                                while (infLoop.hasNext()) {
101:                                    Loop iloop = (Loop) infLoop.next();
102:                                    if (iloop.getStartIndex() == gotoIndex
103:                                            && iloop.isInfinite()) {
104:                                        isInfiniteLoop = true;
105:
106:                                        ifst.setElseCloseLineNumber(gotoIndex);
107:
108:                                        isIfInScope = true;
109:                                        boolean print = true;
110:                                        boolean addifbreak = false;
111:                                        boolean bb = LoopHelper
112:                                                .isBeyondLoop(
113:                                                        getGenericFinder()
114:                                                                .getJumpAddress(
115:                                                                        currentForIndex),
116:                                                        getContext()
117:                                                                .getBehaviourLoops(),
118:                                                        info);
119:                                        this Loop = GlobalVariableStore
120:                                                .getThisLoop();
121:                                        if (bb && this Loop != null
122:                                                && this Loop.isInfinite()
123:                                                && !encounteredAndOrComp
124:                                                && addBreak) {
125:                                            Loop dowl = LoopHelper
126:                                                    .isIfInADoWhile(
127:                                                            currentForIndex,
128:                                                            ifst,
129:                                                            getContext()
130:                                                                    .getBehaviourLoops());
131:                                            if (dowl != null) {
132:                                                tempString = "";
133:                                            } else {
134:                                                tempString = "\nif("
135:                                                        + op.getOperandValue()
136:                                                        + "!= null)\n{\nbreak;\n}\n";
137:                                                // ifst.setIfHasBeenClosed(true);
138:                                                // codeStatements
139:                                                // +=Util.formatDecompiledStatement(tempString);
140:                                                addifbreak = true;
141:                                            }
142:                                            print = false;
143:                                        }
144:                                        boolean last = IFHelper
145:                                                .lastIFinShortCutChain(info,
146:                                                        ifst, currentForIndex);
147:                                        boolean c = IFHelper
148:                                                .addCodeStatementWRTShortcutOR(
149:                                                        ifst,
150:                                                        op.getOperandValue()
151:                                                                + "!=null",
152:                                                        print, "if", last,
153:                                                        op.getOperandValue()
154:                                                                + "== null");
155:                                        if (c) {
156:                                            if (addifbreak) {
157:                                                behavior
158:                                                        .appendToBuffer(Util
159:                                                                .formatDecompiledStatement(tempString));
160:                                            }
161:                                            tempString = "\nif("
162:                                                    + op.getOperandValue()
163:                                                    + "== null)\n{\n";
164:                                            behavior
165:                                                    .appendToBuffer(Util
166:                                                            .formatDecompiledStatement(tempString));
167:                                        } else {
168:                                            boolean firstIfForLoop = LoopHelper
169:                                                    .isIfFirstIfInLoopCondition(
170:                                                            info,
171:                                                            currentForIndex);
172:                                            if (firstIfForLoop) {
173:                                                IFHelper
174:                                                        .registerElseBreakForIfChain(currentForIndex);
175:                                            }
176:                                        }
177:
178:                                        break;
179:                                    }
180:                                }
181:                                if (isInfiniteLoop) {
182:                                    GlobalVariableStore
183:                                            .setEncounteredAndOrComp(encounteredAndOrComp);
184:                                    GlobalVariableStore
185:                                            .setIfInScope(isIfInScope);
186:                                    GlobalVariableStore.setThisLoop(this Loop);
187:
188:                                    return;
189:                                }
190:                                boolean last = IFHelper.lastIFinShortCutChain(
191:                                        info, ifst, currentForIndex);
192:                                boolean c = IFHelper
193:                                        .addCodeStatementWRTShortcutOR(ifst, op
194:                                                .getOperandValue()
195:                                                + "!=null", true, "while",
196:                                                last, op.getOperandValue()
197:                                                        + "==null");
198:                                if (c) {
199:                                    tempString = "\nwhile("
200:                                            + op.getOperandValue()
201:                                            + " == null)\n{\n";
202:                                    behavior
203:                                            .appendToBuffer(Util
204:                                                    .formatDecompiledStatement(tempString));
205:                                }
206:
207:                            } else {
208:
209:                                ifst.setElseCloseLineNumber(gotoIndex);
210:
211:                                isIfInScope = true;
212:                                boolean print = true;
213:                                boolean addifbreak = false;
214:                                boolean bb = LoopHelper.isBeyondLoop(
215:                                        getGenericFinder().getJumpAddress(
216:                                                currentForIndex), getContext()
217:                                                .getBehaviourLoops(), info);
218:                                this Loop = GlobalVariableStore.getThisLoop();
219:                                if (bb && this Loop != null
220:                                        && this Loop.isInfinite()
221:                                        && !encounteredAndOrComp && addBreak) {
222:                                    Loop dowl = LoopHelper.isIfInADoWhile(
223:                                            currentForIndex, ifst, getContext()
224:                                                    .getBehaviourLoops());
225:                                    if (dowl != null) {
226:                                        tempString = "";
227:                                    } else {
228:                                        tempString = "\nif("
229:                                                + op.getOperandValue()
230:                                                + "!= null)\n{\nbreak;\n}\n";
231:                                        // ifst.setIfHasBeenClosed(true);
232:                                        // codeStatements
233:                                        // +=Util.formatDecompiledStatement(tempString);
234:                                        addifbreak = true;
235:                                    }
236:                                    print = false;
237:                                }
238:                                boolean last = IFHelper.lastIFinShortCutChain(
239:                                        info, ifst, currentForIndex);
240:                                boolean c = IFHelper
241:                                        .addCodeStatementWRTShortcutOR(ifst, op
242:                                                .getOperandValue()
243:                                                + "!=null", print, "if", last,
244:                                                op.getOperandValue() + "==null");
245:                                if (c) {
246:                                    if (addifbreak) {
247:                                        behavior
248:                                                .appendToBuffer(Util
249:                                                        .formatDecompiledStatement(tempString));
250:                                    }
251:                                    tempString = "\nif(" + op.getOperandValue()
252:                                            + "== null)\n{\n";
253:                                    behavior
254:                                            .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:                        isIfInScope = true;
271:                        // addBranchLabel(classIndex,i,ifst,currentForIndex,info);
272:                        boolean bb = LoopHelper.isBeyondLoop(getGenericFinder()
273:                                .getJumpAddress(currentForIndex), getContext()
274:                                .getBehaviourLoops(), info);
275:                        this Loop = GlobalVariableStore.getThisLoop();
276:                        boolean print = true;
277:                        boolean addifbreak = false;
278:                        if (bb && this Loop != null && this Loop.isInfinite()
279:                                && !encounteredAndOrComp && addBreak) {
280:
281:                            Loop dowl = LoopHelper.isIfInADoWhile(
282:                                    currentForIndex, ifst, getContext()
283:                                            .getBehaviourLoops());
284:                            if (dowl != null) {
285:                                tempString = "";
286:                            } else {
287:                                tempString = "\nif(" + op.getOperandValue()
288:                                        + "!= null)\n{\nbreak;\n}\n";
289:                                // ifst.setIfHasBeenClosed(true);
290:                                // codeStatements
291:                                // +=Util.formatDecompiledStatement(tempString);
292:                                addifbreak = true;
293:                            }
294:                            print = false;
295:                        }
296:
297:                        boolean last = IFHelper.lastIFinShortCutChain(info,
298:                                ifst, currentForIndex);
299:                        boolean c = IFHelper.addCodeStatementWRTShortcutOR(
300:                                ifst, op.getOperandValue() + "!=null", print,
301:                                "if", last, op.getOperandValue() + "==null");
302:
303:                        if (c) {
304:                            if (addifbreak) {
305:                                behavior.appendToBuffer(Util
306:                                        .formatDecompiledStatement(tempString));
307:                            }
308:                            tempString = "\nif(" + op.getOperandValue()
309:                                    + "== null)\n{\n";
310:                            behavior.appendToBuffer(Util
311:                                    .formatDecompiledStatement(tempString));
312:                        } else {
313:                            boolean firstIfForLoop = LoopHelper
314:                                    .isIfFirstIfInLoopCondition(info,
315:                                            currentForIndex);
316:                            if (firstIfForLoop) {
317:                                IFHelper
318:                                        .registerElseBreakForIfChain(currentForIndex);
319:                            }
320:                        }
321:
322:                    }
323:                }
324:                GlobalVariableStore
325:                        .setEncounteredAndOrComp(encounteredAndOrComp);
326:                GlobalVariableStore.setIfInScope(isIfInScope);
327:                GlobalVariableStore.setThisLoop(thisLoop);
328:
329:            }
330:
331:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.