Source Code Cross Referenced for BranchInstrFinder.java in  » Development » jdec » net » sf » jdec » lookup » 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.lookup 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.jdec.lookup;
002:
003:        import net.sf.jdec.blocks.IFBlock;
004:        import net.sf.jdec.blocks.Loop;
005:        import net.sf.jdec.blocks.Switch;
006:        import net.sf.jdec.constantpool.*;
007:        import net.sf.jdec.constantpool.CPString;
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.TernaryTracker;
012:        import net.sf.jdec.util.Util;
013:        import net.sf.jdec.util.ExecutionState;
014:
015:        import java.util.*;
016:
017:        /*
018:         *  BranchInstrFinder.java Copyright (c) 2006,07 Swaroop Belur
019:         *  
020:         * This program is free software; you can redistribute it and/or
021:         * modify it under the terms of the GNU General Public License
022:         * as published by the Free Software Foundation; either version 2
023:         * of the License, or (at your option) any later version.
024:
025:         * This program is distributed in the hope that it will be useful,
026:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
027:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
028:         * GNU General Public License for more details.
029:
030:         * You should have received a copy of the GNU General Public License
031:         * along with this program; if not, write to the Free Software
032:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
033:         *
034:         */
035:
036:        /**
037:         * Implementation methods cover ifs , loops , switch cases Basically any
038:         * instruction which can cause the sequence of execution to be non sequential. 1
039:         * >If jump can lead to an instruction either ahead or behind the current
040:         * instruction pos <p/> 2> Loop is nothing but an if with repetition. <p/> 3>
041:         * Switches can be easily simulated with ifs...
042:         * 
043:         * @author swaroop belur(belurs)
044:         * @since 1.2.1
045:         */
046:        public class BranchInstrFinder extends BasicFinder {
047:
048:            public static final BranchInstrFinder branchFinder = new BranchInstrFinder();
049:
050:            private BranchInstrFinder() {
051:            }
052:
053:            public boolean isCurrentInstStore(int pos) {
054:                throw new UnsupportedOperationException(
055:                        "Invalid call[isCurrentInstStore] on BranchInstrFinder object");
056:            }
057:
058:            public boolean isGotoPrecededByDUPSTORE(int pos) {
059:                throw new UnsupportedOperationException(
060:                        "Invalid call[isGotoPrecededByDUPSTORE] on BranchInstrFinder object");
061:            }
062:
063:            public boolean isHandlerEndPresentAtGuardEnd(int i) {
064:                throw new UnsupportedOperationException(
065:                        "Invalid call[isHandlerEndPresentAtGuardEnd] on BranchInstrFinder object");
066:            }
067:
068:            public boolean isEndOfGuard(int pos) {
069:                throw new UnsupportedOperationException(
070:                        "Invalid call[isEndOfGuard] on BranchInstrFinder object");
071:            }
072:
073:            public boolean isIfConditionForSomeOtherLoop(int i,
074:                    StringBuffer lend) {
075:                List loops = getMethod().getBehaviourLoops();
076:                Object[] sortedLoops = sortLoops(loops);
077:                byte[] info = getMethod().getCode();
078:                int parentLoopStart = getParentLoopStartForIf(sortedLoops, i);
079:                for (int z = 0; z < loops.size(); z++) {
080:                    Loop l = (Loop) loops.get(z);
081:                    int end = l.getEndIndex();
082:                    boolean start = isThisInstrStart(end);
083:                    if (start) {
084:
085:                        int ls = l.getStartIndex();
086:                        if (info[end] == JvmOpCodes.GOTO && ls < end && ls < i
087:                                && i < end && (parentLoopStart == ls)) {
088:                            for (int k = ls; k < end; k++) {
089:                                start = isThisInstrStart(k);
090:                                if (start) {
091:                                    boolean isif = isInstructionIF(k);
092:                                    if (isif) {
093:                                        if (k == i) {
094:                                            lend.append("" + end);
095:                                            return true;
096:                                        } else {
097:                                            return false;
098:                                        }
099:                                    }
100:                                }
101:                            }
102:                        }
103:                    }
104:
105:                }
106:
107:                return false;
108:            }
109:
110:            private Object[] sortLoops(List list) {
111:                Object o[] = list.toArray();
112:                Arrays.sort(o);
113:                return o;
114:            }
115:
116:            private int getParentLoopStartForIf(Object[] sortedloops,
117:                    int ifbegin) {
118:                int reqdStart = -1;
119:                int max = -1;
120:                int pos = 0;
121:                int counter = sortedloops.length - 1;
122:                while (counter >= 0) {
123:                    Object o = sortedloops[counter];
124:                    if (o instanceof  Loop) {
125:                        Loop l = (Loop) o;
126:                        int ls = l.getStartIndex();
127:                        int this LoopEnd = getloopEndForStart(getMethod()
128:                                .getBehaviourLoops(), ls);
129:                        if (ls < ifbegin && !(ifbegin > this LoopEnd)) {
130:                            reqdStart = ls;
131:                            break;
132:                        }
133:
134:                    }
135:                    counter--;
136:                }
137:                return reqdStart;
138:
139:            }
140:
141:            private int getloopEndForStart(ArrayList list, int start) {
142:                for (int i = 0; i < list.size(); i++) {
143:                    Loop l = (Loop) list.get(i);
144:                    if (l.getStartIndex() == start) {
145:                        return l.getEndIndex();
146:                    }
147:                }
148:                return -1;
149:
150:            }
151:
152:            public boolean isIfFirstIfInLoopCondition(int pos) {
153:                Loop loop = getParentLoopForIf(sortLoops(getMethod()
154:                        .getBehaviourLoops()), pos);
155:                if (loop != null) {
156:                    int start = loop.getStartIndex();
157:                    byte[] info = getMethod().getCode();
158:                    for (int x = start; x < info.length; x++) {
159:                        boolean b = isThisInstrStart(x);
160:                        if (b) {
161:                            boolean isif = isInstructionIF(x);
162:                            if (isif) {
163:                                if (x == pos) {
164:                                    return true;
165:                                } else {
166:                                    return false;
167:                                }
168:                            }
169:                        }
170:                    }
171:                }
172:
173:                return false;
174:            }
175:
176:            private Loop getParentLoopForIf(Object[] sortedloops, int ifbegin) {
177:                int reqdStart = -1;
178:                Loop reqdl = null;
179:                int max = -1;
180:                int pos = 0;
181:                int counter = sortedloops.length - 1;
182:                while (counter >= 0) {
183:                    Object o = sortedloops[counter];
184:                    if (o instanceof  Loop) {
185:                        Loop l = (Loop) o;
186:                        int ls = l.getStartIndex();
187:                        int this LoopEnd = getloopEndForStart(getMethod()
188:                                .getBehaviourLoops(), ls);
189:                        if (ls < ifbegin && !(ifbegin > this LoopEnd)) {
190:                            reqdStart = ls;
191:                            reqdl = l;
192:                            break;
193:                        }
194:
195:                    }
196:                    counter--;
197:                }
198:                return reqdl;
199:
200:            }
201:
202:            public boolean isIfForLoadClass(IFBlock ifst) {
203:                boolean p = true;
204:                ClassDescription cd = ExecutionState.getMethodContext()
205:                        .getClassRef().getCd();
206:                int by = ifst.getIfCloseFromByteCode();
207:                byte[] info = getMethod().getCode();
208:                if (by > ifst.getIfStart()) {
209:                    int j = by - 3;
210:                    if (isThisInstrStart(j) && info[j] == JvmOpCodes.GOTO) {
211:                        int k = getJumpAddress(j);
212:                        if ((k - j) == 6) {
213:                            int s = ifst.getIfStart();
214:                            s = s + 3;
215:                            if (info[s] == JvmOpCodes.LDC) {
216:                                int d = (s + 1);
217:                                int offset = info[d];
218:                                if (offset < 0) {
219:                                    offset += 256;
220:                                }
221:
222:                                net.sf.jdec.constantpool.CPString constString = cd
223:                                        .getStringsAtCPoolPosition(offset);
224:                                if (constString == null) {
225:                                    return true;
226:                                }
227:                                java.lang.String stringLiteral = cd
228:                                        .getUTF8String(constString
229:                                                .getUtf8pointer());
230:                                if (stringLiteral == null) {
231:                                    return true;
232:                                }
233:                                s = s + 2;
234:                                if (isThisInstrStart(s)
235:                                        && info[s] == JvmOpCodes.INVOKESTATIC) {
236:                                    int classIndex = getOffset(s);
237:                                    MethodRef mref = cd
238:                                            .getMethodRefAtCPoolPosition(classIndex);
239:                                    java.lang.String name = mref
240:                                            .getMethodName();
241:                                    if (name != null
242:                                            && name.indexOf("class$") != -1) {
243:
244:                                        Operand op = new Operand();
245:                                        StringBuffer sb = new StringBuffer("");
246:                                        Util.checkForImport(stringLiteral, sb);
247:                                        java.lang.String classToLoad = sb
248:                                                .toString()
249:                                                + ".class";
250:                                        boolean yes = isIfPartOfTernaryIfCond(ExecutionState
251:                                                .getCurrentInstructionPosition());
252:                                        /*
253:                                         * if(yes) {
254:                                         * op.setOperandValue(opStack.getTopOfStack().getOperandValue()+classToLoad); }
255:                                         * else
256:                                         */
257:                                        op.setOperandValue(classToLoad);
258:                                        boolean terend = isTernaryEnd(ExecutionState
259:                                                .getCurrentInstructionPosition());
260:                                        if (terend) {
261:                                            op.setOperandValue(op
262:                                                    .getOperandValue()
263:                                                    + ")");
264:                                        }
265:
266:                                        getMethod().getOpStack().push(op);
267:                                        op.setClassType("Class");
268:                                        int next = k + 1;
269:                                        if (info[k] == JvmOpCodes.DUP
270:                                                || info[k] == JvmOpCodes.DUP2) {
271:                                            boolean store = isStoreInst(next);
272:                                            if (store) {
273:                                                k = next;
274:                                            }
275:                                        }
276:                                        GlobalVariableStore
277:                                                .getSkipWRTClassLoadIf()
278:                                                .put(
279:                                                        new Integer(
280:                                                                ifst
281:                                                                        .getIfStart() + 3),
282:                                                        new Integer(k));
283:                                        return false;
284:                                    }
285:                                } else {
286:                                    return true;
287:                                }
288:
289:                            } else if (info[s] == JvmOpCodes.LDC_W) {
290:                                // int d=(s+1);
291:                                int offset = getOffset(s);
292:                                // if(offset < 0)offset+=256;
293:                                CPString constString = cd
294:                                        .getStringsAtCPoolPosition(offset);
295:                                if (constString == null) {
296:                                    return true;
297:                                }
298:                                java.lang.String stringLiteral = cd
299:                                        .getUTF8String(constString
300:                                                .getUtf8pointer());
301:                                if (stringLiteral == null) {
302:                                    return true;
303:                                }
304:                                s = s + 3;
305:                                if (isThisInstrStart(s)
306:                                        && info[s] == JvmOpCodes.INVOKESTATIC) {
307:                                    int classIndex = getOffset(s);
308:                                    MethodRef mref = cd
309:                                            .getMethodRefAtCPoolPosition(classIndex);
310:                                    java.lang.String name = mref
311:                                            .getMethodName();
312:                                    if (name != null
313:                                            && name.indexOf("class$") != -1) {
314:
315:                                        Operand op = new Operand();
316:                                        StringBuffer sb = new StringBuffer("");
317:                                        Util.checkForImport(stringLiteral, sb);
318:                                        java.lang.String classToLoad = sb
319:                                                .toString()
320:                                                + ".class";
321:                                        op.setOperandValue(classToLoad);
322:                                        getMethod().getOpStack().push(op);
323:                                        op.setClassType("Class");
324:                                        GlobalVariableStore
325:                                                .getSkipWRTClassLoadIf()
326:                                                .put(
327:                                                        new Integer(
328:                                                                ifst
329:                                                                        .getIfStart() + 3),
330:                                                        new Integer(k));
331:                                        return false;
332:                                    }
333:                                } else {
334:                                    return true;
335:                                }
336:
337:                            } else {
338:                                return true;
339:
340:                            }
341:
342:                        }
343:
344:                    }
345:
346:                }
347:
348:                return p;
349:            }
350:
351:            public boolean isIFForThisElseATernaryIF(int pos, StringBuffer sb) {
352:                boolean yes = false;
353:
354:                Set methodifs = ExecutionState.getMethodContext()
355:                        .getMethodIfs();
356:                Iterator iterIfHash = methodifs.iterator();
357:                int current = ExecutionState.getCurrentInstructionPosition();
358:                while (iterIfHash.hasNext()) {
359:
360:                    IFBlock ifs = (IFBlock) iterIfHash.next();
361:                    int this ifclose = ifs.getIfCloseLineNumber();
362:                    if ((ifs.getIfCloseLineNumber() - (current)) == 0) {
363:                        boolean present = isIFpresentInTernaryList(ifs);
364:                        if (present) {
365:                            boolean end = isThisGotoTernaryEnd(ifs, current);
366:                            if (end) {
367:                                sb.append("end");
368:                            }
369:                            return true;
370:                        }
371:                    }
372:                }
373:                return yes;
374:            }
375:
376:            private boolean isThisGotoTernaryEnd(IFBlock ifst, int end) {
377:                List ternList = GlobalVariableStore.getTernList();
378:                if (ternList.size() == 0) {
379:                    return false;
380:                }
381:                for (int z = 0; z < ternList.size(); z++) {
382:
383:                    TernaryTracker ternobj = (TernaryTracker) ternList.get(z);
384:                    IFBlock iF = ternobj.getIF();
385:                    if (iF == ifst) {
386:                        int t = ternobj.getTEnd();
387:                        if (t == end) {
388:                            return true;
389:                        }
390:                    }
391:                }
392:                return false;
393:            }
394:
395:            public Loop isIfInADoWhile(int current, IFBlock ifst) {
396:
397:                Loop l = getLoopGivenEnd(current, getMethod()
398:                        .getBehaviourLoops());
399:                byte[] info = getMethod().getCode();
400:                if (l != null) {
401:                    boolean isif = isInstructionIF(current);
402:                    if (isif && isThisInstrStart(current)) {
403:                        return l;
404:                    }
405:                }
406:                return null;
407:            }
408:
409:            private Loop getLoopGivenEnd(int end, ArrayList loops) {
410:                for (int z = 0; z < loops.size(); z++) {
411:                    Loop l = (Loop) loops.get(z);
412:                    if (l.getEndIndex() == end) {
413:                        return l;
414:                    }
415:                }
416:                return null;
417:            }
418:
419:            public Switch.Case isIFInCase(int pos, IFBlock ifs) {
420:                Switch.Case caseblk = null;
421:                boolean present = false;
422:                int ifstart = ifs.getIfStart();
423:                int ifend = ifs.getIfCloseLineNumber();
424:                ArrayList allswitches = getMethod().getAllSwitchBlks();
425:                for (int s = 0; s < allswitches.size(); s++) {
426:
427:                    ArrayList allcases = ((Switch) allswitches.get(s))
428:                            .getAllCases();
429:                    for (int k = 0; k < allcases.size(); k++) {
430:                        Switch.Case cblk = (Switch.Case) allcases.get(k);
431:                        int casestart = cblk.getCaseStart();
432:                        int caseend = cblk.getCaseEnd();
433:                        if (ifstart >= casestart && ifend < caseend) {
434:
435:                            present = true;
436:                            caseblk = cblk;
437:                            break;
438:                        }
439:
440:                    }
441:                    // System.out.println(caseblk);
442:                    if (present) {
443:                        break;
444:                    }
445:
446:                }
447:
448:                return caseblk;
449:
450:            }
451:
452:            public boolean isIfPartOfTernaryIfCond(int pos) {
453:                return false;
454:            }
455:
456:            public boolean isIFpresentInTernaryList(IFBlock ifst) {
457:                return false;
458:            }
459:
460:            public boolean isIFShortcutORComp(int pos) {
461:
462:                boolean b = getMethod().getShortCutAnalyser()
463:                        .isIFShortcutIfCondition(pos);
464:                return b;
465:            }
466:
467:            public boolean isIndexEndOfLoop(int s) {
468:                List list = getMethod().getBehaviourLoops();
469:                boolean ok = false;
470:                for (int st = 0; st < list.size(); st++) {
471:                    if (((Loop) list.get(st)).getEndIndex() == s) {
472:                        return true;
473:                    }
474:                }
475:                return ok;
476:            }
477:
478:            public boolean isInstrPosAAload(int pos) {
479:                throw new UnsupportedOperationException();
480:            }
481:
482:            public int isInstAload(int pos, StringBuffer bf) {
483:                throw new UnsupportedOperationException();
484:            }
485:
486:            public int isInstDloadInst(int pos, StringBuffer sb2) {
487:                throw new UnsupportedOperationException();
488:            }
489:
490:            public int isInstFloadInst(int pos, StringBuffer sb2) {
491:                throw new UnsupportedOperationException();
492:            }
493:
494:            public int isInstIloadInst(int pos, StringBuffer sb2) {
495:                throw new UnsupportedOperationException();
496:            }
497:
498:            public int isInstLloadInst(int pos, StringBuffer sb2) {
499:                throw new UnsupportedOperationException();
500:            }
501:
502:            public boolean isInstLoopStart(int pos) {
503:                ArrayList loops = getMethod().getBehaviourLoops();
504:                for (int z = 0; z < loops.size(); z++) {
505:                    Loop loop = (Loop) loops.get(z);
506:                    int loopstart = loop.getStartIndex();
507:                    if (loopstart == pos) {
508:                        return true;
509:                    }
510:                }
511:                return false;
512:
513:            }
514:
515:            public boolean isInstPrimitiveArrayStore(int inst) {
516:                throw new UnsupportedOperationException();
517:            }
518:
519:            public boolean isInstReturnInst(byte[] code, int pos,
520:                    StringBuffer sb) {
521:
522:                boolean ret = false;
523:                if (isThisInstrStart(pos)) {
524:                    switch (code[pos]) {
525:                    case JvmOpCodes.IRETURN:
526:                        sb.append("ireturn");
527:                        ret = true;
528:                        break;
529:
530:                    case JvmOpCodes.LRETURN:
531:                        sb.append("lreturn");
532:                        ret = true;
533:                        break;
534:                    case JvmOpCodes.FRETURN:
535:                        sb.append("freturn");
536:                        ret = true;
537:                        break;
538:                    case JvmOpCodes.DRETURN:
539:                        sb.append("dreturn");
540:                        ret = true;
541:                        break;
542:                    case JvmOpCodes.ARETURN:
543:                        sb.append("areturn");
544:                        ret = true;
545:                        break;
546:                    case JvmOpCodes.RETURN:
547:                        sb.append("return");
548:                        ret = true;
549:                        break;
550:                    }
551:                }
552:
553:                return ret;
554:
555:            }
556:
557:            public boolean isInstReturnInst(int pos, StringBuffer sb) {
558:
559:                boolean ret = false;
560:                if (isThisInstrStart(pos)) {
561:                    switch (getMethod().getCode()[pos]) {
562:                    case JvmOpCodes.IRETURN:
563:                        sb.append("ireturn");
564:                        ret = true;
565:                        break;
566:
567:                    case JvmOpCodes.LRETURN:
568:                        sb.append("lreturn");
569:                        ret = true;
570:                        break;
571:                    case JvmOpCodes.FRETURN:
572:                        sb.append("freturn");
573:                        ret = true;
574:                        break;
575:                    case JvmOpCodes.DRETURN:
576:                        sb.append("dreturn");
577:                        ret = true;
578:                        break;
579:                    case JvmOpCodes.ARETURN:
580:                        sb.append("areturn");
581:                        ret = true;
582:                        break;
583:                    case JvmOpCodes.RETURN:
584:                        sb.append("return");
585:                        ret = true;
586:                        break;
587:                    }
588:                }
589:
590:                return ret;
591:
592:            }
593:
594:            public boolean isInstructionIF(int pos) {
595:
596:                if (!isThisInstrStart(pos)) {
597:                    return false;
598:                }
599:                switch (getMethod().getCode()[pos]) {
600:
601:                case JvmOpCodes.IF_ACMPEQ:
602:                    return true;
603:                case JvmOpCodes.IF_ACMPNE:
604:                    return true;
605:                case JvmOpCodes.IF_ICMPEQ:
606:                    return true;
607:                case JvmOpCodes.IF_ICMPGE:
608:                    return true;
609:                case JvmOpCodes.IF_ICMPGT:
610:                    return true;
611:                case JvmOpCodes.IF_ICMPLE:
612:                    return true;
613:                case JvmOpCodes.IF_ICMPLT:
614:                    return true;
615:                case JvmOpCodes.IF_ICMPNE:
616:                    return true;
617:
618:                case JvmOpCodes.IFEQ:
619:                    return true;
620:                case JvmOpCodes.IFGE:
621:                    return true;
622:                case JvmOpCodes.IFGT:
623:                    return true;
624:                case JvmOpCodes.IFLE:
625:                    return true;
626:                case JvmOpCodes.IFNE:
627:                    return true;
628:                case JvmOpCodes.IFLT:
629:                    return true;
630:                case JvmOpCodes.IFNULL:
631:                    return true;
632:                case JvmOpCodes.IFNONNULL:
633:                    return true;
634:                default:
635:                    return false;
636:
637:                }
638:
639:            }
640:
641:            public boolean isInstStore0(int pos) {
642:                throw new UnsupportedOperationException();
643:            }
644:
645:            public boolean isNextInstAStore(int pos) {
646:                throw new UnsupportedOperationException();
647:            }
648:
649:            public boolean isNextInstructionLoad(int nextInstruction) {
650:                throw new UnsupportedOperationException();
651:            }
652:
653:            public boolean isNextInstructionPrimitiveStoreInst(int pos,
654:                    StringBuffer index) {
655:                throw new UnsupportedOperationException();
656:            }
657:
658:            public boolean isNextInstructionStore(int nextInstruction) {
659:                throw new UnsupportedOperationException();
660:            }
661:
662:            public boolean isPrevInstALOADInst(int pos, StringBuffer s) {
663:                throw new UnsupportedOperationException();
664:            }
665:
666:            public boolean isPrevInstIloadInst(int s, StringBuffer sb2) {
667:                throw new UnsupportedOperationException();
668:            }
669:
670:            public boolean isPrevInstPrimitiveLoad(int pos, StringBuffer sb) {
671:                throw new UnsupportedOperationException();
672:            }
673:
674:            public boolean isPrevInstructionAload(int pos, StringBuffer sb) {
675:                throw new UnsupportedOperationException();
676:            }
677:
678:            public boolean isPrevInstructionAload(int pos) {
679:                throw new UnsupportedOperationException();
680:            }
681:
682:            public boolean isPrevInstructionAload(int pos, byte[] code,
683:                    StringBuffer sb) {
684:                throw new UnsupportedOperationException();
685:            }
686:
687:            public boolean isStoreInst(int index) {
688:                throw new UnsupportedOperationException();
689:            }
690:
691:            public boolean isStoreInst(int index, StringBuffer varindex,
692:                    StringBuffer t) {
693:                throw new UnsupportedOperationException();
694:            }
695:
696:            public boolean isThisDUPSTOREAtEndOFTernaryIF(int pos,
697:                    java.lang.String type) {
698:                return false;
699:            }
700:
701:            public boolean isThisIfALoopCondition(IFBlock IF) {
702:                boolean b = true;
703:                int ifend = IF.getIfCloseLineNumber();
704:                int ifs = IF.getIfStart();
705:                boolean b1 = isThisLoopEndAlso(ifend, ifs);
706:                if (!b1) {
707:                    return false;
708:                }
709:                if (b1) {
710:                    byte[] info = getMethod().getCode();
711:                    int jump = getJumpAddress(ifend);
712:                    if (jump >= ifs) {
713:                        return false;
714:                    }
715:                    for (int s = jump; s < ifs; s++) {
716:                        // int inst=info[s];
717:                        boolean b2 = isInstructionIF(s);
718:                        if (b2 && isThisInstrStart(s)) {
719:                            b = false;
720:                            return b;
721:                        }
722:                    }
723:
724:                }
725:
726:                return b;
727:            }
728:
729:            public boolean isThisInstASTOREInst(int pos, StringBuffer sb) {
730:                throw new UnsupportedOperationException();
731:            }
732:
733:            public boolean isThisInstructionIStoreInst(int s, StringBuffer sb) {
734:                throw new UnsupportedOperationException();
735:            }
736:
737:            public boolean isThisLoopEndAlso(int i, int ifstart) {
738:                List loops = getMethod().getBehaviourLoops();
739:                for (int s = 0; s < loops.size(); s++) {
740:                    Loop l = (Loop) loops.get(s);
741:                    int lend = (l).getEndIndex();
742:                    if (lend == i && ifstart > l.getStartIndex()) {
743:                        return true;
744:                    }
745:                }
746:                return false;
747:            }
748:
749:            public boolean isThisLoopStart(IFBlock IF) {
750:                boolean ok = false;
751:                ok = isThisIfALoopCondition(IF);
752:                return ok;
753:            }
754:
755:            public boolean isThisTryStart(int i) {
756:                throw new UnsupportedOperationException();
757:            }
758:
759:            public boolean lastIFinShortCutChain(IFBlock ifst, int i) {
760:                return getMethod().getShortCutAnalyser().isLastIfInChain(i);
761:            }
762:
763:            public boolean isNextInstructionReturn(int pos) {
764:                boolean flag = false;
765:                if (!isThisInstrStart(pos)) {
766:                    return flag;
767:                }
768:
769:                switch (getMethod().getCode()[pos]) {
770:                case JvmOpCodes.RETURN:
771:                    return true;
772:                default:
773:                    return false;
774:
775:                }
776:            }
777:
778:            public boolean isThisInstructionIStoreInst(byte[] code, int s,
779:                    StringBuffer sb) {
780:                throw new UnsupportedOperationException();
781:            }
782:
783:            public boolean isNextInstructionIf(int nextInstruction) {
784:                boolean flag = false;
785:
786:                switch (nextInstruction) {
787:                case JvmOpCodes.IF_ACMPEQ:
788:                    flag = true;
789:                    break;
790:                case JvmOpCodes.IF_ACMPNE:
791:                    flag = true;
792:                    break;
793:                case JvmOpCodes.IF_ICMPEQ:
794:                    flag = true;
795:                    break;
796:                case JvmOpCodes.IF_ICMPGE:
797:                    flag = true;
798:                    break;
799:                case JvmOpCodes.IF_ICMPGT:
800:                    flag = true;
801:                    break;
802:                case JvmOpCodes.IF_ICMPLE:
803:                    flag = true;
804:                    break;
805:                case JvmOpCodes.IF_ICMPLT:
806:                    flag = true;
807:                    break;
808:                case JvmOpCodes.IF_ICMPNE:
809:                    flag = true;
810:                    break;
811:                case JvmOpCodes.IFEQ:
812:                    flag = true;
813:                    break;
814:                case JvmOpCodes.IFGE:
815:                    flag = true;
816:                    break;
817:                case JvmOpCodes.IFGT:
818:                    flag = true;
819:                    break;
820:                case JvmOpCodes.IFLE:
821:                    flag = true;
822:                    break;
823:                case JvmOpCodes.IFLT:
824:                    flag = true;
825:                    break;
826:                case JvmOpCodes.IFNE:
827:                    flag = true;
828:                    break;
829:                case JvmOpCodes.IFNONNULL:
830:                    flag = true;
831:                    break;
832:                case JvmOpCodes.IFNULL:
833:                    flag = true;
834:                    break;
835:                default:
836:                    flag = false;
837:                }
838:                return flag;
839:            }
840:
841:            public boolean isStoreInst(int index, byte[] info) {
842:                throw new UnsupportedOperationException();
843:            }
844:
845:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.