From 1cbc6acab2c1bd745649a639db023b0f6c87f821 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Tue, 23 Apr 2024 15:04:43 -0600 Subject: Cleanup BoilSimp -> BoilVisitor --- st/AbstractInstance.java | 2 +- st/SymbolTable.java | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'st') diff --git a/st/AbstractInstance.java b/st/AbstractInstance.java index 4e4287d..6db9d3c 100644 --- a/st/AbstractInstance.java +++ b/st/AbstractInstance.java @@ -18,7 +18,7 @@ public abstract class AbstractInstance { return this.name; } - @Override public boolean equals(AbstractInstance other) { + public boolean equals(AbstractInstance other) { return this.name == other.getName() && this.type == this.type; } diff --git a/st/SymbolTable.java b/st/SymbolTable.java index e3dd398..77b8a93 100644 --- a/st/SymbolTable.java +++ b/st/SymbolTable.java @@ -1,6 +1,7 @@ package st; import java.util.*; +import misc.*; /** * Class which provides methods for interacting with and managing @@ -103,23 +104,35 @@ public class SymbolTable { public TypeInstance getType(String id) { AbstractInstance symbol; - return ((symbol = this.symt.get(id)) != - null && symbol instanceof TypeInstance) ? + TypeInstance ret = ((symbol = this.symt.get(id)) != + null && symbol instanceof TypeInstance) ? (TypeInstance) symbol : null; + if (ret == null) + MinimalLogger.severe(String.format("getType returning null for missing alias %s!", + id)); + return ret; } public MethodInstance getMethod(String id) { AbstractInstance symbol; - return ((symbol = this.symt.get(id)) != - null && symbol instanceof MethodInstance) ? + MethodInstance ret = ((symbol = this.symt.get(id)) != + null && symbol instanceof MethodInstance) ? (MethodInstance) symbol : null; + if (ret == null) + MinimalLogger.severe(String.format("getMethod returning null for missing alias %s!", + id)); + return ret; } public ClassInstance getClass(String id) { AbstractInstance symbol; - return ((symbol = this.symt.get(id)) != - null && symbol instanceof ClassInstance) ? + ClassInstance ret = ((symbol = this.symt.get(id)) != + null && symbol instanceof ClassInstance) ? (ClassInstance) symbol : null; + if (ret == null) + MinimalLogger.severe(String.format("getClass returning null for missing alias %s!", + id)); + return ret; } public String getActive(TypeEnum type) { -- cgit v1.2.3