View Javadoc

1   /*
2    * Created on Sep 19, 2003
3    *
4    * To change the template for this generated file go to
5    * Window>Preferences>Java>Code Generation>Code and Comments
6    */
7   package joeq.Compiler.Analysis.IPSSA;
8   
9   import java.io.PrintStream;
10  import joeq.Class.jq_Method;
11  import joeq.Compiler.Quad.ControlFlowGraph;
12  
13  /***
14   * Goes over all bindings in a method.
15   * @author V.Benjamin Livshits
16   * @version $Id: SSABindingVisitor.java 1931 2004-09-22 22:17:47Z joewhaley $
17   * */
18  public abstract class SSABindingVisitor {
19      public abstract void visit(SSABinding b);
20      
21      /***
22       * Applies itself to all bindings in the CFG.
23       * */
24      public void visitCFG(ControlFlowGraph cfg) {
25          jq_Method method = cfg.getMethod();
26                  
27          for (SSAIterator.BindingIterator j=SSAProcInfo.retrieveQuery(method).getBindingIterator(method); j.hasNext(); ) {
28              SSABinding b = j.nextBinding();
29              b.accept(this);
30          }                
31      }
32      
33      public static class EmptySSABindingVisitor extends SSABindingVisitor {
34          public EmptySSABindingVisitor(){}
35          
36          public void visit(SSABinding b){
37              // do nothing
38          }
39      }
40      
41      public static class SSABindingPrinter extends SSABindingVisitor {
42          protected PrintStream _out;
43          SSABindingPrinter(PrintStream out){
44              this._out = out;
45          }
46          public void visit(SSABinding b){
47              _out.println(b.toString());
48          }
49      }
50  }
51