00001 package edu.ksu.cis.bandera.report;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import java.io.*;
00036 import java.util.*;
00037 import ca.mcgill.sable.soot.jimple.*;
00038 import edu.ksu.cis.bandera.specification.assertion.datastructure.*;
00039 import edu.ksu.cis.bandera.specification.predicate.datastructure.*;
00040
00041 public class BSLReport implements Report {
00042 private static String filename = "bsl.report";
00043
00044 private TreeSet predicates = new TreeSet();
00045 private TreeSet assertions = new TreeSet();
00046 private TreeSet compiledPredicates = new TreeSet();
00047 private Hashtable compiledTable = new Hashtable();
00048
00049
00050
00051
00052
00053
00054
00055 public void addAssertionsAndPredicates() {
00056 for (Enumeration e = AssertionSet.getAssertionSetTable().elements(); e.hasMoreElements();) {
00057 for (Enumeration e2 = ((AssertionSet) e.nextElement()).getAssertionTable().elements(); e2.hasMoreElements();) {
00058 assertions.add((Assertion) e2.nextElement());
00059 }
00060 }
00061 for (Enumeration e = PredicateSet.getPredicateSetTable().elements(); e.hasMoreElements();) {
00062 for (Enumeration e2 = ((PredicateSet) e.nextElement()).getPredicateTable().elements(); e2.hasMoreElements();) {
00063 predicates.add((Predicate) e2.nextElement());
00064 }
00065 }
00066 }
00067
00068
00069
00070
00071
00072 public void addCompiledPredicate(Predicate p, Value v) {
00073 compiledPredicates.add(p);
00074 compiledTable.put(p, v);
00075 }
00076
00077
00078
00079
00080 public String getFilename() {
00081 return filename;
00082 }
00083
00084
00085
00086 public String getTextRepresentation() {
00087 StringWriter sw = new StringWriter();
00088 PrintWriter pw = new PrintWriter(sw);
00089
00090 pw.println("BSL Report");
00091 pw.println("==========");
00092 pw.println("");
00093 pw.println("");
00094 pw.println("");
00095
00096 pw.println("Assertions");
00097 pw.println("----------");
00098
00099 for (Iterator i = assertions.iterator(); i.hasNext();) {
00100 Assertion a = (Assertion) i.next();
00101 Vector exceptions = a.getExceptions();
00102 if (exceptions.size() > 0) {
00103 pw.println("* " + a.getName() + " didn't pass type checking");
00104 pw.println(" + constraint: " + a.getConstraint());
00105 pw.println(" + description: " + a.getDescription());
00106 pw.println(" + annotation: " + a.getAnnotation());
00107 pw.println(" + type checking message(s):");
00108 for (Iterator j = exceptions.iterator(); j.hasNext();) {
00109 pw.println(" - " + ((Exception) exceptions.iterator()).getMessage());
00110 }
00111 } else {
00112 pw.println("* " + a.getName() + " passed type checking");
00113 pw.println(" + constraint: " + a.getConstraint());
00114 pw.println(" + description: " + a.getDescription());
00115 pw.println(" + annotation: " + a.getAnnotation());
00116 }
00117 }
00118
00119 pw.println("");
00120 pw.println("");
00121
00122 pw.println("Predicates");
00123 pw.println("----------");
00124
00125 for (Iterator i = predicates.iterator(); i.hasNext();) {
00126 Predicate p = (Predicate) i.next();
00127 Vector exceptions = p.getExceptions();
00128 if (exceptions.size() > 0) {
00129 pw.println("* " + p.getName() + " didn't pass type checking");
00130 pw.println(" + static: " + p.isStatic());
00131 pw.println(" + use private field: " + p.isUsePrivate());
00132 pw.println(" + parameters: " + p.getParams());
00133 pw.println(" + parameter types: " + p.getParamTypes());
00134 pw.println(" + constraint: " + p.getConstraint());
00135 pw.println(" + description: " + p.getDescription());
00136 pw.println(" + annotation: " + p.getAnnotation());
00137 pw.println(" + type checking message(s):");
00138 for (Iterator j = exceptions.iterator(); j.hasNext();) {
00139 pw.println(" - " + ((Exception) j.next()).getMessage());
00140 }
00141 } else {
00142 pw.println("* " + p.getName() + " passed type checking");
00143 pw.println(" + static: " + p.isStatic());
00144 pw.println(" + use private field: " + p.isUsePrivate());
00145 pw.println(" + parameters: " + p.getParams());
00146 pw.println(" + parameter types: " + p.getParamTypes());
00147 pw.println(" + constraint: " + p.getConstraint());
00148 pw.println(" + description: " + p.getDescription());
00149 pw.println(" + annotation: " + p.getAnnotation());
00150 }
00151 }
00152
00153 pw.println("");
00154 pw.println("");
00155
00156 pw.println("Compiled Predicates");
00157 pw.println("-------------------");
00158
00159 for (Iterator i = compiledPredicates.iterator(); i.hasNext();) {
00160 Predicate p = (Predicate) i.next();
00161 Value v = (Value) compiledTable.get(p);
00162 pw.println("* " + p.getName() + " = " + v);
00163 }
00164
00165 pw.println("");
00166 pw.println("");
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 return sw.toString();
00185 }
00186 }