diff options
Diffstat (limited to 'st/SymTableVis.java')
-rw-r--r-- | st/SymTableVis.java | 74 |
1 files changed, 47 insertions, 27 deletions
diff --git a/st/SymTableVis.java b/st/SymTableVis.java index fb62979..2731a26 100644 --- a/st/SymTableVis.java +++ b/st/SymTableVis.java @@ -36,13 +36,7 @@ public class SymTableVis extends GJDepthFirst<String,ArrayList<TypeInstance>> { */ public String visit(MainClass n, ArrayList<TypeInstance> argu) { - PrintFilter.print("Processing main", true); - - String id = n.f1.f0.tokenImage; - - ClassInstance type = new ClassInstance(id); - PrintFilter.print("Inserting " + id + " => " + type, true); - symt.put(id, type); + ArrayList<TypeInstance> attr_list = new ArrayList<TypeInstance>(); n.f0.accept(this, argu); n.f1.accept(this, argu); @@ -58,10 +52,21 @@ public class SymTableVis extends GJDepthFirst<String,ArrayList<TypeInstance>> { n.f11.accept(this, argu); n.f12.accept(this, argu); n.f13.accept(this, argu); - n.f14.accept(this, argu); + n.f14.accept(this, attr_list); n.f15.accept(this, argu); n.f16.accept(this, argu); n.f17.accept(this, argu); + + + PrintFilter.print("Processing main", true); + + String id = n.f1.f0.tokenImage; + + ClassInstance type = new ClassInstance(id); + type.set_attrs(attr_list); + PrintFilter.print("Inserting " + id + " => " + type, true); + symt.put(id, type); + return null; } @@ -76,22 +81,29 @@ public class SymTableVis extends GJDepthFirst<String,ArrayList<TypeInstance>> { */ public String visit(ClassDeclaration n, ArrayList<TypeInstance> argu) { + ArrayList<TypeInstance> attr_list = new ArrayList<TypeInstance>(); + // ArrayList<TypeInstance> mtd_list = new ArrayList<TypeInstance>(); + + n.f0.accept(this, argu); + n.f1.accept(this, argu); + n.f2.accept(this, argu); + n.f3.accept(this, attr_list); + n.f4.accept(this, argu); + n.f5.accept(this, argu); + + PrintFilter.print("Processing class", true); String id = n.f1.f0.tokenImage; ClassInstance type = new ClassInstance(id); + type.set_attrs(attr_list); + // type.set_mtds(mtd_list); PrintFilter.print("Inserting " + id + " => " + type, true); // Safe? symt.put(id, type); - n.f0.accept(this, argu); - n.f1.accept(this, argu); - n.f2.accept(this, argu); - n.f3.accept(this, argu); - n.f4.accept(this, argu); - n.f5.accept(this, argu); return null; } @@ -107,25 +119,32 @@ public class SymTableVis extends GJDepthFirst<String,ArrayList<TypeInstance>> { * f7 -> "}" */ public String visit(ClassExtendsDeclaration n, ArrayList<TypeInstance> argu) { - PrintFilter.print("Processing class", true); - String id = n.f1.f0.tokenImage; - String ext = n.f3.f0.tokenImage; - - ClassInstance type = new ClassInstance(id, ext); - PrintFilter.print("Inserting " + id + " => " + type + - "(" + ext + ")", true); - - symt.put(id, type); + ArrayList<TypeInstance> attr_list = new ArrayList<TypeInstance>(); + // ArrayList<TypeInstance> mtd_list = new ArrayList<TypeInstance>(); n.f0.accept(this, argu); n.f1.accept(this, argu); n.f2.accept(this, argu); n.f3.accept(this, argu); n.f4.accept(this, argu); - n.f5.accept(this, argu); + n.f5.accept(this, attr_list); n.f6.accept(this, argu); n.f7.accept(this, argu); + + + PrintFilter.print("Processing extension class", true); + + String id = n.f1.f0.tokenImage; + String ext = n.f3.f0.tokenImage; + + ClassInstance type = new ClassInstance(id, ext); + type.set_attrs(attr_list); + // type.set_mtds(mtd_list); + PrintFilter.print("Inserting " + id + " => " + type, true); + + symt.put(id, type); + return null; } @@ -230,7 +249,7 @@ public class SymTableVis extends GJDepthFirst<String,ArrayList<TypeInstance>> { * f1 -> Identifier() */ public String visit(FormalParameter n, ArrayList<TypeInstance> argu) { - PrintFilter.print("Processing parameter", true); + // PrintFilter.print("Processing parameter", true); String id = n.f1.f0.tokenImage; TypeEnum rtrn = TypeEnum.ERROR; @@ -242,11 +261,12 @@ public class SymTableVis extends GJDepthFirst<String,ArrayList<TypeInstance>> { case 2: rtrn = TypeEnum.integer; break; default: - PrintFilter.print("Unsupported case", true); + // PrintFilter.print("Unsupported case", true); + ; } TypeInstance type = new TypeInstance(id, rtrn); - PrintFilter.print("Adding Argument " + type, true); + // PrintFilter.print("Adding Argument " + type, true); argu.add(type); n.f0.accept(this, argu); |