summaryrefslogtreecommitdiff
path: root/st/SymTableVis.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-06 19:02:21 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-06 19:02:21 -0600
commitb03859dce5991169b07d1d5040c8faf7ba82e5b5 (patch)
tree5a1217d441c9323976aef6e45018c9c2522930a6 /st/SymTableVis.java
parent0ae01301d572b2e69585c4d1cb753ed7fc89dfe3 (diff)
Rewrite SymbolTable again P1
Diffstat (limited to 'st/SymTableVis.java')
-rw-r--r--st/SymTableVis.java18
1 files changed, 10 insertions, 8 deletions
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<R> extends GJDepthFirst<R,ArrayList<String>> {
public R visit(MainClass n, ArrayList<String> argu) {
ArrayList<String> attr_list = new ArrayList<String>();
- ArrayList<String> mtd_list = new ArrayList<String>();
+ ArrayList<String> mtd_list = new ArrayList<String>();
n.f0.accept(this, argu);
n.f1.accept(this, argu);
@@ -64,7 +64,7 @@ public class SymTableVis<R> extends GJDepthFirst<R,ArrayList<String>> {
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<R> extends GJDepthFirst<R,ArrayList<String>> {
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<R> extends GJDepthFirst<R,ArrayList<String>> {
}
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<R> extends GJDepthFirst<R,ArrayList<String>> {
TypeInstance type = new TypeInstance(id, rtrn);
- // add type to parent class
+ // add type to parent class
argu.add(id);
n.f0.accept(this, argu);