changes on ssjava.
[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   public static final int DELTA = 4;
11
12   int type;
13   ClassDescriptor cd;
14   String loc;
15
16   public Location(ClassDescriptor cd, String loc) {
17     this.cd = cd;
18     this.loc = loc;
19     this.type = NORMAL;
20   }
21
22   public Location(ClassDescriptor cd) {
23     this.cd = cd;
24   }
25
26   public void setType(int type) {
27     this.type = type;
28   }
29
30   public ClassDescriptor getClassDescriptor() {
31     return cd;
32   }
33
34   public String getLocIdentifier() {
35     return loc;
36   }
37
38   public int getType() {
39     return this.type;
40   }
41
42   public boolean equals(Object o) {
43     if (!(o instanceof Location)) {
44       return false;
45     }
46
47     Location loc = (Location) o;
48
49     if (loc.getClassDescriptor().equals(getClassDescriptor())) {
50       if (loc.getLocIdentifier() == null || getLocIdentifier() == null) {
51         if (loc.getType() == getType()) {
52           return true;
53         }
54       } else {
55         if (loc.getLocIdentifier().equals(getLocIdentifier())) {
56           return true;
57         }
58       }
59     }
60
61     return false;
62   }
63
64   public int hashCode() {
65
66     int hash = cd.hashCode();
67     if (loc != null) {
68       hash += loc.hashCode();
69     }
70     return hash;
71
72   }
73
74   public String toString() {
75     return "Loc[" + cd.getSymbol() + "." + loc + "]";
76   }
77
78   public static Location createTopLocation(ClassDescriptor cd) {
79     Location topLoc = new Location(cd);
80     topLoc.setType(TOP);
81     topLoc.loc = "_top_";
82     return topLoc;
83   }
84
85   public static Location createBottomLocation(ClassDescriptor cd) {
86     Location bottomLoc = new Location(cd);
87     bottomLoc.setType(BOTTOM);
88     bottomLoc.loc = "_bottom_";
89     return bottomLoc;
90   }
91
92 }