summaryrefslogtreecommitdiff
path: root/st/TokenKey.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-25 12:58:10 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-25 12:58:10 -0600
commitc28a1cc9d206bdde41a621b018c01980b3c8a617 (patch)
tree90e9de370313682558172c8cebac9389b48c0855 /st/TokenKey.java
parentbd44adf2b180fcc1198d612a8ae0d2a28468088d (diff)
Rewrote Symbol Table to be more context aware and avoid collisions
Diffstat (limited to 'st/TokenKey.java')
-rw-r--r--st/TokenKey.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/st/TokenKey.java b/st/TokenKey.java
index 2319917..54086c5 100644
--- a/st/TokenKey.java
+++ b/st/TokenKey.java
@@ -8,18 +8,20 @@ package st;
public class TokenKey {
private String name;
- private int beginLine;
+ private AbstractInstance cls; // null for classes
+ private AbstractInstance mtd; // null for classes, methods
- public TokenKey(String name, int beginLine) {
- // classes CANNOT collide, so CALLEES ARE EXPECTED TO USE ZERO!
+ public TokenKey(String name, AbstractInstance cls, AbstractInstance mtd) {
this.name = name;
- this.beginLine = beginLine;
+ this.cls = cls;
+ this.mtd = mtd;
}
@Override public String toString() {
- return String.format("%s (%d)",
+ return String.format("%s (%s,%s)",
this.name,
- this.beginLine);
+ this.mtd,
+ this.cls);
}
@@ -28,7 +30,8 @@ public class TokenKey {
TokenKey o;
if (other instanceof TokenKey &&
(o = (TokenKey) other).name == this.name &&
- o.beginLine == this.beginLine) {
+ o.cls == this.cls &&
+ o.mtd == this.mtd) {
ret = true;
}
return ret;