KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > dava > toolkits > base > AST > analysis > DepthFirstAdapter


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2005 Nomair A. Naeem
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 /*
21  * Maintained by Nomair A. Naeem
22  */

23
24 /*
25  * CHANGE LOG: 23rd November, 2005: Added explicit check for DVariableDeclarationStmt in checking stmts
26  * This is essential because to get complete code coverage the traversal routine needs
27  * to go into the DVariableDeclarationStmt and invoke applies on the defs or local
28  * being declared in there.
29  */

30 package soot.dava.toolkits.base.AST.analysis;
31
32 import soot.*;
33 import soot.jimple.*;
34 import soot.dava.internal.AST.*;
35 import soot.dava.internal.asg.*;
36 import java.util.*;
37 import soot.dava.internal.javaRep.*;
38
39 public class DepthFirstAdapter extends AnalysisAdapter{
40
41     public boolean DEBUG = false;
42     
43     boolean verbose=false;
44
45     public DepthFirstAdapter(){
46     }
47     public DepthFirstAdapter(boolean verbose){
48     this.verbose=verbose;
49     }
50
51     public void inASTMethodNode(ASTMethodNode node){
52     if(verbose)
53     System.out.println("inASTMethodNode");
54     }
55
56     public void outASTMethodNode(ASTMethodNode node){
57     if(verbose)
58     System.out.println("outASTMethodNode");
59     }
60
61     public void caseASTMethodNode(ASTMethodNode node){
62     inASTMethodNode(node);
63     normalRetrieving(node);
64     outASTMethodNode(node);
65     }
66
67
68
69
70
71
72     public void inASTSynchronizedBlockNode(ASTSynchronizedBlockNode node){
73     if(verbose)
74     System.out.println("inASTSynchronizedBlockNode");
75     }
76     public void outASTSynchronizedBlockNode(ASTSynchronizedBlockNode node){
77     if(verbose)
78     System.out.println("outASTSynchronizedBlockNode");
79     }
80
81     public void caseASTSynchronizedBlockNode(ASTSynchronizedBlockNode node){
82     inASTSynchronizedBlockNode(node);
83
84
85     /*
86       apply on the local on which synchronization is done
87     */

88     Value local = node.getLocal();
89     decideCaseExprOrRef(local);
90
91     /*
92       apply on the body of the synch block
93     */

94     normalRetrieving(node);
95
96     outASTSynchronizedBlockNode(node);
97     }
98
99
100
101
102     public void inASTLabeledBlockNode (ASTLabeledBlockNode node){
103     if(verbose)
104     System.out.println("inASTLabeledBlockNode");
105     }
106     public void outASTLabeledBlockNode (ASTLabeledBlockNode node){
107     if(verbose)
108     System.out.println("outASTLabeledBlockNode");
109     }
110     public void caseASTLabeledBlockNode (ASTLabeledBlockNode node){
111     inASTLabeledBlockNode(node);
112     normalRetrieving(node);
113     outASTLabeledBlockNode(node);
114     }
115
116
117
118
119
120
121     public void inASTUnconditionalLoopNode (ASTUnconditionalLoopNode node){
122     if(verbose)
123     System.out.println("inASTUnconditionalWhileNode");
124     }
125     public void outASTUnconditionalLoopNode (ASTUnconditionalLoopNode node){
126     if(verbose)
127     System.out.println("outASTUnconditionalWhileNode");
128     }
129     public void caseASTUnconditionalLoopNode (ASTUnconditionalLoopNode node){
130     inASTUnconditionalLoopNode(node);
131     normalRetrieving(node);
132     outASTUnconditionalLoopNode(node);
133     }
134     
135
136
137
138     public void inASTSwitchNode(ASTSwitchNode node){
139     if(verbose)
140     System.out.println("inASTSwitchNode");
141     }
142     public void outASTSwitchNode(ASTSwitchNode node){
143     if(verbose)
144     System.out.println("outASTSwitchNode");
145     }
146     public void caseASTSwitchNode(ASTSwitchNode node){
147     inASTSwitchNode(node);
148
149     /*
150       apply on key of switchStatement
151     */

152     Value key = node.get_Key();
153     decideCaseExprOrRef(key);
154     /*
155       Apply on bodies of switch cases
156     */

157     normalRetrieving(node);
158     outASTSwitchNode(node);
159     }
160
161
162
163
164
165
166
167
168
169
170
171     public void inASTIfNode(ASTIfNode node){
172     if(verbose)
173     System.out.println("inASTIfNode");
174     }
175     public void outASTIfNode(ASTIfNode node){
176     if(verbose)
177     System.out.println("outASTIfNode");
178     }
179     public void caseASTIfNode(ASTIfNode node){
180     inASTIfNode(node);
181
182     /*
183       apply on the ASTCondition
184     */

185     ASTCondition condition = node.get_Condition();
186     condition.apply(this);
187
188     /*
189       Apply on the if body
190     */

191     normalRetrieving(node);
192     outASTIfNode(node);
193     }
194
195
196
197
198
199
200
201     public void inASTIfElseNode(ASTIfElseNode node){
202     if(verbose)
203     System.out.println("inASTIfElseNode");
204     }
205     public void outASTIfElseNode(ASTIfElseNode node){
206     if(verbose)
207     System.out.println("outASTIfElseNode");
208     }
209     public void caseASTIfElseNode(ASTIfElseNode node){
210     inASTIfElseNode(node);
211
212     /*
213       apply on the ASTCondition
214     */

215     ASTCondition condition = node.get_Condition();
216     condition.apply(this);
217
218     /*
219       Apply on the if body followed by the else body
220     */

221     normalRetrieving(node);
222
223
224     outASTIfElseNode(node);
225     }
226
227
228
229
230
231
232
233
234
235
236     public void inASTWhileNode(ASTWhileNode node){
237     if(verbose)
238     System.out.println("inASTWhileNode");
239     }
240     public void outASTWhileNode(ASTWhileNode node){
241     if(verbose)
242     System.out.println("outASTWhileNode");
243     }
244     public void caseASTWhileNode(ASTWhileNode node){
245     inASTWhileNode(node);
246
247     /*
248       apply on the ASTCondition
249     */

250     ASTCondition condition = node.get_Condition();
251     condition.apply(this);
252
253     /*
254       Apply on the while body
255     */

256     normalRetrieving(node);
257     outASTWhileNode(node);
258     }
259
260
261
262
263     public void inASTForLoopNode(ASTForLoopNode node){
264     if(verbose)
265         System.out.println("inASTForLoopNode");
266     }
267     public void outASTForLoopNode(ASTForLoopNode node){
268     if(verbose)
269         System.out.println("outASTForLoopNode");
270     }
271     public void caseASTForLoopNode(ASTForLoopNode node){
272     inASTForLoopNode(node);
273
274
275
276     /*
277       Apply on init
278     */

279     List init=node.getInit();
280     Iterator it = init.iterator();
281     while(it.hasNext()){
282         AugmentedStmt as = (AugmentedStmt)it.next();
283         Stmt s = as.get_Stmt();
284         if (s instanceof DefinitionStmt)
285         caseDefinitionStmt((DefinitionStmt)s);
286         else if (s instanceof ReturnStmt)
287         caseReturnStmt((ReturnStmt)s);
288         else if (s instanceof InvokeStmt)
289         caseInvokeStmt((InvokeStmt)s);
290         else if (s instanceof ThrowStmt)
291         caseThrowStmt((ThrowStmt)s);
292         else
293         caseStmt(s);
294     }
295
296
297     /*
298       apply on the ASTCondition
299     */

300     ASTCondition condition = node.get_Condition();
301     condition.apply(this);
302
303     /*
304       Apply on update
305     */

306     List update=node.getUpdate();
307     it = update.iterator();
308     while(it.hasNext()){
309         AugmentedStmt as = (AugmentedStmt)it.next();
310         Stmt s = as.get_Stmt();
311
312         if (s instanceof DefinitionStmt)
313         caseDefinitionStmt((DefinitionStmt)s);
314         else if (s instanceof ReturnStmt)
315         caseReturnStmt((ReturnStmt)s);
316         else if (s instanceof InvokeStmt)
317         caseInvokeStmt((InvokeStmt)s);
318         else if (s instanceof ThrowStmt)
319         caseThrowStmt((ThrowStmt)s);
320         else
321         caseStmt(s);
322     }
323
324     /*
325       Apply on the for body
326     */

327     normalRetrieving(node);
328     outASTForLoopNode(node);
329     }
330
331
332
333
334
335     public void inASTDoWhileNode(ASTDoWhileNode node){
336     if(verbose)
337     System.out.println("inASTDoWhileNode");
338     }
339     public void outASTDoWhileNode(ASTDoWhileNode node){
340     if(verbose)
341     System.out.println("outASTDoWhileNode");
342     }
343     public void caseASTDoWhileNode(ASTDoWhileNode node){
344     inASTDoWhileNode(node);
345
346     /*
347       apply on the ASTCondition
348     */

349     ASTCondition condition = node.get_Condition();
350     condition.apply(this);
351
352     /*
353       Apply on the while body
354     */

355     normalRetrieving(node);
356     outASTDoWhileNode(node);
357     }
358
359
360
361
362
363
364     public void inASTTryNode(ASTTryNode node){
365     if(verbose)
366     System.out.println("inASTTryNode");
367     }
368     public void outASTTryNode(ASTTryNode node){
369     if(verbose)
370     System.out.println("outASTTryNode");
371     }
372     public void caseASTTryNode(ASTTryNode node){
373     inASTTryNode(node);
374
375     //get try body
376
List tryBody = node.get_TryBody();
377     Iterator it = tryBody.iterator();
378
379     //go over the ASTNodes in this tryBody and apply
380
while (it.hasNext())
381         ((ASTNode) it.next()).apply(this);
382     
383
384     Map exceptionMap = node.get_ExceptionMap();
385     Map paramMap = node.get_ParamMap();
386     //get catch list and apply on the following
387
// a, type of exception caught
388
// b, local of exception
389
// c, catchBody
390
List catchList = node.get_CatchList();
391     Iterator itBody=null;
392         it = catchList.iterator();
393     while (it.hasNext()) {
394         ASTTryNode.container catchBody = (ASTTryNode.container)it.next();
395         
396         SootClass sootClass = ((SootClass)exceptionMap.get(catchBody));
397         Type type = sootClass.getType();
398         
399         //apply on type of exception
400
caseType(type);
401
402         //apply on local of exception
403
Local local = (Local)paramMap.get(catchBody);
404         decideCaseExprOrRef(local);
405
406         //apply on catchBody
407
List body = (List)catchBody.o;
408         itBody = body.iterator();
409         while(itBody.hasNext()){
410         ((ASTNode) itBody.next()).apply(this);
411         }
412     }
413     outASTTryNode(node);
414     }
415
416
417
418
419
420
421
422     
423     public void inASTUnaryCondition(ASTUnaryCondition uc){
424     if(verbose)
425         System.out.println("inASTUnaryCondition");
426     }
427     public void outASTUnaryCondition(ASTUnaryCondition uc){
428     if(verbose)
429         System.out.println("outASTUnaryCondition");
430     }
431     public void caseASTUnaryCondition(ASTUnaryCondition uc){
432     inASTUnaryCondition(uc);
433     //apply on the value
434
decideCaseExprOrRef(uc.getValue());
435     outASTUnaryCondition(uc);
436     }
437
438
439
440
441     public void inASTBinaryCondition(ASTBinaryCondition bc){
442     if(verbose)
443         System.out.println("inASTBinaryCondition");
444     }
445     public void outASTBinaryCondition(ASTBinaryCondition bc){
446     if(verbose)
447         System.out.println("outASTBinaryCondition");
448     }
449     public void caseASTBinaryCondition(ASTBinaryCondition bc){
450     inASTBinaryCondition(bc);
451
452     ConditionExpr condition = bc.getConditionExpr();
453     //calling decideCaseExprOrRef although we know for sure this is an Expr but doesnt matter
454
decideCaseExprOrRef(condition);
455
456     outASTBinaryCondition(bc);
457     }
458
459
460
461
462
463
464
465     public void inASTAndCondition(ASTAndCondition ac){
466     if(verbose)
467         System.out.println("inASTAndCondition");
468     }
469     public void outASTAndCondition(ASTAndCondition ac){
470     if(verbose)
471         System.out.println("outASTAndCondition");
472     }
473     public void caseASTAndCondition(ASTAndCondition ac){
474     inASTAndCondition(ac);
475
476     ((ASTCondition)(ac.getLeftOp())).apply(this);
477     ((ASTCondition)(ac.getRightOp())).apply(this);
478
479     outASTAndCondition(ac);
480     }
481
482
483
484
485
486     public void inASTOrCondition(ASTOrCondition oc){
487     if(verbose)
488         System.out.println("inASTOrCondition");
489     }
490     public void outASTOrCondition(ASTOrCondition oc){
491     if(verbose)
492         System.out.println("outASTOrCondition");
493     }
494     public void caseASTOrCondition(ASTOrCondition oc){
495     inASTOrCondition(oc);
496
497     ((ASTCondition)(oc.getLeftOp())).apply(this);
498     ((ASTCondition)(oc.getRightOp())).apply(this);
499
500     outASTOrCondition(oc);
501     }
502
503
504
505
506
507
508
509
510
511
512     public void inType(Type t){
513         if(verbose)
514         System.out.println("inType");
515     }
516     public void outType(Type t){
517         if(verbose)
518         System.out.println("outType");
519     }
520     public void caseType(Type t){
521         inType(t);
522         outType(t);
523     }
524
525
526
527
528
529     public void normalRetrieving(ASTNode node){
530     //from the Node get the subBodes
531
Iterator sbit = node.get_SubBodies().iterator();
532     while (sbit.hasNext()) {
533         Object JavaDoc subBody = sbit.next();
534         Iterator it = ((List) subBody).iterator();
535
536         //go over the ASTNodes in this subBody and apply
537
while (it.hasNext()){
538         ASTNode temp = (ASTNode) it.next();
539
540         temp.apply(this);
541         }
542     }//end of going over subBodies
543
}
544
545
546
547
548
549     public void inASTStatementSequenceNode(ASTStatementSequenceNode node){
550     if(verbose)
551     System.out.println("inASTStatementSequenceNode");
552     }
553     public void outASTStatementSequenceNode(ASTStatementSequenceNode node){
554     if(verbose)
555     System.out.println("outASTStatementSequenceNode");
556     }
557
558     public void caseASTStatementSequenceNode(ASTStatementSequenceNode node){
559     inASTStatementSequenceNode(node);
560     Iterator it = node.getStatements().iterator();
561     while (it.hasNext()){
562         AugmentedStmt as = (AugmentedStmt)it.next();
563         Stmt s = as.get_Stmt();
564         /*
565           Do a case by case check of possible statements and invoke
566           the case methods from within this method.
567           
568           cant use apply since the Statements are defined in some other
569           package and dont want to change code all over the place
570         */

571
572         if (s instanceof DefinitionStmt)
573         caseDefinitionStmt((DefinitionStmt)s);
574         else if (s instanceof ReturnStmt)
575         caseReturnStmt((ReturnStmt)s);
576         else if (s instanceof InvokeStmt)
577         caseInvokeStmt((InvokeStmt)s);
578         else if (s instanceof ThrowStmt)
579         caseThrowStmt((ThrowStmt)s);
580         else if (s instanceof DVariableDeclarationStmt)
581         caseDVariableDeclarationStmt((DVariableDeclarationStmt)s);
582         else
583         caseStmt(s);
584         
585     }//end of while going through the statement sequence
586
outASTStatementSequenceNode(node);
587     }
588
589
590
591     public void inDefinitionStmt(DefinitionStmt s){
592     if(verbose)
593         System.out.println("inDefinitionStmt"+s);
594     }
595     public void outDefinitionStmt(DefinitionStmt s){
596     if(verbose)
597         System.out.println("outDefinitionStmt");
598     }
599     public void caseDefinitionStmt(DefinitionStmt s){
600     inDefinitionStmt(s);
601
602     decideCaseExprOrRef(s.getRightOp());
603     decideCaseExprOrRef(s.getLeftOp());
604
605     outDefinitionStmt(s);
606      }
607
608
609
610
611     public void inReturnStmt(ReturnStmt s){
612     if(verbose)
613         System.out.println("inReturnStmt");
614     // System.out.println("Return Stmt:"+s);
615
}
616     public void outReturnStmt(ReturnStmt s){
617     if(verbose)
618         System.out.println("outReturnStmt");
619     }
620     public void caseReturnStmt(ReturnStmt s){
621     inReturnStmt(s);
622
623     decideCaseExprOrRef(s.getOp());
624       
625     outReturnStmt(s);
626     }
627
628
629
630
631
632
633
634
635     public void inInvokeStmt(InvokeStmt s){
636     if(verbose)
637         System.out.println("inInvokeStmt");
638     }
639     public void outInvokeStmt(InvokeStmt s){
640     if(verbose)
641         System.out.println("outInvokeStmt");
642     }
643     public void caseInvokeStmt(InvokeStmt s){
644     inInvokeStmt(s);
645     
646     decideCaseExprOrRef(s.getInvokeExpr());
647     
648     outInvokeStmt(s);
649     }
650
651
652
653     public void inThrowStmt(ThrowStmt s){
654     if(verbose)
655         System.out.println("\n\ninThrowStmt\n\n");
656     }
657     public void outThrowStmt(ThrowStmt s){
658     if(verbose)
659         System.out.println("outThrowStmt");
660     }
661     public void caseThrowStmt(ThrowStmt s){
662     inThrowStmt(s);
663
664     decideCaseExprOrRef(s.getOp());
665
666     outThrowStmt(s);
667     }
668
669
670
671
672
673
674     public void inDVariableDeclarationStmt(DVariableDeclarationStmt s){
675     if(verbose)
676         System.out.println("\n\ninDVariableDeclarationStmt\n\n"+s);
677     }
678     public void outDVariableDeclarationStmt(DVariableDeclarationStmt s){
679     if(verbose)
680         System.out.println("outDVariableDeclarationStmt");
681     }
682     public void caseDVariableDeclarationStmt(DVariableDeclarationStmt s){
683     inDVariableDeclarationStmt(s);
684
685     //a variableDeclarationStmt has a type followed by a list of locals
686
Type type = s.getType();
687     caseType(type);
688
689     List listDeclared = s.getDeclarations();
690     Iterator it = listDeclared.iterator();
691     while(it.hasNext()){
692         Local declared = (Local)it.next();
693         decideCaseExprOrRef(declared);
694     }
695
696     outDVariableDeclarationStmt(s);
697     }
698     
699
700
701
702     public void inStmt(Stmt s){
703     if(verbose)
704         System.out.println("inStmt: "+s);
705
706     /*
707       if(s instanceof DAbruptStmt)
708       System.out.println("DAbruptStmt: "+s);
709       if(s instanceof ReturnVoidStmt)
710       System.out.println("ReturnVoidStmt: "+s);
711     */

712     }
713     public void outStmt(Stmt s){
714     if(verbose)
715         System.out.println("outStmt");
716     }
717     public void caseStmt(Stmt s){
718     inStmt(s);
719     outStmt(s);
720     }
721
722
723
724
725
726
727     public void decideCaseExprOrRef(Value v){
728         if (v instanceof Expr)
729         caseExpr((Expr)v);
730     else if (v instanceof Ref)
731         caseRef((Ref)v);
732     else
733         caseValue(v);
734     }
735
736
737
738
739     public void inValue(Value v){
740     if(verbose){
741         System.out.println("inValue"+v);
742         
743         if(v instanceof DThisRef)
744         System.out.println("DTHISREF.................");
745         else if(v instanceof Immediate){
746         System.out.println("\tIMMEDIATE");
747         if(v instanceof soot.jimple.internal.JimpleLocal){
748             System.out.println("\t\tJimpleLocal...................."+v);
749             
750         }
751         else if(v instanceof Constant){
752             System.out.println("\t\tconstant....................");
753         }
754         else if(v instanceof soot.baf.internal.BafLocal){
755             System.out.println("\t\tBafLocal....................");
756         }
757         else
758             System.out.println("\t\telse!!!!!!!!!!!!");
759         }
760         else {
761         System.out.println("NEITHER................");
762         }
763     }
764     }
765     public void outValue(Value v){
766     if(verbose)
767     System.out.println("outValue");
768     }
769     public void caseValue(Value v){
770     inValue(v);
771     outValue(v);
772     }
773
774
775
776
777
778     public void inExpr(Expr e){
779     if(verbose)
780     System.out.println("inExpr");
781     }
782     public void outExpr(Expr e){
783     if(verbose)
784     System.out.println("outExpr");
785     }
786     public void caseExpr(Expr e){
787     inExpr(e);
788     decideCaseExpr(e);
789     outExpr(e);
790     }
791
792
793
794
795     public void inRef(Ref r){
796     if(verbose)
797     System.out.println("inRef");
798     }
799     public void outRef(Ref r){
800     if(verbose)
801     System.out.println("outRef");
802     }
803     public void caseRef(Ref r){
804     inRef(r);
805     decideCaseRef(r);
806     outRef(r);
807     }
808
809
810
811
812     public void decideCaseExpr(Expr e){
813     if (e instanceof BinopExpr)
814         caseBinopExpr((BinopExpr)e);
815     else if (e instanceof UnopExpr)
816         caseUnopExpr((UnopExpr)e);
817     else if (e instanceof NewArrayExpr)
818         caseNewArrayExpr((NewArrayExpr)e);
819     else if (e instanceof NewMultiArrayExpr)
820         caseNewMultiArrayExpr((NewMultiArrayExpr)e);
821     else if (e instanceof InstanceOfExpr)
822         caseInstanceOfExpr((InstanceOfExpr)e);
823     else if (e instanceof InvokeExpr)
824         caseInvokeExpr((InvokeExpr)e);
825     else if (e instanceof CastExpr)
826         caseCastExpr((CastExpr)e);
827     }
828
829
830
831
832
833     public void inBinopExpr(BinopExpr be){
834     if(verbose)
835     System.out.println("inBinopExpr");
836     }
837     public void outBinopExpr(BinopExpr be){
838     if(verbose)
839     System.out.println("outBinopExpr");
840     }
841     public void caseBinopExpr(BinopExpr be){
842     inBinopExpr(be);
843
844     decideCaseExprOrRef(be.getOp1());
845     decideCaseExprOrRef(be.getOp2());
846
847     outBinopExpr(be);
848     }
849
850
851
852
853     public void inUnopExpr(UnopExpr ue){
854     if(verbose)
855     System.out.println("inUnopExpr");
856     }
857     public void outUnopExpr(UnopExpr ue){
858     if(verbose)
859     System.out.println("outUnopExpr");
860     }
861     public void caseUnopExpr(UnopExpr ue){
862     inUnopExpr(ue);
863
864     decideCaseExprOrRef(ue.getOp());
865
866     outUnopExpr(ue);
867     }
868     
869
870
871
872     public void inNewArrayExpr(NewArrayExpr nae){
873     if(verbose)
874     System.out.println("inNewArrayExpr");
875     }
876     public void outNewArrayExpr(NewArrayExpr nae){
877     if(verbose)
878     System.out.println("outNewArrayExpr");
879     }
880     public void caseNewArrayExpr(NewArrayExpr nae){
881     inNewArrayExpr(nae);
882
883     decideCaseExprOrRef(nae.getSize());
884
885     outNewArrayExpr(nae);
886     }
887
888
889
890
891     public void inNewMultiArrayExpr(NewMultiArrayExpr nmae){
892     if(verbose)
893     System.out.println("inNewMultiArrayExpr");
894     }
895     public void outNewMultiArrayExpr(NewMultiArrayExpr nmae){
896     if(verbose)
897     System.out.println("outNewMultiArrayExpr");
898     }
899     public void caseNewMultiArrayExpr(NewMultiArrayExpr nmae){
900     inNewMultiArrayExpr(nmae);
901
902     for (int i=0; i<nmae.getSizeCount(); i++)
903         decideCaseExprOrRef(nmae.getSize(i));
904     
905     outNewMultiArrayExpr(nmae);
906     }
907
908
909
910
911     public void inInstanceOfExpr(InstanceOfExpr ioe){
912     if(verbose)
913     System.out.println("inInstanceOfExpr");
914     }
915     public void outInstanceOfExpr(InstanceOfExpr ioe){
916     if(verbose)
917     System.out.println("outInstanceOfExpr");
918     }
919     public void caseInstanceOfExpr(InstanceOfExpr ioe){
920     inInstanceOfExpr(ioe);
921
922     decideCaseExprOrRef(ioe.getOp());
923
924     outInstanceOfExpr(ioe);
925     }
926
927
928
929
930     public void inInvokeExpr(InvokeExpr ie){
931     if(verbose)
932     System.out.println("inInvokeExpr");
933     }
934     public void outInvokeExpr(InvokeExpr ie){
935     if(verbose)
936     System.out.println("outInvokeExpr");
937     }
938     public void caseInvokeExpr(InvokeExpr ie){
939     inInvokeExpr(ie);
940
941     for (int i=0; i<ie.getArgCount(); i++)
942         decideCaseExprOrRef(ie.getArg( i));
943     if (ie instanceof InstanceInvokeExpr)
944         caseInstanceInvokeExpr((InstanceInvokeExpr)ie);
945
946     outInvokeExpr(ie);
947     }
948
949
950     public void inInstanceInvokeExpr(InstanceInvokeExpr iie){
951     if(verbose)
952     System.out.println("inInstanceInvokeExpr");
953     }
954     public void outInstanceInvokeExpr(InstanceInvokeExpr iie){
955     if(verbose)
956     System.out.println("outInstanceInvokeExpr");
957     }
958     public void caseInstanceInvokeExpr(InstanceInvokeExpr iie){
959     inInstanceInvokeExpr(iie);
960
961     decideCaseExprOrRef(iie.getBase());
962     
963     outInstanceInvokeExpr(iie);
964     }
965
966
967
968     public void inCastExpr(CastExpr ce){
969     if(verbose)
970         System.out.println("inCastExpr");
971     }
972     public void outCastExpr(CastExpr ce){
973     if(verbose)
974         System.out.println("outCastExpr");
975     }
976     public void caseCastExpr(CastExpr ce){
977     inCastExpr(ce);
978     Type type = ce.getCastType();
979     caseType(type);
980
981     Value op = ce.getOp();
982     decideCaseExprOrRef(op);
983
984     outCastExpr(ce);
985     }
986
987
988
989
990
991     public void decideCaseRef(Ref r){
992     if (r instanceof ArrayRef)
993         caseArrayRef((ArrayRef)r);
994     else if (r instanceof InstanceFieldRef)
995         caseInstanceFieldRef((InstanceFieldRef)r);
996     else if (r instanceof StaticFieldRef)
997         caseStaticFieldRef((StaticFieldRef)r);
998     }
999
1000    
1001
1002
1003
1004    public void inArrayRef(ArrayRef ar){
1005    if(verbose)
1006    System.out.println("inArrayRef");
1007    }
1008    public void outArrayRef(ArrayRef ar){
1009    if(verbose)
1010    System.out.println("outArrayRef");
1011    }
1012    public void caseArrayRef(ArrayRef ar){
1013    inArrayRef(ar);
1014    decideCaseExprOrRef(ar.getBase());
1015    decideCaseExprOrRef(ar.getIndex());
1016    outArrayRef(ar);
1017    }
1018
1019
1020
1021    public void inInstanceFieldRef(InstanceFieldRef ifr){
1022    if(verbose){
1023        System.out.println("inInstanceFieldRef");
1024
1025        if(ifr instanceof DInstanceFieldRef){
1026        System.out.println("...........DINSTANCEFIELDREF");
1027        
1028        }
1029    }
1030    }
1031    public void outInstanceFieldRef(InstanceFieldRef ifr){
1032    if(verbose)
1033    System.out.println("outInstanceFieldRef");
1034    }
1035    public void caseInstanceFieldRef(InstanceFieldRef ifr){
1036    inInstanceFieldRef(ifr);
1037    decideCaseExprOrRef(ifr.getBase());
1038    outInstanceFieldRef(ifr);
1039    }
1040
1041
1042
1043
1044
1045
1046
1047    public void inStaticFieldRef(StaticFieldRef sfr){
1048    if(verbose)
1049        System.out.println("inStaticFieldRef");
1050    }
1051    public void outStaticFieldRef(StaticFieldRef sfr){
1052    if(verbose)
1053        System.out.println("outStaticFieldRef");
1054    }
1055    public void caseStaticFieldRef(StaticFieldRef sfr){
1056    inStaticFieldRef(sfr);
1057    outStaticFieldRef(sfr);
1058    }
1059
1060
1061    public void debug(String JavaDoc className, String JavaDoc methodName, String JavaDoc debug){
1062        if(DEBUG)
1063            System.out.println("Analysis"+className+"..Method:"+methodName+ " DEBUG: "+debug);
1064    }
1065
1066}
1067
Popular Tags