From b03859dce5991169b07d1d5040c8faf7ba82e5b5 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Sat, 6 Apr 2024 19:02:21 -0600 Subject: Rewrite SymbolTable again P1 --- st/TypeInstance.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'st/TypeInstance.java') diff --git a/st/TypeInstance.java b/st/TypeInstance.java index 13947ae..e00c1f9 100644 --- a/st/TypeInstance.java +++ b/st/TypeInstance.java @@ -2,15 +2,14 @@ package st; public class TypeInstance extends AbstractInstance { + private AbstractInstance scope; + public TypeInstance(String name, TypeEnum type) { super(name, type); + this.scope = null; } - public String toString() { - return this.name + ":" + this.type; - } - - public boolean same_type(TypeInstance other) { + public boolean sameType(TypeInstance other) { /** * Given a TypeInstance object other, * returns true if other object @@ -22,11 +21,19 @@ public class TypeInstance extends AbstractInstance { */ return this.type != TypeEnum.ERROR && - this.type == other.get_type(); + this.type == other.getType(); } - public boolean has_checked() { + public boolean hasChecked() { return type != TypeEnum.ERROR; } + public AbstractInstance getScope() { + /** + * Returns the scope of the variable, or + * `null' if unset. + */ + return this.scope; + } + } -- cgit v1.2.3