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.getLocIdentifier().equals(getLocIdentifier())) {
97 public int hashCode() {
99 int hash = d.hashCode();
101 hash += loc.hashCode();
107 public String toString() {
108 return "Loc[" + d.getSymbol() + "." + loc + "]";
111 public String getSymbol() {
112 return d.getSymbol() + "." + loc;
115 public static Location createTopLocation(Descriptor d) {
116 Location topLoc = new Location(d, TOP);
120 public static Location createBottomLocation(Descriptor d) {
121 Location bottomLoc = new Location(d, BOTTOM);
125 public boolean isTop() {