From 7c6c79a437a4c1e7cf85964d005a3cdeb59809f1 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Fri, 26 Apr 2024 17:01:49 -0600 Subject: Added skeleton files in "heat" libary, successor to TypeCheckSimp --- heat/TypeBundle.java | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 heat/TypeBundle.java (limited to 'heat/TypeBundle.java') 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; + } + +} -- cgit v1.2.3