changes: now Inference engine works fine with the EyeTracking benchmark.
[IRC.git] / Robust / src / Analysis / SSJava / Location.java
index 06dfdb996f920c37fbac1237aa37243de69faef8..6137379c93fb91bbd1f6e53f195a9454a1fc8c1f 100644 (file)
@@ -12,23 +12,50 @@ public class Location implements TypeExtension {
   int type;
   Descriptor d;
   String loc;
+  Descriptor locDesc;
+
+  public Location(Descriptor enclosingDesc, Descriptor locDesc) {
+    this.d = enclosingDesc;
+    this.locDesc = locDesc;
+    this.loc = locDesc.getSymbol();
+  }
 
   public Location(Descriptor d, String loc) {
     this.d = d;
     this.loc = loc;
-    this.type = NORMAL;
+
+    if (loc.equals(SSJavaAnalysis.TOP)) {
+      type = TOP;
+    } else if (loc.equals(SSJavaAnalysis.BOTTOM)) {
+      type = BOTTOM;
+    } else {
+      type = NORMAL;
+    }
+
   }
 
   public Location(Descriptor d, int type) {
     this.d = d;
     this.type = type;
     if (type == TOP) {
-      loc = SSJavaLattice.TOP;
+      loc = SSJavaAnalysis.TOP;
     } else if (type == BOTTOM) {
-      loc = SSJavaLattice.BOTTOM;
+      loc = SSJavaAnalysis.BOTTOM;
     }
   }
 
+  public void setLocIdentifier(String s) {
+    loc = s;
+  }
+
+  public void setLocDescriptor(Descriptor d) {
+    locDesc = d;
+  }
+
+  public Descriptor getLocDescriptor() {
+    return locDesc;
+  }
+
   public void setType(int type) {
     this.type = type;
   }
@@ -58,7 +85,10 @@ public class Location implements TypeExtension {
           return true;
         }
       } else {
-        if (loc.getLocIdentifier().equals(getLocIdentifier())) {
+        if (loc.getLocDescriptor() != null && getLocDescriptor() != null
+            && loc.getLocDescriptor().equals(getLocDescriptor())) {
+          return true;
+        } else if (loc.getLocIdentifier().equals(getLocIdentifier())) {
           return true;
         }
       }
@@ -73,6 +103,9 @@ public class Location implements TypeExtension {
     if (loc != null) {
       hash += loc.hashCode();
     }
+    if (locDesc != null) {
+      hash += locDesc.hashCode();
+    }
     return hash;
 
   }
@@ -81,6 +114,10 @@ public class Location implements TypeExtension {
     return "Loc[" + d.getSymbol() + "." + loc + "]";
   }
 
+  public String getSymbol() {
+    return d.getSymbol() + "." + loc;
+  }
+
   public static Location createTopLocation(Descriptor d) {
     Location topLoc = new Location(d, TOP);
     return topLoc;