Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

SLABSReport.java

00001 package edu.ksu.cis.bandera.report;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 2001   Robby (robby@cis.ksu.edu)                    *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * This work was done as a project in the SAnToS Laboratory,         *
00009  * Department of Computing and Information Sciences, Kansas State    *
00010  * University, USA (http://www.cis.ksu.edu/santos).                  *
00011  * It is understood that any modification not identified as such is  *
00012  * not covered by the preceding statement.                           *
00013  *                                                                   *
00014  * This work is free software; you can redistribute it and/or        *
00015  * modify it under the terms of the GNU Library General Public       *
00016  * License as published by the Free Software Foundation; either      *
00017  * version 2 of the License, or (at your option) any later version.  *
00018  *                                                                   *
00019  * This work is distributed in the hope that it will be useful,      *
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00022  * Library General Public License for more details.                  *
00023  *                                                                   *
00024  * You should have received a copy of the GNU Library General Public *
00025  * License along with this toolkit; if not, write to the             *
00026  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00027  * Boston, MA  02111-1307, USA.                                      *
00028  *                                                                   *
00029  * Java is a trademark of Sun Microsystems, Inc.                     *
00030  *                                                                   *
00031  * To submit a bug report, send a comment, or get the latest news on *
00032  * this project and other SAnToS projects, please visit the web-site *
00033  *                http://www.cis.ksu.edu/santos                      *
00034  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00035 import java.io.*;
00036 import java.util.*;
00037 import ca.mcgill.sable.soot.*;
00038 import ca.mcgill.sable.soot.jimple.*;
00039 import edu.ksu.cis.bandera.abstraction.typeinference.*;
00040 public class SLABSReport implements Report {
00041     private String typeInfo;
00042 /**
00043  * getFilename method comment.
00044  */
00045 public String getFilename() {
00046     return "slabs.report";
00047 }
00048 /**
00049  * getTextRepresentation method comment.
00050  */
00051 public String getTextRepresentation() {
00052     return typeInfo;
00053 }
00054 /**
00055  * 
00056  * @param t edu.ksu.cis.bandera.abstraction.typeinference.TypeTable
00057  */
00058 public void setTypeTable(TypeTable t) {
00059     StringWriter sw = new StringWriter();
00060     PrintWriter pw = new PrintWriter(sw);
00061 
00062     pw.println("SLABS Report");
00063     pw.println("============");
00064     pw.println("");
00065     pw.println("");
00066     pw.println("");
00067 
00068     pw.println("Type Info");
00069     pw.println("---------");
00070     pw.println("");
00071     
00072     Hashtable h = edu.ksu.cis.bandera.jjjc.CompilationManager.getCompiledClasses();
00073 
00074     TreeSet classNames = new TreeSet();
00075     for (Enumeration e = h.keys(); e.hasMoreElements();) {
00076         classNames.add(e.nextElement());
00077     }
00078 
00079     for (Iterator i = classNames.iterator(); i.hasNext();) {
00080         String className = (String) i.next();
00081         pw.println("class " + className + " {");
00082 
00083         SootClass sc = (SootClass) h.get(className);
00084 
00085         TreeSet fieldNames = new TreeSet();
00086         Object[] sootFields = sc.getFields().toArray();
00087         for (int j = 0; j < sootFields.length; j++) {
00088              fieldNames.add(((SootField) sootFields[j]).getName());
00089         }
00090 
00091         for (Iterator j = fieldNames.iterator(); j.hasNext();) {
00092             String fieldName = (String) j.next();
00093             SootField sf = sc.getField(fieldName);
00094             pw.println("  " + sf.getName() + " : " + t.get(sf));
00095         }
00096 
00097         TreeSet methodSignatures = new TreeSet();
00098         Hashtable methodTable = new Hashtable();
00099         Object[] sootMethods = sc.getMethods().toArray();
00100         for (int j = 0; j < sootMethods.length; j++) {
00101             SootMethod sm = (SootMethod) sootMethods[j];
00102             String methodSignature = sm.toString();
00103             methodSignatures.add(methodSignature);
00104             methodTable.put(methodSignature, sm);   
00105         }
00106 
00107         for (Iterator j = methodSignatures.iterator(); j.hasNext();) {
00108             String methodSignature = (String) j.next();
00109 
00110             pw.println("  " + methodSignature + " {");
00111                 
00112             SootMethod sm = (SootMethod) methodTable.get(methodSignature);
00113             JimpleBody jb = (JimpleBody) sm.getBody(Jimple.v());
00114 
00115             TreeSet localNames = new TreeSet();
00116             Object[] locals = jb.getLocals().toArray();
00117 
00118             for (int k = 0; k < locals.length; k++) {
00119                 localNames.add(((Local) locals[k]).getName());
00120             }
00121 
00122             for (Iterator k = localNames.iterator(); k.hasNext();) {
00123                 String localName = (String) k.next();
00124                 Local l = jb.getLocal(localName);
00125                 pw.println("    " + localName + " : " + t.get(l));
00126             }
00127             
00128             pw.println("  }");
00129         }
00130             
00131         pw.println("}");
00132         pw.println("");
00133     }
00134     
00135     typeInfo = sw.toString();
00136 }
00137 }

Generated at Thu Feb 7 06:54:58 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001