diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-04-25 00:17:56 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-04-25 00:18:51 -0600 |
commit | 765337c53286db39ffc3c64eede602afe3899647 (patch) | |
tree | 893b488f70b22c4d18cec6934ed479feb0943b54 /st/SymTableBottomUp.java | |
parent | d2017d232557b45792857b972ca8883df6e79506 (diff) |
Rewrote SymbolTable to add uniqueness to stored tokens
Diffstat (limited to 'st/SymTableBottomUp.java')
-rw-r--r-- | st/SymTableBottomUp.java | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/st/SymTableBottomUp.java b/st/SymTableBottomUp.java index b0772fc..72a4575 100644 --- a/st/SymTableBottomUp.java +++ b/st/SymTableBottomUp.java @@ -52,14 +52,12 @@ public class SymTableBottomUp<R> extends GJDepthFirst<R,SymbolTable> { n.f17.accept(this, symt); - String id = n.f1.f0.tokenImage; - ClassInstance instance = new ClassInstance(id); - MinimalLogger.info("Inserting " + id + " => " + instance.getType()); + TokenKey id = new TokenKey(n.f1.f0.tokenImage, 0); + ClassInstance instance = new ClassInstance(id.getName()); symt.put(id, instance); - id = "main"; - MethodInstance main = new MethodInstance(id, TypeEnum.ERROR); - MinimalLogger.info("Inserting " + id + " => " + main.getType()); + id = new TokenKey(n.f6.tokenImage, n.f6.beginLine); + MethodInstance main = new MethodInstance(id.getName(), TypeEnum.ERROR); symt.put(id, main); @@ -83,9 +81,8 @@ public class SymTableBottomUp<R> extends GJDepthFirst<R,SymbolTable> { n.f5.accept(this, symt); - String id = n.f1.f0.tokenImage; - ClassInstance instance = new ClassInstance(id); - MinimalLogger.info("Inserting " + id + " => " + instance.getType()); + TokenKey id = new TokenKey(n.f1.f0.tokenImage, 0); + ClassInstance instance = new ClassInstance(id.getName()); symt.put(id, instance); @@ -113,9 +110,8 @@ public class SymTableBottomUp<R> extends GJDepthFirst<R,SymbolTable> { n.f7.accept(this, symt); - String id = n.f1.f0.tokenImage; - ClassInstance instance = new ClassInstance(id); - MinimalLogger.info("Inserting " + id + " => " + instance.getType()); + TokenKey id = new TokenKey(n.f1.f0.tokenImage, 0); + ClassInstance instance = new ClassInstance(id.getName()); symt.put(id, instance); @@ -132,7 +128,7 @@ public class SymTableBottomUp<R> extends GJDepthFirst<R,SymbolTable> { n.f1.accept(this, symt); n.f2.accept(this, symt); - String id = n.f1.f0.tokenImage; + TokenKey id = new TokenKey(n.f1.f0.tokenImage, n.f1.f0.beginLine); TypeEnum rtrn = TypeEnum.ERROR; switch (n.f0.f0.which) { case 0: @@ -147,8 +143,7 @@ public class SymTableBottomUp<R> extends GJDepthFirst<R,SymbolTable> { MinimalLogger.severe("Unsupported case"); } - TypeInstance instance = new TypeInstance(id, rtrn); - MinimalLogger.info("Inserting " + id + " => " + instance.getType()); + TypeInstance instance = new TypeInstance(id.getName(), rtrn); symt.put(id, instance); @@ -186,7 +181,8 @@ public class SymTableBottomUp<R> extends GJDepthFirst<R,SymbolTable> { n.f12.accept(this, symt); - String id = n.f2.f0.tokenImage; + + TokenKey id = new TokenKey(n.f2.f0.tokenImage, n.f2.f0.beginLine); TypeEnum rtrn = TypeEnum.ERROR; switch (n.f1.f0.which) { case 0: @@ -201,8 +197,7 @@ public class SymTableBottomUp<R> extends GJDepthFirst<R,SymbolTable> { MinimalLogger.severe("Unsupported case"); } - MethodInstance instance = new MethodInstance(id, rtrn); - MinimalLogger.info("Inserting " + id + " => " + instance.getType()); + MethodInstance instance = new MethodInstance(id.getName(), rtrn); symt.put(id, instance); @@ -218,7 +213,7 @@ public class SymTableBottomUp<R> extends GJDepthFirst<R,SymbolTable> { n.f1.accept(this, symt); - String id = n.f1.f0.tokenImage; + TokenKey id = new TokenKey(n.f1.f0.tokenImage, n.f1.f0.beginLine); TypeEnum rtrn = TypeEnum.ERROR; switch (n.f0.f0.which) { case 0: @@ -233,8 +228,7 @@ public class SymTableBottomUp<R> extends GJDepthFirst<R,SymbolTable> { MinimalLogger.severe("Unsupported case"); } - TypeInstance instance = new TypeInstance(id, rtrn); - MinimalLogger.info("Inserting " + id + " => " + instance.getType()); + TypeInstance instance = new TypeInstance(id.getName(), rtrn); symt.put(id, instance); |