diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-03-16 22:06:32 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-03-16 22:06:32 -0600 |
commit | 6a24c69232901de51f50beab9c3d3b3760dee334 (patch) | |
tree | 70c71b9ec25d3f6085d71c83e2be3719fe638ae9 /minijava/TypeInstance.java | |
parent | 5b09fb3697f4b1cc1f2f3781f10e1334ada69c22 (diff) |
(Nonfunctional) Implemented many type-checking rules
Diffstat (limited to 'minijava/TypeInstance.java')
-rw-r--r-- | minijava/TypeInstance.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/minijava/TypeInstance.java b/minijava/TypeInstance.java new file mode 100644 index 0000000..13920e4 --- /dev/null +++ b/minijava/TypeInstance.java @@ -0,0 +1,29 @@ +package minijava; + +public class TypeInstance { + TypeEnum type; + + public TypeInstance(TypeEnum type) { + this.type = type; + } + + public boolean equal_type(TypeInstance other) { + /** + * Given a TypeInstance object other, + * returns true if other object + * is the same type as this one. + * + * We can say two types are equal, as + * long as they are not equal on a + * type error! + */ + + return this.type != TypeEnum.ERROR + this.type == other.type; + } + + public TypeEnum get_type() { + return this.type; + } + +} |