summaryrefslogtreecommitdiff
path: root/st/TypeInstance.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/TypeInstance.java
parentbd44adf2b180fcc1198d612a8ae0d2a28468088d (diff)
Rewrote Symbol Table to be more context aware and avoid collisions
Diffstat (limited to 'st/TypeInstance.java')
-rw-r--r--st/TypeInstance.java41
1 files changed, 40 insertions, 1 deletions
diff --git a/st/TypeInstance.java b/st/TypeInstance.java
index 88b73f3..e43c5b3 100644
--- a/st/TypeInstance.java
+++ b/st/TypeInstance.java
@@ -2,8 +2,23 @@ package st;
public class TypeInstance extends AbstractInstance {
- public TypeInstance(String name, TypeEnum type) {
+ protected ClassInstance par_cls; // the surrounding class
+ protected MethodInstance par_mtd; // the surrounding method
+ protected ClassInstance cls; // the class instance
+
+
+ public TypeInstance(String name, TypeEnum type, MethodInstance par_mtd, ClassInstance par_cls) {
super(name, type);
+ this.par_cls = par_cls;
+ this.par_mtd = par_mtd;
+ }
+
+ @Override public boolean equals(Object other) {
+ TypeInstance o;
+ return (other instanceof TypeInstance &&
+ ((o = (TypeInstance) other).getName() == this.getName() &&
+ o.getParentClass() == this.getParentClass() &&
+ o.getParentMethod() == this.getParentMethod()));
}
public int getSize() {
@@ -30,4 +45,28 @@ public class TypeInstance extends AbstractInstance {
return type != TypeEnum.ERROR;
}
+ public void addClassInstance(ClassInstance cls) {
+ this.cls = cls;
+ }
+
+ public ClassInstance getClassInstance() {
+ return this.cls;
+ }
+
+ public void addParentClass(ClassInstance par_cls) {
+ this.par_cls = par_cls;
+ }
+
+ public ClassInstance getParentClass() {
+ return this.par_cls;
+ }
+
+ public void addParentMethod(MethodInstance par_mtd) {
+ this.par_mtd = par_mtd;
+ }
+
+ public MethodInstance getParentMethod() {
+ return this.par_mtd;
+ }
+
}