Source Code Cross Referenced for DepthFirstAdapter.java in  » Code-Analyzer » soot » soot » dava » toolkits » base » AST » analysis » 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 » Code Analyzer » soot » soot.dava.toolkits.base.AST.analysis 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /* Soot - a J*va Optimization Framework
0002:         * Copyright (C) 2005 Nomair A. Naeem
0003:         *
0004:         * This library is free software; you can redistribute it and/or
0005:         * modify it under the terms of the GNU Lesser General Public
0006:         * License as published by the Free Software Foundation; either
0007:         * version 2.1 of the License, or (at your option) any later version.
0008:         *
0009:         * This library is distributed in the hope that it will be useful,
0010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012:         * Lesser General Public License for more details.
0013:         *
0014:         * You should have received a copy of the GNU Lesser General Public
0015:         * License along with this library; if not, write to the
0016:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0017:         * Boston, MA 02111-1307, USA.
0018:         */
0019:
0020:        /*
0021:         * Maintained by Nomair A. Naeem
0022:         */
0023:
0024:        /*
0025:         * CHANGE LOG:   23rd November, 2005: Added explicit check for DVariableDeclarationStmt in checking stmts
0026:         *                       This is essential because to get complete code coverage the traversal routine needs
0027:         *                       to go into the DVariableDeclarationStmt and invoke applies on the defs or local
0028:         *                       being declared in there. 
0029:         */
0030:        package soot.dava.toolkits.base.AST.analysis;
0031:
0032:        import soot.*;
0033:        import soot.jimple.*;
0034:        import soot.dava.internal.AST.*;
0035:        import soot.dava.internal.asg.*;
0036:        import java.util.*;
0037:        import soot.dava.internal.javaRep.*;
0038:
0039:        /*
0040:         * CHANGE LOG: 18th MArch 2006: Need a reference to the ValueBox holding a BinOp for SimplifyExpressions
0041:         *              Need to create a level of indirection i.e. instead of retrieving Values e.g. from stmts retrieve the valueBox
0042:         *              and then apply on the value inside the valuebox
0043:         */
0044:        public class DepthFirstAdapter extends AnalysisAdapter {
0045:
0046:            public boolean DEBUG = false;
0047:
0048:            boolean verbose = false;
0049:
0050:            public DepthFirstAdapter() {
0051:            }
0052:
0053:            public DepthFirstAdapter(boolean verbose) {
0054:                this .verbose = verbose;
0055:            }
0056:
0057:            public void inASTMethodNode(ASTMethodNode node) {
0058:                if (verbose)
0059:                    System.out.println("inASTMethodNode");
0060:            }
0061:
0062:            public void outASTMethodNode(ASTMethodNode node) {
0063:                if (verbose)
0064:                    System.out.println("outASTMethodNode");
0065:            }
0066:
0067:            public void caseASTMethodNode(ASTMethodNode node) {
0068:                inASTMethodNode(node);
0069:                normalRetrieving(node);
0070:                outASTMethodNode(node);
0071:            }
0072:
0073:            public void inASTSynchronizedBlockNode(ASTSynchronizedBlockNode node) {
0074:                if (verbose)
0075:                    System.out.println("inASTSynchronizedBlockNode");
0076:            }
0077:
0078:            public void outASTSynchronizedBlockNode(
0079:                    ASTSynchronizedBlockNode node) {
0080:                if (verbose)
0081:                    System.out.println("outASTSynchronizedBlockNode");
0082:            }
0083:
0084:            public void caseASTSynchronizedBlockNode(
0085:                    ASTSynchronizedBlockNode node) {
0086:                inASTSynchronizedBlockNode(node);
0087:
0088:                /*
0089:                 apply on the local on which synchronization is done
0090:                 MArch 18th, 2006: since getLocal returns a local always dont need a valuebox for this
0091:                 */
0092:                Value local = node.getLocal();
0093:
0094:                decideCaseExprOrRef(local);
0095:
0096:                /*
0097:                 apply on the body of the synch block
0098:                 */
0099:                normalRetrieving(node);
0100:
0101:                outASTSynchronizedBlockNode(node);
0102:            }
0103:
0104:            public void inASTLabeledBlockNode(ASTLabeledBlockNode node) {
0105:                if (verbose)
0106:                    System.out.println("inASTLabeledBlockNode");
0107:            }
0108:
0109:            public void outASTLabeledBlockNode(ASTLabeledBlockNode node) {
0110:                if (verbose)
0111:                    System.out.println("outASTLabeledBlockNode");
0112:            }
0113:
0114:            public void caseASTLabeledBlockNode(ASTLabeledBlockNode node) {
0115:                inASTLabeledBlockNode(node);
0116:                normalRetrieving(node);
0117:                outASTLabeledBlockNode(node);
0118:            }
0119:
0120:            public void inASTUnconditionalLoopNode(ASTUnconditionalLoopNode node) {
0121:                if (verbose)
0122:                    System.out.println("inASTUnconditionalWhileNode");
0123:            }
0124:
0125:            public void outASTUnconditionalLoopNode(
0126:                    ASTUnconditionalLoopNode node) {
0127:                if (verbose)
0128:                    System.out.println("outASTUnconditionalWhileNode");
0129:            }
0130:
0131:            public void caseASTUnconditionalLoopNode(
0132:                    ASTUnconditionalLoopNode node) {
0133:                inASTUnconditionalLoopNode(node);
0134:                normalRetrieving(node);
0135:                outASTUnconditionalLoopNode(node);
0136:            }
0137:
0138:            public void inASTSwitchNode(ASTSwitchNode node) {
0139:                if (verbose)
0140:                    System.out.println("inASTSwitchNode");
0141:            }
0142:
0143:            public void outASTSwitchNode(ASTSwitchNode node) {
0144:                if (verbose)
0145:                    System.out.println("outASTSwitchNode");
0146:            }
0147:
0148:            public void caseASTSwitchNode(ASTSwitchNode node) {
0149:                inASTSwitchNode(node);
0150:
0151:                /*
0152:                 apply on key of switchStatement
0153:                 */
0154:                /*
0155:                 * March 18th 2006, added level of indirection to have access to value box
0156:                 * Value key = node.get_Key();
0157:                 * decideCaseExprOrRef(key);
0158:                 */
0159:                caseExprOrRefValueBox(node.getKeyBox());
0160:
0161:                /*
0162:                 Apply on bodies of switch cases
0163:                 */
0164:                normalRetrieving(node);
0165:                outASTSwitchNode(node);
0166:            }
0167:
0168:            public void inASTIfNode(ASTIfNode node) {
0169:                if (verbose)
0170:                    System.out.println("inASTIfNode");
0171:            }
0172:
0173:            public void outASTIfNode(ASTIfNode node) {
0174:                if (verbose)
0175:                    System.out.println("outASTIfNode");
0176:            }
0177:
0178:            public void caseASTIfNode(ASTIfNode node) {
0179:                inASTIfNode(node);
0180:
0181:                /*
0182:                 apply on the ASTCondition
0183:                 */
0184:                ASTCondition condition = node.get_Condition();
0185:                condition.apply(this );
0186:
0187:                /*
0188:                 Apply on the if body
0189:                 */
0190:                normalRetrieving(node);
0191:                outASTIfNode(node);
0192:            }
0193:
0194:            public void inASTIfElseNode(ASTIfElseNode node) {
0195:                if (verbose)
0196:                    System.out.println("inASTIfElseNode");
0197:            }
0198:
0199:            public void outASTIfElseNode(ASTIfElseNode node) {
0200:                if (verbose)
0201:                    System.out.println("outASTIfElseNode");
0202:            }
0203:
0204:            public void caseASTIfElseNode(ASTIfElseNode node) {
0205:                inASTIfElseNode(node);
0206:
0207:                /*
0208:                 apply on the ASTCondition
0209:                 */
0210:                ASTCondition condition = node.get_Condition();
0211:                condition.apply(this );
0212:
0213:                /*
0214:                 Apply on the if body followed by the else body
0215:                 */
0216:                normalRetrieving(node);
0217:
0218:                outASTIfElseNode(node);
0219:            }
0220:
0221:            public void inASTWhileNode(ASTWhileNode node) {
0222:                if (verbose)
0223:                    System.out.println("inASTWhileNode");
0224:            }
0225:
0226:            public void outASTWhileNode(ASTWhileNode node) {
0227:                if (verbose)
0228:                    System.out.println("outASTWhileNode");
0229:            }
0230:
0231:            public void caseASTWhileNode(ASTWhileNode node) {
0232:                inASTWhileNode(node);
0233:
0234:                /*
0235:                 apply on the ASTCondition
0236:                 */
0237:                ASTCondition condition = node.get_Condition();
0238:                condition.apply(this );
0239:
0240:                /*
0241:                 Apply on the while body
0242:                 */
0243:                normalRetrieving(node);
0244:                outASTWhileNode(node);
0245:            }
0246:
0247:            public void inASTForLoopNode(ASTForLoopNode node) {
0248:                if (verbose)
0249:                    System.out.println("inASTForLoopNode");
0250:            }
0251:
0252:            public void outASTForLoopNode(ASTForLoopNode node) {
0253:                if (verbose)
0254:                    System.out.println("outASTForLoopNode");
0255:            }
0256:
0257:            public void caseASTForLoopNode(ASTForLoopNode node) {
0258:                inASTForLoopNode(node);
0259:
0260:                /*
0261:                 Apply on init
0262:                 */
0263:                List<Object> init = node.getInit();
0264:                Iterator<Object> it = init.iterator();
0265:                while (it.hasNext()) {
0266:                    AugmentedStmt as = (AugmentedStmt) it.next();
0267:                    Stmt s = as.get_Stmt();
0268:                    if (s instanceof  DefinitionStmt)
0269:                        caseDefinitionStmt((DefinitionStmt) s);
0270:                    else if (s instanceof  ReturnStmt)
0271:                        caseReturnStmt((ReturnStmt) s);
0272:                    else if (s instanceof  InvokeStmt)
0273:                        caseInvokeStmt((InvokeStmt) s);
0274:                    else if (s instanceof  ThrowStmt)
0275:                        caseThrowStmt((ThrowStmt) s);
0276:                    else
0277:                        caseStmt(s);
0278:                }
0279:
0280:                /*
0281:                 apply on the ASTCondition
0282:                 */
0283:                ASTCondition condition = node.get_Condition();
0284:                condition.apply(this );
0285:
0286:                /*
0287:                 Apply on update
0288:                 */
0289:                List<Object> update = node.getUpdate();
0290:                it = update.iterator();
0291:                while (it.hasNext()) {
0292:                    AugmentedStmt as = (AugmentedStmt) it.next();
0293:                    Stmt s = as.get_Stmt();
0294:
0295:                    if (s instanceof  DefinitionStmt)
0296:                        caseDefinitionStmt((DefinitionStmt) s);
0297:                    else if (s instanceof  ReturnStmt)
0298:                        caseReturnStmt((ReturnStmt) s);
0299:                    else if (s instanceof  InvokeStmt)
0300:                        caseInvokeStmt((InvokeStmt) s);
0301:                    else if (s instanceof  ThrowStmt)
0302:                        caseThrowStmt((ThrowStmt) s);
0303:                    else
0304:                        caseStmt(s);
0305:                }
0306:
0307:                /*
0308:                 Apply on the for body
0309:                 */
0310:                normalRetrieving(node);
0311:                outASTForLoopNode(node);
0312:            }
0313:
0314:            public void inASTDoWhileNode(ASTDoWhileNode node) {
0315:                if (verbose)
0316:                    System.out.println("inASTDoWhileNode");
0317:            }
0318:
0319:            public void outASTDoWhileNode(ASTDoWhileNode node) {
0320:                if (verbose)
0321:                    System.out.println("outASTDoWhileNode");
0322:            }
0323:
0324:            public void caseASTDoWhileNode(ASTDoWhileNode node) {
0325:                inASTDoWhileNode(node);
0326:
0327:                /*
0328:                 apply on the ASTCondition
0329:                 */
0330:                ASTCondition condition = node.get_Condition();
0331:                condition.apply(this );
0332:
0333:                /*
0334:                 Apply on the while body
0335:                 */
0336:                normalRetrieving(node);
0337:                outASTDoWhileNode(node);
0338:            }
0339:
0340:            public void inASTTryNode(ASTTryNode node) {
0341:                if (verbose)
0342:                    System.out.println("inASTTryNode");
0343:            }
0344:
0345:            public void outASTTryNode(ASTTryNode node) {
0346:                if (verbose)
0347:                    System.out.println("outASTTryNode");
0348:            }
0349:
0350:            public void caseASTTryNode(ASTTryNode node) {
0351:                inASTTryNode(node);
0352:
0353:                //get try body 
0354:                List<Object> tryBody = node.get_TryBody();
0355:                Iterator<Object> it = tryBody.iterator();
0356:
0357:                //go over the ASTNodes in this tryBody and apply
0358:                while (it.hasNext())
0359:                    ((ASTNode) it.next()).apply(this );
0360:
0361:                Map<Object, Object> exceptionMap = node.get_ExceptionMap();
0362:                Map<Object, Object> paramMap = node.get_ParamMap();
0363:                //get catch list and apply on the following
0364:                // a, type of exception caught
0365:                // b, local of exception
0366:                // c, catchBody
0367:                List<Object> catchList = node.get_CatchList();
0368:                Iterator itBody = null;
0369:                it = catchList.iterator();
0370:                while (it.hasNext()) {
0371:                    ASTTryNode.container catchBody = (ASTTryNode.container) it
0372:                            .next();
0373:
0374:                    SootClass sootClass = ((SootClass) exceptionMap
0375:                            .get(catchBody));
0376:                    Type type = sootClass.getType();
0377:
0378:                    //apply on type of exception
0379:                    caseType(type);
0380:
0381:                    //apply on local of exception
0382:                    Local local = (Local) paramMap.get(catchBody);
0383:                    /*
0384:                     * March 18th, 2006, Since these are always locals we dont have access to ValueBox
0385:                     */
0386:                    decideCaseExprOrRef(local);
0387:
0388:                    //apply on catchBody
0389:                    List body = (List) catchBody.o;
0390:                    itBody = body.iterator();
0391:                    while (itBody.hasNext()) {
0392:                        ((ASTNode) itBody.next()).apply(this );
0393:                    }
0394:                }
0395:                outASTTryNode(node);
0396:            }
0397:
0398:            public void inASTUnaryCondition(ASTUnaryCondition uc) {
0399:                if (verbose)
0400:                    System.out.println("inASTUnaryCondition");
0401:            }
0402:
0403:            public void outASTUnaryCondition(ASTUnaryCondition uc) {
0404:                if (verbose)
0405:                    System.out.println("outASTUnaryCondition");
0406:            }
0407:
0408:            public void caseASTUnaryCondition(ASTUnaryCondition uc) {
0409:                inASTUnaryCondition(uc);
0410:                //apply on the value
0411:                decideCaseExprOrRef(uc.getValue());
0412:                outASTUnaryCondition(uc);
0413:            }
0414:
0415:            public void inASTBinaryCondition(ASTBinaryCondition bc) {
0416:                if (verbose)
0417:                    System.out.println("inASTBinaryCondition");
0418:            }
0419:
0420:            public void outASTBinaryCondition(ASTBinaryCondition bc) {
0421:                if (verbose)
0422:                    System.out.println("outASTBinaryCondition");
0423:            }
0424:
0425:            public void caseASTBinaryCondition(ASTBinaryCondition bc) {
0426:                inASTBinaryCondition(bc);
0427:
0428:                ConditionExpr condition = bc.getConditionExpr();
0429:                //calling decideCaseExprOrRef although we know for sure this is an Expr but doesnt matter
0430:
0431:                decideCaseExprOrRef(condition);
0432:
0433:                outASTBinaryCondition(bc);
0434:            }
0435:
0436:            public void inASTAndCondition(ASTAndCondition ac) {
0437:                if (verbose)
0438:                    System.out.println("inASTAndCondition");
0439:            }
0440:
0441:            public void outASTAndCondition(ASTAndCondition ac) {
0442:                if (verbose)
0443:                    System.out.println("outASTAndCondition");
0444:            }
0445:
0446:            public void caseASTAndCondition(ASTAndCondition ac) {
0447:                inASTAndCondition(ac);
0448:
0449:                ((ac.getLeftOp())).apply(this );
0450:                ((ac.getRightOp())).apply(this );
0451:
0452:                outASTAndCondition(ac);
0453:            }
0454:
0455:            public void inASTOrCondition(ASTOrCondition oc) {
0456:                if (verbose)
0457:                    System.out.println("inASTOrCondition");
0458:            }
0459:
0460:            public void outASTOrCondition(ASTOrCondition oc) {
0461:                if (verbose)
0462:                    System.out.println("outASTOrCondition");
0463:            }
0464:
0465:            public void caseASTOrCondition(ASTOrCondition oc) {
0466:                inASTOrCondition(oc);
0467:
0468:                ((oc.getLeftOp())).apply(this );
0469:                ((oc.getRightOp())).apply(this );
0470:
0471:                outASTOrCondition(oc);
0472:            }
0473:
0474:            public void inType(Type t) {
0475:                if (verbose)
0476:                    System.out.println("inType");
0477:            }
0478:
0479:            public void outType(Type t) {
0480:                if (verbose)
0481:                    System.out.println("outType");
0482:            }
0483:
0484:            public void caseType(Type t) {
0485:                inType(t);
0486:                outType(t);
0487:            }
0488:
0489:            public void normalRetrieving(ASTNode node) {
0490:                //from the Node get the subBodes
0491:                Iterator<Object> sbit = node.get_SubBodies().iterator();
0492:                while (sbit.hasNext()) {
0493:                    Object subBody = sbit.next();
0494:                    Iterator it = ((List) subBody).iterator();
0495:
0496:                    //go over the ASTNodes in this subBody and apply
0497:                    while (it.hasNext()) {
0498:                        ASTNode temp = (ASTNode) it.next();
0499:
0500:                        temp.apply(this );
0501:                    }
0502:                }//end of going over subBodies
0503:            }
0504:
0505:            public void inASTStatementSequenceNode(ASTStatementSequenceNode node) {
0506:                if (verbose)
0507:                    System.out.println("inASTStatementSequenceNode");
0508:            }
0509:
0510:            public void outASTStatementSequenceNode(
0511:                    ASTStatementSequenceNode node) {
0512:                if (verbose)
0513:                    System.out.println("outASTStatementSequenceNode");
0514:            }
0515:
0516:            public void caseASTStatementSequenceNode(
0517:                    ASTStatementSequenceNode node) {
0518:                inASTStatementSequenceNode(node);
0519:                Iterator<Object> it = node.getStatements().iterator();
0520:                while (it.hasNext()) {
0521:                    AugmentedStmt as = (AugmentedStmt) it.next();
0522:                    Stmt s = as.get_Stmt();
0523:                    /*
0524:                     Do a case by case check of possible statements and invoke
0525:                     the case methods from within this method.
0526:                     
0527:                     cant use apply since the Statements are defined in some other
0528:                     package and dont want to change code all over the place
0529:                     */
0530:
0531:                    if (s instanceof  DefinitionStmt)
0532:                        caseDefinitionStmt((DefinitionStmt) s);
0533:                    else if (s instanceof  ReturnStmt)
0534:                        caseReturnStmt((ReturnStmt) s);
0535:                    else if (s instanceof  InvokeStmt)
0536:                        caseInvokeStmt((InvokeStmt) s);
0537:                    else if (s instanceof  ThrowStmt)
0538:                        caseThrowStmt((ThrowStmt) s);
0539:                    else if (s instanceof  DVariableDeclarationStmt)
0540:                        caseDVariableDeclarationStmt((DVariableDeclarationStmt) s);
0541:                    else
0542:                        caseStmt(s);
0543:
0544:                }//end of while going through the statement sequence
0545:                outASTStatementSequenceNode(node);
0546:            }
0547:
0548:            public void inDefinitionStmt(DefinitionStmt s) {
0549:                if (verbose)
0550:                    System.out.println("inDefinitionStmt" + s);
0551:            }
0552:
0553:            public void outDefinitionStmt(DefinitionStmt s) {
0554:                if (verbose)
0555:                    System.out.println("outDefinitionStmt");
0556:            }
0557:
0558:            public void caseDefinitionStmt(DefinitionStmt s) {
0559:                inDefinitionStmt(s);
0560:
0561:                /*
0562:                 * March 18th, 2006 introducing level of indirection
0563:                 * decideCaseExprOrRef(s.getRightOp());
0564:                 * decideCaseExprOrRef(s.getLeftOp());
0565:                 */
0566:                caseExprOrRefValueBox(s.getRightOpBox());
0567:                caseExprOrRefValueBox(s.getLeftOpBox());
0568:
0569:                outDefinitionStmt(s);
0570:            }
0571:
0572:            public void inReturnStmt(ReturnStmt s) {
0573:                if (verbose)
0574:                    System.out.println("inReturnStmt");
0575:                //	System.out.println("Return Stmt:"+s);
0576:            }
0577:
0578:            public void outReturnStmt(ReturnStmt s) {
0579:                if (verbose)
0580:                    System.out.println("outReturnStmt");
0581:            }
0582:
0583:            public void caseReturnStmt(ReturnStmt s) {
0584:                inReturnStmt(s);
0585:
0586:                /*
0587:                 * MArch 18th 2006
0588:                 * decideCaseExprOrRef(s.getOp());
0589:                 */
0590:                caseExprOrRefValueBox(s.getOpBox());
0591:
0592:                outReturnStmt(s);
0593:            }
0594:
0595:            public void inInvokeStmt(InvokeStmt s) {
0596:                if (verbose)
0597:                    System.out.println("inInvokeStmt");
0598:            }
0599:
0600:            public void outInvokeStmt(InvokeStmt s) {
0601:                if (verbose)
0602:                    System.out.println("outInvokeStmt");
0603:            }
0604:
0605:            public void caseInvokeStmt(InvokeStmt s) {
0606:                inInvokeStmt(s);
0607:
0608:                caseExprOrRefValueBox(s.getInvokeExprBox());
0609:                //decideCaseExprOrRef(s.getInvokeExpr());
0610:
0611:                outInvokeStmt(s);
0612:            }
0613:
0614:            public void inThrowStmt(ThrowStmt s) {
0615:                if (verbose)
0616:                    System.out.println("\n\ninThrowStmt\n\n");
0617:            }
0618:
0619:            public void outThrowStmt(ThrowStmt s) {
0620:                if (verbose)
0621:                    System.out.println("outThrowStmt");
0622:            }
0623:
0624:            public void caseThrowStmt(ThrowStmt s) {
0625:                inThrowStmt(s);
0626:                caseExprOrRefValueBox(s.getOpBox());
0627:                //decideCaseExprOrRef(s.getOp());
0628:
0629:                outThrowStmt(s);
0630:            }
0631:
0632:            public void inDVariableDeclarationStmt(DVariableDeclarationStmt s) {
0633:                if (verbose)
0634:                    System.out
0635:                            .println("\n\ninDVariableDeclarationStmt\n\n" + s);
0636:            }
0637:
0638:            public void outDVariableDeclarationStmt(DVariableDeclarationStmt s) {
0639:                if (verbose)
0640:                    System.out.println("outDVariableDeclarationStmt");
0641:            }
0642:
0643:            public void caseDVariableDeclarationStmt(DVariableDeclarationStmt s) {
0644:                inDVariableDeclarationStmt(s);
0645:
0646:                //a variableDeclarationStmt has a type followed by a list of locals
0647:                Type type = s.getType();
0648:                caseType(type);
0649:
0650:                List listDeclared = s.getDeclarations();
0651:                Iterator it = listDeclared.iterator();
0652:                while (it.hasNext()) {
0653:                    Local declared = (Local) it.next();
0654:                    decideCaseExprOrRef(declared);
0655:                }
0656:
0657:                outDVariableDeclarationStmt(s);
0658:            }
0659:
0660:            public void inStmt(Stmt s) {
0661:                if (verbose)
0662:                    System.out.println("inStmt: " + s);
0663:
0664:                /*
0665:                 if(s instanceof DAbruptStmt)
0666:                 System.out.println("DAbruptStmt: "+s);
0667:                 if(s instanceof ReturnVoidStmt)
0668:                 System.out.println("ReturnVoidStmt: "+s);
0669:                 */
0670:            }
0671:
0672:            public void outStmt(Stmt s) {
0673:                if (verbose)
0674:                    System.out.println("outStmt");
0675:            }
0676:
0677:            public void caseStmt(Stmt s) {
0678:                inStmt(s);
0679:                outStmt(s);
0680:            }
0681:
0682:            /*
0683:             * March 18th 2006, Adding new indirection
0684:             */
0685:            public void caseExprOrRefValueBox(ValueBox vb) {
0686:                inExprOrRefValueBox(vb);
0687:                decideCaseExprOrRef(vb.getValue());
0688:                outExprOrRefValueBox(vb);
0689:            }
0690:
0691:            public void inExprOrRefValueBox(ValueBox vb) {
0692:                if (verbose)
0693:                    System.out.println("inExprOrRefValueBox" + vb);
0694:
0695:            }
0696:
0697:            public void outExprOrRefValueBox(ValueBox vb) {
0698:                if (verbose)
0699:                    System.out.println("outExprOrRefValueBox" + vb);
0700:
0701:            }
0702:
0703:            public void decideCaseExprOrRef(Value v) {
0704:                if (v instanceof  Expr)
0705:                    caseExpr((Expr) v);
0706:                else if (v instanceof  Ref)
0707:                    caseRef((Ref) v);
0708:                else
0709:                    caseValue(v);
0710:            }
0711:
0712:            public void inValue(Value v) {
0713:                if (verbose) {
0714:                    System.out.println("inValue" + v);
0715:
0716:                    if (v instanceof  DThisRef)
0717:                        System.out.println("DTHISREF.................");
0718:                    else if (v instanceof  Immediate) {
0719:                        System.out.println("\tIMMEDIATE");
0720:                        if (v instanceof  soot.jimple.internal.JimpleLocal) {
0721:                            System.out
0722:                                    .println("\t\tJimpleLocal...................."
0723:                                            + v);
0724:
0725:                        } else if (v instanceof  Constant) {
0726:                            System.out
0727:                                    .println("\t\tconstant....................");
0728:                            if (v instanceof  IntConstant)
0729:                                System.out
0730:                                        .println("\t\t INTconstant....................");
0731:                        } else if (v instanceof  soot.baf.internal.BafLocal) {
0732:                            System.out
0733:                                    .println("\t\tBafLocal....................");
0734:                        } else
0735:                            System.out.println("\t\telse!!!!!!!!!!!!");
0736:                    } else {
0737:                        System.out.println("NEITHER................");
0738:                    }
0739:                }
0740:            }
0741:
0742:            public void outValue(Value v) {
0743:                if (verbose)
0744:                    System.out.println("outValue");
0745:            }
0746:
0747:            public void caseValue(Value v) {
0748:                inValue(v);
0749:                outValue(v);
0750:            }
0751:
0752:            public void inExpr(Expr e) {
0753:                if (verbose)
0754:                    System.out.println("inExpr");
0755:            }
0756:
0757:            public void outExpr(Expr e) {
0758:                if (verbose)
0759:                    System.out.println("outExpr");
0760:            }
0761:
0762:            public void caseExpr(Expr e) {
0763:                inExpr(e);
0764:                decideCaseExpr(e);
0765:                outExpr(e);
0766:            }
0767:
0768:            public void inRef(Ref r) {
0769:                if (verbose)
0770:                    System.out.println("inRef");
0771:            }
0772:
0773:            public void outRef(Ref r) {
0774:                if (verbose)
0775:                    System.out.println("outRef");
0776:            }
0777:
0778:            public void caseRef(Ref r) {
0779:                inRef(r);
0780:                decideCaseRef(r);
0781:                outRef(r);
0782:            }
0783:
0784:            public void decideCaseExpr(Expr e) {
0785:                if (e instanceof  BinopExpr)
0786:                    caseBinopExpr((BinopExpr) e);
0787:                else if (e instanceof  UnopExpr)
0788:                    caseUnopExpr((UnopExpr) e);
0789:                else if (e instanceof  NewArrayExpr)
0790:                    caseNewArrayExpr((NewArrayExpr) e);
0791:                else if (e instanceof  NewMultiArrayExpr)
0792:                    caseNewMultiArrayExpr((NewMultiArrayExpr) e);
0793:                else if (e instanceof  InstanceOfExpr)
0794:                    caseInstanceOfExpr((InstanceOfExpr) e);
0795:                else if (e instanceof  InvokeExpr)
0796:                    caseInvokeExpr((InvokeExpr) e);
0797:                else if (e instanceof  CastExpr)
0798:                    caseCastExpr((CastExpr) e);
0799:            }
0800:
0801:            public void inBinopExpr(BinopExpr be) {
0802:                if (verbose)
0803:                    System.out.println("inBinopExpr");
0804:            }
0805:
0806:            public void outBinopExpr(BinopExpr be) {
0807:                if (verbose)
0808:                    System.out.println("outBinopExpr");
0809:            }
0810:
0811:            public void caseBinopExpr(BinopExpr be) {
0812:                inBinopExpr(be);
0813:
0814:                caseExprOrRefValueBox(be.getOp1Box());
0815:                caseExprOrRefValueBox(be.getOp2Box());
0816:                //decideCaseExprOrRef(be.getOp1());
0817:                //decideCaseExprOrRef(be.getOp2());
0818:
0819:                outBinopExpr(be);
0820:            }
0821:
0822:            public void inUnopExpr(UnopExpr ue) {
0823:                if (verbose)
0824:                    System.out.println("inUnopExpr");
0825:            }
0826:
0827:            public void outUnopExpr(UnopExpr ue) {
0828:                if (verbose)
0829:                    System.out.println("outUnopExpr");
0830:            }
0831:
0832:            public void caseUnopExpr(UnopExpr ue) {
0833:                inUnopExpr(ue);
0834:
0835:                caseExprOrRefValueBox(ue.getOpBox());
0836:                //decideCaseExprOrRef(ue.getOp());
0837:
0838:                outUnopExpr(ue);
0839:            }
0840:
0841:            public void inNewArrayExpr(NewArrayExpr nae) {
0842:                if (verbose)
0843:                    System.out.println("inNewArrayExpr");
0844:            }
0845:
0846:            public void outNewArrayExpr(NewArrayExpr nae) {
0847:                if (verbose)
0848:                    System.out.println("outNewArrayExpr");
0849:            }
0850:
0851:            public void caseNewArrayExpr(NewArrayExpr nae) {
0852:                inNewArrayExpr(nae);
0853:
0854:                caseExprOrRefValueBox(nae.getSizeBox());
0855:                //decideCaseExprOrRef(nae.getSize());
0856:
0857:                outNewArrayExpr(nae);
0858:            }
0859:
0860:            public void inNewMultiArrayExpr(NewMultiArrayExpr nmae) {
0861:                if (verbose)
0862:                    System.out.println("inNewMultiArrayExpr");
0863:            }
0864:
0865:            public void outNewMultiArrayExpr(NewMultiArrayExpr nmae) {
0866:                if (verbose)
0867:                    System.out.println("outNewMultiArrayExpr");
0868:            }
0869:
0870:            public void caseNewMultiArrayExpr(NewMultiArrayExpr nmae) {
0871:                inNewMultiArrayExpr(nmae);
0872:
0873:                for (int i = 0; i < nmae.getSizeCount(); i++) {
0874:                    caseExprOrRefValueBox(nmae.getSizeBox(i));
0875:                    //decideCaseExprOrRef(nmae.getSize(i));
0876:                }
0877:                outNewMultiArrayExpr(nmae);
0878:            }
0879:
0880:            public void inInstanceOfExpr(InstanceOfExpr ioe) {
0881:                if (verbose)
0882:                    System.out.println("inInstanceOfExpr");
0883:            }
0884:
0885:            public void outInstanceOfExpr(InstanceOfExpr ioe) {
0886:                if (verbose)
0887:                    System.out.println("outInstanceOfExpr");
0888:            }
0889:
0890:            public void caseInstanceOfExpr(InstanceOfExpr ioe) {
0891:                inInstanceOfExpr(ioe);
0892:
0893:                caseExprOrRefValueBox(ioe.getOpBox());
0894:                //decideCaseExprOrRef(ioe.getOp());
0895:
0896:                outInstanceOfExpr(ioe);
0897:            }
0898:
0899:            public void inInvokeExpr(InvokeExpr ie) {
0900:                if (verbose)
0901:                    System.out.println("inInvokeExpr");
0902:            }
0903:
0904:            public void outInvokeExpr(InvokeExpr ie) {
0905:                if (verbose)
0906:                    System.out.println("outInvokeExpr");
0907:            }
0908:
0909:            public void caseInvokeExpr(InvokeExpr ie) {
0910:                inInvokeExpr(ie);
0911:
0912:                for (int i = 0; i < ie.getArgCount(); i++) {
0913:                    caseExprOrRefValueBox(ie.getArgBox(i));
0914:                    //decideCaseExprOrRef(ie.getArg(i));
0915:                }
0916:                if (ie instanceof  InstanceInvokeExpr)
0917:                    caseInstanceInvokeExpr((InstanceInvokeExpr) ie);
0918:
0919:                outInvokeExpr(ie);
0920:            }
0921:
0922:            public void inInstanceInvokeExpr(InstanceInvokeExpr iie) {
0923:                if (verbose)
0924:                    System.out.println("inInstanceInvokeExpr");
0925:            }
0926:
0927:            public void outInstanceInvokeExpr(InstanceInvokeExpr iie) {
0928:                if (verbose)
0929:                    System.out.println("outInstanceInvokeExpr");
0930:            }
0931:
0932:            public void caseInstanceInvokeExpr(InstanceInvokeExpr iie) {
0933:                inInstanceInvokeExpr(iie);
0934:
0935:                caseExprOrRefValueBox(iie.getBaseBox());
0936:                //decideCaseExprOrRef(iie.getBase());
0937:
0938:                outInstanceInvokeExpr(iie);
0939:            }
0940:
0941:            public void inCastExpr(CastExpr ce) {
0942:                if (verbose)
0943:                    System.out.println("inCastExpr");
0944:            }
0945:
0946:            public void outCastExpr(CastExpr ce) {
0947:                if (verbose)
0948:                    System.out.println("outCastExpr");
0949:            }
0950:
0951:            public void caseCastExpr(CastExpr ce) {
0952:                inCastExpr(ce);
0953:                Type type = ce.getCastType();
0954:                caseType(type);
0955:
0956:                caseExprOrRefValueBox(ce.getOpBox());
0957:                //Value op = ce.getOp();
0958:                //decideCaseExprOrRef(op);
0959:
0960:                outCastExpr(ce);
0961:            }
0962:
0963:            public void decideCaseRef(Ref r) {
0964:                if (r instanceof  ArrayRef)
0965:                    caseArrayRef((ArrayRef) r);
0966:                else if (r instanceof  InstanceFieldRef)
0967:                    caseInstanceFieldRef((InstanceFieldRef) r);
0968:                else if (r instanceof  StaticFieldRef)
0969:                    caseStaticFieldRef((StaticFieldRef) r);
0970:            }
0971:
0972:            public void inArrayRef(ArrayRef ar) {
0973:                if (verbose)
0974:                    System.out.println("inArrayRef");
0975:            }
0976:
0977:            public void outArrayRef(ArrayRef ar) {
0978:                if (verbose)
0979:                    System.out.println("outArrayRef");
0980:            }
0981:
0982:            public void caseArrayRef(ArrayRef ar) {
0983:                inArrayRef(ar);
0984:                caseExprOrRefValueBox(ar.getBaseBox());
0985:                caseExprOrRefValueBox(ar.getIndexBox());
0986:                //decideCaseExprOrRef(ar.getBase());
0987:                //decideCaseExprOrRef(ar.getIndex());
0988:                outArrayRef(ar);
0989:            }
0990:
0991:            public void inInstanceFieldRef(InstanceFieldRef ifr) {
0992:                if (verbose) {
0993:                    System.out.println("inInstanceFieldRef");
0994:
0995:                    if (ifr instanceof  DInstanceFieldRef) {
0996:                        System.out.println("...........DINSTANCEFIELDREF");
0997:
0998:                    }
0999:                }
1000:            }
1001:
1002:            public void outInstanceFieldRef(InstanceFieldRef ifr) {
1003:                if (verbose)
1004:                    System.out.println("outInstanceFieldRef");
1005:            }
1006:
1007:            public void caseInstanceFieldRef(InstanceFieldRef ifr) {
1008:                inInstanceFieldRef(ifr);
1009:                caseExprOrRefValueBox(ifr.getBaseBox());
1010:                //decideCaseExprOrRef(ifr.getBase());
1011:                outInstanceFieldRef(ifr);
1012:            }
1013:
1014:            public void inStaticFieldRef(StaticFieldRef sfr) {
1015:                if (verbose)
1016:                    System.out.println("inStaticFieldRef");
1017:            }
1018:
1019:            public void outStaticFieldRef(StaticFieldRef sfr) {
1020:                if (verbose)
1021:                    System.out.println("outStaticFieldRef");
1022:            }
1023:
1024:            public void caseStaticFieldRef(StaticFieldRef sfr) {
1025:                inStaticFieldRef(sfr);
1026:
1027:                outStaticFieldRef(sfr);
1028:            }
1029:
1030:            public void debug(String className, String methodName, String debug) {
1031:                if (DEBUG)
1032:                    System.out.println("Analysis" + className + "..Method:"
1033:                            + methodName + "    DEBUG: " + debug);
1034:            }
1035:
1036:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.