From b01fe1e8e5541d6c11f905d7fbb949d747f29230 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Wed, 27 Mar 2024 22:53:08 -0600 Subject: SymbolTable to separate library, Class/Method Instances --- st/TypeInstance.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 st/TypeInstance.java (limited to 'st/TypeInstance.java') diff --git a/st/TypeInstance.java b/st/TypeInstance.java new file mode 100644 index 0000000..13947ae --- /dev/null +++ b/st/TypeInstance.java @@ -0,0 +1,32 @@ +package st; + +public class TypeInstance extends AbstractInstance { + + public TypeInstance(String name, TypeEnum type) { + super(name, type); + } + + public String toString() { + return this.name + ":" + this.type; + } + + public boolean same_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.get_type(); + } + + public boolean has_checked() { + return type != TypeEnum.ERROR; + } + +} -- cgit v1.2.3