Fix tabbing.... Please fix your editors so they do tabbing correctly!!! (Spaces...
[IRC.git] / Robust / src / Analysis / SSJava / Location.java
1 package Analysis.SSJava;
2
3 import IR.ClassDescriptor;
4 import IR.TypeExtension;
5
6 public class Location  implements TypeExtension {
7
8   public static final int TOP = 1;
9   public static final int NORMAL = 2;
10   public static final int BOTTOM = 3;
11   public static final int DELTA = 4;
12
13   int type;
14   ClassDescriptor cd;
15   String loc;
16
17   public Location(ClassDescriptor cd, String loc) {
18     this.cd = cd;
19     this.loc = loc;
20     this.type = NORMAL;
21   }
22
23   public Location(ClassDescriptor cd) {
24     this.cd = cd;
25   }
26
27   public void setType(int type) {
28     this.type = type;
29   }
30
31   public ClassDescriptor getClassDescriptor() {
32     return cd;
33   }
34
35   public String getLocIdentifier() {
36     return loc;
37   }
38
39   public int getType() {
40     return this.type;
41   }
42
43   public boolean equals(Object o) {
44     if (!(o instanceof Location)) {
45       return false;
46     }
47
48     Location loc = (Location) o;
49
50     if (loc.getClassDescriptor().equals(getClassDescriptor())) {
51       if (loc.getLocIdentifier() == null || getLocIdentifier() == null) {
52         if (loc.getType() == getType()) {
53           return true;
54         }
55       } else {
56         if (loc.getLocIdentifier().equals(getLocIdentifier())) {
57           return true;
58         }
59       }
60     }
61
62     return false;
63   }
64
65   public int hashCode() {
66
67     int hash = cd.hashCode();
68     if (loc != null) {
69       hash += loc.hashCode();
70     }
71     return hash;
72
73   }
74
75   public String toString() {
76     return "Loc[" + cd.getSymbol() + "." + loc + "]";
77   }
78
79   public static Location createTopLocation(ClassDescriptor cd) {
80     Location topLoc = new Location(cd);
81     topLoc.setType(TOP);
82     topLoc.loc = "_top_";
83     return topLoc;
84   }
85
86   public static Location createBottomLocation(ClassDescriptor cd) {
87     Location bottomLoc = new Location(cd);
88     bottomLoc.setType(BOTTOM);
89     bottomLoc.loc = "_bottom_";
90     return bottomLoc;
91   }
92
93   public boolean isTop() {
94     return type==TOP;
95   }
96
97 }