summaryrefslogtreecommitdiff
path: root/heat/TypeBundle.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-26 17:01:49 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-26 17:01:49 -0600
commit7c6c79a437a4c1e7cf85964d005a3cdeb59809f1 (patch)
tree87318f07590b624d4408410e4b2693ad20dff166 /heat/TypeBundle.java
parentccd38b0746b0b5aeeefdd6e49f2c9d6cb66676f4 (diff)
Added skeleton files in "heat" libary, successor to TypeCheckSimp
Diffstat (limited to 'heat/TypeBundle.java')
-rw-r--r--heat/TypeBundle.java41
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;
+ }
+
+}