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/MethodInstance.java | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'st/MethodInstance.java') diff --git a/st/MethodInstance.java b/st/MethodInstance.java index 8b4ed57..d6c22b6 100644 --- a/st/MethodInstance.java +++ b/st/MethodInstance.java @@ -3,9 +3,10 @@ package st; import java.util.ArrayList; public class MethodInstance extends AbstractInstance { - private ArrayList args; // the list of arguments - private ArrayList lvars; // the list of local variables + private ArrayList args; // the list of arguments + private ArrayList lvars; // the list of local variables private TypeEnum rtrn; // the returned type + private ClassInstance scope; // the surrounding class public MethodInstance(String name, TypeEnum rtrn) { super(name, TypeEnum.method); @@ -14,18 +15,21 @@ public class MethodInstance extends AbstractInstance { this.rtrn = rtrn; } - public String toString() { - return name + ":T[" + type + "]R[" + - this.rtrn + "]P[" + this.args.toString() + - "]V[" + this.lvars.toString() + "]"; + public void addArgument(TypeInstance arg) { + this.args.add(arg); + this.lvars.add(arg); } - public void set_args(ArrayList args) { - this.args = args; + public void addLocal(TypeInstance lvar) { + this.lvars.add(lvar); } - public void set_locals(ArrayList lvars) { - this.lvars = lvars; + public AbstractInstance getScope() { + /** + * Returns the scope of the method, or + * `null' if unset. + */ + return this.scope; } } -- cgit v1.2.3