diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-26 17:01:49 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-26 17:01:49 -0600 |
commit | 7c6c79a437a4c1e7cf85964d005a3cdeb59809f1 (patch) | |
tree | 87318f07590b624d4408410e4b2693ad20dff166 /heat/TypeBundle.java | |
parent | ccd38b0746b0b5aeeefdd6e49f2c9d6cb66676f4 (diff) |
Added skeleton files in "heat" libary, successor to TypeCheckSimp
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; + } + +} |