blob: 941c83f0a727d04e2ee5590e5362444abbd9772f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
package st;
/**
* This class is a data structure used to distinguish tokens in
* a given program. Tokens are considered unique if their "beginLine"
* and name are different.
*/
public class TokenKey {
private String name;
private AbstractInstance cls; // null for classes
private AbstractInstance mtd; // null for classes, methods
public TokenKey(String name, AbstractInstance cls, AbstractInstance mtd) {
this.name = name;
this.cls = cls;
this.mtd = mtd;
}
@Override public String toString() {
return String.format("%s (%s,%s)",
this.name,
this.mtd,
this.cls);
}
@Override public boolean equals(Object other) {
boolean ret = false;
TokenKey o;
if (other instanceof TokenKey &&
(o = (TokenKey) other).name.equals(this.name) &&
((o.cls == null && this.cls == null) ||
(o.cls != null && o.cls.equals(this.cls))) &&
((o.mtd == null && this.mtd == null) ||
(o.mtd != null && o.mtd.equals(this.mtd))))
ret = true;
return ret;
}
@Override public int hashCode() {
return this.name.hashCode();
}
public String getName() {
return this.name;
}
}
|