From c28a1cc9d206bdde41a621b018c01980b3c8a617 Mon Sep 17 00:00:00 2001 From: bd-912 Date: Thu, 25 Apr 2024 12:58:10 -0600 Subject: Rewrote Symbol Table to be more context aware and avoid collisions --- st/MethodInstance.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'st/MethodInstance.java') diff --git a/st/MethodInstance.java b/st/MethodInstance.java index 6cf6ccc..c2f978b 100644 --- a/st/MethodInstance.java +++ b/st/MethodInstance.java @@ -5,15 +5,24 @@ import java.util.ArrayList; public class MethodInstance extends AbstractInstance { private ArrayList args; // the list of arguments private ArrayList lvars; // the list of local variables + protected ClassInstance par_cls; // the surrounding class private TypeEnum rtrn; // the returned type - public MethodInstance(String name, TypeEnum rtrn) { + public MethodInstance(String name, TypeEnum rtrn, ClassInstance par_cls) { super(name, TypeEnum.method); this.lvars = new ArrayList<>(); this.args = new ArrayList<>(); + this.par_cls = par_cls; this.rtrn = rtrn; } + public boolean equals(Object other) { + MethodInstance o; + return (other instanceof MethodInstance && + ((o = (MethodInstance) other).getName() == this.getName() && + o.getParentClass() == this.getParentClass())); + } + public ArrayList getArguments() { return this.args; } @@ -35,4 +44,12 @@ public class MethodInstance extends AbstractInstance { this.lvars.add(lvar); } + public void addParentClass(ClassInstance par_cls) { + this.par_cls = par_cls; + } + + public ClassInstance getParentClass() { + return this.par_cls; + } + } -- cgit v1.2.3