View Javadoc

1   // QuadVisitor.java, created Fri Jan 11 16:42:38 2002 by joewhaley
2   // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3   // Licensed under the terms of the GNU LGPL; see COPYING for details.
4   package joeq.Compiler.Quad;
5   
6   /***
7    * @author  John Whaley <jwhaley@alum.mit.edu>
8    * @version $Id: QuadVisitor.java 1590 2004-03-26 23:20:37Z joewhaley $
9    */
10  public interface QuadVisitor {
11  
12      /*** A potentially excepting instruction.. */
13      void visitExceptionThrower(Quad obj);
14      /*** An instruction that loads from memory. */
15      void visitLoad(Quad obj);
16      /*** An instruction that stores into memory. */
17      void visitStore(Quad obj);
18      /*** An instruction that may branch (not including exceptional control flow). */
19      void visitBranch(Quad obj);
20      /*** A conditional branch instruction. */
21      void visitCondBranch(Quad obj);
22      /*** An exception check instruction. */
23      void visitCheck(Quad obj);
24      /*** An instruction.that accesses a static field. */
25      void visitStaticField(Quad obj);
26      /*** An instruction.that accesses an instance field. */
27      void visitInstanceField(Quad obj);
28      /*** An instruction.that accesses an array. */
29      void visitArray(Quad obj);
30      /*** An instruction.that does an allocation. */
31      void visitAllocation(Quad obj);
32      /*** An instruction.that does a type check. */
33      void visitTypeCheck(Quad obj);
34      
35      /*** An array load instruction. */
36      void visitALoad(Quad obj);
37      /*** An array store instruction. */
38      void visitAStore(Quad obj);
39      /*** An array length instruction. */
40      void visitALength(Quad obj);
41      /*** A binary operation instruction. */
42      void visitBinary(Quad obj);
43      /*** An array bounds check instruction. */
44      void visitBoundsCheck(Quad obj);
45      /*** A type cast check instruction. */
46      void visitCheckCast(Quad obj);
47      /*** A get instance field instruction. */
48      void visitGetfield(Quad obj);
49      /*** A get static field instruction. */
50      void visitGetstatic(Quad obj);
51      /*** A goto instruction. */
52      void visitGoto(Quad obj);
53      /*** A type instance of instruction. */
54      void visitInstanceOf(Quad obj);
55      /*** A compare and branch instruction. */
56      void visitIntIfCmp(Quad obj);
57      /*** An invoke instruction. */
58      void visitInvoke(Quad obj);
59      /*** A jump local subroutine instruction. */
60      void visitJsr(Quad obj);
61      /*** A lookup switch instruction. */
62      void visitLookupSwitch(Quad obj);
63      /*** A raw memory load instruction. */
64      void visitMemLoad(Quad obj);
65      /*** A raw memory store instruction. */
66      void visitMemStore(Quad obj);
67      /*** An object monitor lock/unlock instruction. */
68      void visitMonitor(Quad obj);
69      /*** A register move instruction. */
70      void visitMove(Quad obj);
71      /*** An object allocation instruction. */
72      void visitNew(Quad obj);
73      /*** An array allocation instruction. */
74      void visitNewArray(Quad obj);
75      /*** A null pointer check instruction. */
76      void visitNullCheck(Quad obj);
77      /*** A phi instruction. (For SSA.) */
78      void visitPhi(Quad obj);
79      /*** A put instance field instruction. */
80      void visitPutfield(Quad obj);
81      /*** A put static field instruction. */
82      void visitPutstatic(Quad obj);
83      /*** A return from local subroutine instruction. */
84      void visitRet(Quad obj);
85      /*** A return from method instruction. */
86      void visitReturn(Quad obj);
87      /*** A special instruction. */
88      void visitSpecial(Quad obj);
89      /*** An object array store type check instruction. */
90      void visitStoreCheck(Quad obj);
91      /*** A jump table switch instruction. */
92      void visitTableSwitch(Quad obj);
93      /*** A unary operation instruction. */
94      void visitUnary(Quad obj);
95      /*** A divide-by-zero check instruction. */
96      void visitZeroCheck(Quad obj);
97      
98      /*** Any quad. */
99      void visitQuad(Quad obj);
100     
101     abstract class EmptyVisitor implements QuadVisitor {
102         /*** A potentially excepting instruction.. */
103         public void visitExceptionThrower(Quad obj) {}
104         /*** An instruction that loads from memory. */
105         public void visitLoad(Quad obj) {}
106         /*** An instruction that stores into memory. */
107         public void visitStore(Quad obj) {}
108         /*** An instruction that may branch (not including exceptional control flow). */
109         public void visitBranch(Quad obj) {}
110         /*** A conditional branch instruction. */
111         public void visitCondBranch(Quad obj) {}
112         /*** An exception check instruction. */
113         public void visitCheck(Quad obj) {}
114         /*** An instruction.that accesses a static field. */
115         public void visitStaticField(Quad obj) {}
116         /*** An instruction.that accesses an instance field. */
117         public void visitInstanceField(Quad obj) {}
118         /*** An instruction.that accesses an array. */
119         public void visitArray(Quad obj) {}
120         /*** An instruction.that does an allocation. */
121         public void visitAllocation(Quad obj) {}
122         /*** An instruction.that does a type check. */
123         public void visitTypeCheck(Quad obj) {}
124 
125         /*** An array load instruction. */
126         public void visitALoad(Quad obj) {}
127         /*** An array store instruction. */
128         public void visitAStore(Quad obj) {}
129         /*** An array length instruction. */
130         public void visitALength(Quad obj) {}
131         /*** A binary operation instruction. */
132         public void visitBinary(Quad obj) {}
133         /*** An array bounds check instruction. */
134         public void visitBoundsCheck(Quad obj) {}
135         /*** A type cast check instruction. */
136         public void visitCheckCast(Quad obj) {}
137         /*** A get instance field instruction. */
138         public void visitGetfield(Quad obj) {}
139         /*** A get static field instruction. */
140         public void visitGetstatic(Quad obj) {}
141         /*** A goto instruction. */
142         public void visitGoto(Quad obj) {}
143         /*** A type instance of instruction. */
144         public void visitInstanceOf(Quad obj) {}
145         /*** A compare and branch instruction. */
146         public void visitIntIfCmp(Quad obj) {}
147         /*** An invoke instruction. */
148         public void visitInvoke(Quad obj) {}
149         /*** A jump local subroutine instruction. */
150         public void visitJsr(Quad obj) {}
151         /*** A lookup switch instruction. */
152         public void visitLookupSwitch(Quad obj) {}
153         /*** A raw memory load instruction. */
154         public void visitMemLoad(Quad obj) {}
155         /*** A raw memory store instruction. */
156         public void visitMemStore(Quad obj) {}
157         /*** An object monitor lock/unlock instruction. */
158         public void visitMonitor(Quad obj) {}
159         /*** A register move instruction. */
160         public void visitMove(Quad obj) {}
161         /*** An object allocation instruction. */
162         public void visitNew(Quad obj) {}
163         /*** An array allocation instruction. */
164         public void visitNewArray(Quad obj) {}
165         /*** A null pointer check instruction. */
166         public void visitNullCheck(Quad obj) {}
167         /*** A phi instruction. (For SSA.) */
168         public void visitPhi(Quad obj) {}
169         /*** A put instance field instruction. */
170         public void visitPutfield(Quad obj) {}
171         /*** A put static field instruction. */
172         public void visitPutstatic(Quad obj) {}
173         /*** A return from local subroutine instruction. */
174         public void visitRet(Quad obj) {}
175         /*** A return from method instruction. */
176         public void visitReturn(Quad obj) {}
177         /*** A special instruction. */
178         public void visitSpecial(Quad obj) {}
179         /*** An object array store type check instruction. */
180         public void visitStoreCheck(Quad obj) {}
181         /*** A jump table switch instruction. */
182         public void visitTableSwitch(Quad obj) {}
183         /*** A unary operation instruction. */
184         public void visitUnary(Quad obj) {}
185         /*** A divide-by-zero check instruction. */
186         public void visitZeroCheck(Quad obj) {}
187         
188         /*** Any quad. */
189         public void visitQuad(Quad obj) {}
190     }
191     
192     class AllQuadVisitor implements BasicBlockVisitor {
193         final QuadVisitor qv;
194         boolean trace;
195         public AllQuadVisitor(QuadVisitor qv) { this.qv = qv; }
196         public AllQuadVisitor(QuadVisitor qv, boolean trace) { this.qv = qv; this.trace = trace; }
197         public void visitBasicBlock(BasicBlock bb) {
198             if (trace) System.out.println(bb.toString());
199             bb.visitQuads(qv);
200         }
201     }
202     
203 }
204