keep the current snapshot before making further changes.
[IRC.git] / Robust / src / Analysis / SSJava / Location.java
1 package Analysis.SSJava;
2
3 import IR.ClassDescriptor;
4
5 public class Location {
6
7   public static final int TOP = 1;
8   public static final int NORMAL = 2;
9   public static final int BOTTOM = 3;
10
11   int type;
12   ClassDescriptor cd;
13   String loc;
14
15   public Location(ClassDescriptor cd, String loc) {
16     this.cd = cd;
17     this.loc = loc;
18     this.type = NORMAL;
19   }
20
21   public Location(ClassDescriptor cd) {
22     this.cd = cd;
23   }
24
25   public void setType(int type) {
26     this.type = type;
27   }
28
29   public ClassDescriptor getClassDescriptor() {
30     return cd;
31   }
32
33   public String getLocIdentifier() {
34     return loc;
35   }
36
37   public int getType() {
38     return this.type;
39   }
40
41   public boolean equals(Object o) {
42     if (!(o instanceof Location)) {
43       return false;
44     }
45
46     Location loc = (Location) o;
47
48     if (loc.getClassDescriptor().equals(getClassDescriptor())) {
49       if (loc.getLocIdentifier() == null || getLocIdentifier() == null) {
50         if (loc.getType() == getType()) {
51           return true;
52         }
53       } else {
54         if (loc.getLocIdentifier().equals(getLocIdentifier())) {
55           return true;
56         }
57       }
58     }
59
60     return false;
61   }
62
63   public int hashCode() {
64
65     int hash = cd.hashCode();
66     if (loc != null) {
67       hash += loc.hashCode();
68     }
69     return hash;
70
71   }
72
73   public String toString() {
74     return "Loc[" + cd.getSymbol() + "." + loc + "]";
75   }
76
77 }