changes.
[IRC.git] / Robust / src / Analysis / SSJava / SSJavaAnalysis.java
index adf303d533a74f549615468aa7e2591430ad0ced..fb9d4d5c3e54729424f8dd9903d55dc8812d427e 100644 (file)
@@ -110,6 +110,8 @@ public class SSJavaAnalysis {
 
   private LinkedList<MethodDescriptor> sortedDescriptors;
 
+  private Map<Location, Set<Descriptor>> mapSharedLocToDescSet;
+
   public SSJavaAnalysis(State state, TypeUtil tu, BuildFlat bf, CallGraph callgraph) {
     this.state = state;
     this.tu = tu;
@@ -129,15 +131,16 @@ public class SSJavaAnalysis {
     this.mapDescriptorToSetDependents = new Hashtable<Descriptor, Set<MethodDescriptor>>();
     this.sortedDescriptors = new LinkedList<MethodDescriptor>();
     this.md2pcLoc = new HashMap<MethodDescriptor, CompositeLocation>();
+    this.mapSharedLocToDescSet = new HashMap<Location, Set<Descriptor>>();
   }
 
   public void doCheck() {
     doMethodAnnotationCheck();
 
     if (state.SSJAVA && !state.SSJAVAINFER) {
+      init();
       computeLinearTypeCheckMethodSet();
       doLinearTypeCheck();
-      init();
     }
 
     if (state.SSJAVADEBUG) {
@@ -152,6 +155,14 @@ public class SSJavaAnalysis {
       doDefinitelyWrittenCheck();
       doLoopCheck();
     }
+
+    for (Iterator iterator = annotationRequireSet.iterator(); iterator.hasNext();) {
+      MethodDescriptor md = (MethodDescriptor) iterator.next();
+      MethodLattice<String> locOrder = getMethodLattice(md);
+      writeLatticeDotFile(md.getClassDesc(), md, getMethodLattice(md));
+      // System.out.println("~~~\t" + md.getClassDesc() + "_" + md + "\t"
+      // + locOrder.getKeySet().size());
+    }
   }
 
   public void init() {
@@ -166,8 +177,19 @@ public class SSJavaAnalysis {
     return (LinkedList<MethodDescriptor>) sortedDescriptors.clone();
   }
 
+  public void addSharedDesc(Location loc, Descriptor fd) {
+    if (!mapSharedLocToDescSet.containsKey(loc)) {
+      mapSharedLocToDescSet.put(loc, new HashSet<Descriptor>());
+    }
+    mapSharedLocToDescSet.get(loc).add(fd);
+  }
+
+  public Set<Descriptor> getSharedDescSet(Location loc) {
+    return mapSharedLocToDescSet.get(loc);
+  }
+
   private void inference() {
-    LocationInference inferEngine = new LocationInference(this, state);
+    LocationInference inferEngine = new LocationInference(this, state, tu);
     inferEngine.inference();
   }
 
@@ -245,6 +267,8 @@ public class SSJavaAnalysis {
       }
     }
 
+    linearTypeCheckMethodSet.addAll(sortedDescriptors);
+
   }
 
   private void doLinearTypeCheck() {
@@ -300,6 +324,7 @@ public class SSJavaAnalysis {
           if (state.SSJAVADEBUG) {
             // generate lattice dot file
             writeLatticeDotFile(cd, null, locOrder);
+            System.out.println("~~~\t" + cd + "\t" + locOrder.getKeySet().size());
           }
 
         } else if (marker.equals(METHODDEFAULT)) {
@@ -307,6 +332,7 @@ public class SSJavaAnalysis {
               new MethodLattice<String>(SSJavaAnalysis.TOP, SSJavaAnalysis.BOTTOM);
           cd2methodDefault.put(cd, locOrder);
           parseMethodDefaultLatticeDefinition(cd, an.getValue(), locOrder);
+          // writeLatticeDotFile(cd, null, locOrder, "METHOD_DEFAULT");
         }
       }
 
@@ -324,7 +350,9 @@ public class SSJavaAnalysis {
                 MethodLattice<String> locOrder =
                     new MethodLattice<String>(SSJavaAnalysis.TOP, SSJavaAnalysis.BOTTOM);
                 md2lattice.put(md, locOrder);
+                System.out.println("parsing method lattice=" + md);
                 parseMethodDefaultLatticeDefinition(cd, an.getValue(), locOrder);
+                writeLatticeDotFile(cd, md, locOrder, "");
               } else if (an.getMarker().equals(TERMINATE)) {
                 // developer explicitly wants to skip loop termination analysis
                 String value = an.getValue();