diff options
Diffstat (limited to 'heat/TypeBundle.java')
-rw-r--r-- | heat/TypeBundle.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/heat/TypeBundle.java b/heat/TypeBundle.java new file mode 100644 index 0000000..d5f8121 --- /dev/null +++ b/heat/TypeBundle.java @@ -0,0 +1,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; + } + +} |