-
- private void writeFlatIRGraph( FlatMethod fm, String graphname ) throws java.io.IOException {
- // give every node in the flat IR graph a unique label
- // so a human being can inspect the graph and verify
- // correctness
- flatnodetolabel=new Hashtable<FlatNode, Integer>();
- visited=new HashSet<FlatNode>();
- labelindex=0;
- labelFlatNodes( fm );
-
- // take symbols out of graphname that cause dot to fail
- graphname = graphname.replaceAll( "[\\W]", "" );
-
- flatbw=new BufferedWriter( new FileWriter( graphname+"_flatIRGraph.dot" ) );
- flatbw.write("digraph "+graphname+" {\n");
-
- visited=new HashSet<FlatNode>();
- toVisit=new HashSet<FlatNode>();
- toVisit.add(fm);
-
- while( !toVisit.isEmpty() ) {
- FlatNode fn=(FlatNode)toVisit.iterator().next();
- toVisit.remove(fn);
- visited.add(fn);
-
- if( fn.kind() == FKind.FlatMethod ) {
- // FlatMethod does not have toString
- flatbw.write( makeDotNodeDec( graphname, flatnodetolabel.get(fn), fn.getClass().getName(), "FlatMethod" ) );
- } else {
- flatbw.write( makeDotNodeDec( graphname, flatnodetolabel.get(fn), fn.getClass().getName(), fn.toString() ) );
- }
-
- for(int i=0;i<fn.numNext();i++) {
- FlatNode nn=fn.getNext(i);
- flatbw.write( " node"+flatnodetolabel.get(fn)+" -> node"+flatnodetolabel.get(nn)+";\n" );
-
- if( !visited.contains( nn ) ) {
- toVisit.add( nn );
- }
- }
- }
-
- flatbw.write( "}\n" );
- flatbw.close();
+ }
+
+ private void graphMethods() throws java.io.IOException {
+ for(Iterator it_classes=state.getClassSymbolTable().getDescriptorsIterator(); it_classes.hasNext();) {
+ ClassDescriptor cd = (ClassDescriptor)it_classes.next();
+ for(Iterator it_methods=cd.getMethods(); it_methods.hasNext();) {
+ MethodDescriptor md = (MethodDescriptor)it_methods.next();
+ FlatMethod fm = state.getMethodFlat(md);
+ writeFlatIRGraph(fm,cd.getSymbol()+"."+md.getSymbol());
+ }