1 package Analysis.SSJava;
4 import IR.TypeExtension;
6 public class Location implements TypeExtension {
8 public static final int TOP = 1;
9 public static final int NORMAL = 2;
10 public static final int BOTTOM = 3;
17 public Location(Descriptor enclosingDesc, Descriptor locDesc) {
18 this.d = enclosingDesc;
19 this.locDesc = locDesc;
20 this.loc = locDesc.getSymbol();
23 public Location(Descriptor d, String loc) {
27 if (loc.equals(SSJavaAnalysis.TOP)) {
29 } else if (loc.equals(SSJavaAnalysis.BOTTOM)) {
37 public Location(Descriptor d, int type) {
41 loc = SSJavaAnalysis.TOP;
42 } else if (type == BOTTOM) {
43 loc = SSJavaAnalysis.BOTTOM;
47 public void setLocIdentifier(String s) {
51 public void setLocDescriptor(Descriptor d) {
55 public Descriptor getLocDescriptor() {
59 public void setType(int type) {
63 public Descriptor getDescriptor() {
67 public String getLocIdentifier() {
71 public int getType() {
75 public boolean equals(Object o) {
76 if (!(o instanceof Location)) {
80 Location loc = (Location) o;
82 if (loc.getDescriptor().equals(getDescriptor())) {
83 if (loc.getLocIdentifier() == null || getLocIdentifier() == null) {
84 if (loc.getType() == getType()) {
88 if (loc.getLocDescriptor() != null && getLocDescriptor() != null
89 && loc.getLocDescriptor().equals(getLocDescriptor())) {
91 } else if (loc.getLocIdentifier().equals(getLocIdentifier())) {
100 public int hashCode() {
102 int hash = d.hashCode();
104 hash += loc.hashCode();
106 if (locDesc != null) {
107 hash += locDesc.hashCode();
113 public String toString() {
114 return "Loc[" + d.getSymbol() + "." + loc + "]";
117 public String getSymbol() {
118 return d.getSymbol() + "." + loc;
121 public static Location createTopLocation(Descriptor d) {
122 Location topLoc = new Location(d, TOP);
126 public static Location createBottomLocation(Descriptor d) {
127 Location bottomLoc = new Location(d, BOTTOM);
131 public boolean isTop() {