View Javadoc

1   // ControlFlowGraphVisitor.java, created Mon Feb 11  0:24:01 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   import joeq.Class.jq_Method;
7   import joeq.Class.jq_MethodVisitor;
8   
9   /***
10   *
11   * @author  John Whaley <jwhaley@alum.mit.edu>
12   * @version $Id: ControlFlowGraphVisitor.java 1456 2004-03-09 22:01:46Z jwhaley $
13   */
14  public interface ControlFlowGraphVisitor {
15      void visitCFG(ControlFlowGraph cfg);
16      
17      class CodeCacheVisitor extends jq_MethodVisitor.EmptyVisitor {
18          private final ControlFlowGraphVisitor bbv;
19          boolean trace;
20          public CodeCacheVisitor(ControlFlowGraphVisitor bbv) { this.bbv = bbv; }
21          public CodeCacheVisitor(ControlFlowGraphVisitor bbv, boolean trace) { this.bbv = bbv; this.trace = trace; }
22          public void visitMethod(jq_Method m) {
23              if (m.getBytecode() == null) return;
24              if (trace) System.out.println(m.toString());
25              ControlFlowGraph cfg = joeq.Compiler.Quad.CodeCache.getCode(m);
26              bbv.visitCFG(cfg);
27          }
28      }
29  
30  }