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/SymTableVis.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'st/SymTableVis.java') diff --git a/st/SymTableVis.java b/st/SymTableVis.java index 399ea09..36233b3 100644 --- a/st/SymTableVis.java +++ b/st/SymTableVis.java @@ -37,7 +37,7 @@ public class SymTableVis extends GJDepthFirst> { public R visit(MainClass n, ArrayList argu) { ArrayList attr_list = new ArrayList(); - ArrayList mtd_list = new ArrayList(); + ArrayList mtd_list = new ArrayList(); n.f0.accept(this, argu); n.f1.accept(this, argu); @@ -64,7 +64,7 @@ public class SymTableVis extends GJDepthFirst> { String id = n.f1.f0.tokenImage; ClassInstance type = new ClassInstance(id); - type.set_attrs(attr_list); + type.set_attrs(attr_list); type.set_mtds(mtd_list); PrintFilter.print("Inserting " + id + " => " + type, true); symt.put(id, type); @@ -141,8 +141,10 @@ public class SymTableVis extends GJDepthFirst> { String ext = n.f3.f0.tokenImage; ClassInstance type = new ClassInstance(id, ext); - type.set_attrs(attr_list); - type.set_mtds(mtd_list); + ClassInstance parent = (ClassInstance) symt.get(ext); + System.out.println("Parent addrs: " + parent.get_attrs()); + // type.set_attrs(attr_list.addAll(parent.get_attrs())); + // type.set_mtds(mtd_list.addAll(parent.get_mtds())); PrintFilter.print("Inserting " + id + " => " + type, true); symt.put(id, type); @@ -238,14 +240,14 @@ public class SymTableVis extends GJDepthFirst> { } MethodInstance type = new MethodInstance(id, rtrn); - // add children to current class + // add children to current class type.set_args(argu_list); type.set_locals(var_list); PrintFilter.print("Inserting " + type, true); symt.put(id, type); - // add method to parent class - argu.add(id); + // add method to parent class + argu.add(id); return null; } @@ -273,7 +275,7 @@ public class SymTableVis extends GJDepthFirst> { TypeInstance type = new TypeInstance(id, rtrn); - // add type to parent class + // add type to parent class argu.add(id); n.f0.accept(this, argu); -- cgit v1.2.3