blob: d5f81217c00de6838f8feed69ed27646e976feb4 (
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
|
package heat;
import st.TypeEnum;
import st.ClassInstance;
/**
* A simple wrapper for TypeEnum,
* meant to provide all helper methods
* and structures for evaluating typing.
*/
class TypeBundle {
TypeEnum type;
ClassInstance instance;
protected TypeBundle(TypeEnum type, ClassInstance instance) {
this.type = type;
this.instance = instance;
}
@Override public String toString() {
return String.format("%s (%s)",
type,
instance);
}
@Override public boolean equals(Object other) {
/**
* We can say two types are equal, as
* long as they are not equal on a
* type error!
*/
return (other instanceof TypeBundle) &&
this.hasChecked() &&
((TypeBundle) other).type == this.type;
}
public boolean hasChecked() {
return type != TypeEnum.ERROR;
}
}
|