summaryrefslogtreecommitdiff
path: root/st/AbstractInstance.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-06 20:00:31 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-06 20:00:31 -0600
commit8e660afb356c1f6d0b9cd115426cf21129e5d304 (patch)
treea8c885c83b138762ca51af640355048bc305b437 /st/AbstractInstance.java
parentb03859dce5991169b07d1d5040c8faf7ba82e5b5 (diff)
Untested SymbolTable full implementation
Diffstat (limited to 'st/AbstractInstance.java')
-rw-r--r--st/AbstractInstance.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/st/AbstractInstance.java b/st/AbstractInstance.java
index 65b0db7..7acc3e5 100644
--- a/st/AbstractInstance.java
+++ b/st/AbstractInstance.java
@@ -1,9 +1,10 @@
package st;
public abstract class AbstractInstance {
- protected String name; // the literal name of the declaration
- protected TypeEnum type; // the type of the declaration
- protected int size; // the size in memory
+ protected String name; // the literal name of the declaration
+ protected TypeEnum type; // the type of the declaration
+ protected int size; // the size in memory
+ protected AbstractInstance scope; // the surrounding method or class
public AbstractInstance(String name, TypeEnum type) {
this.type = type;
@@ -22,6 +23,13 @@ public abstract class AbstractInstance {
return this.name.hashCode();
}
+ public void setScope(AbstractInstance cls) {
+ if (this.scope != null)
+ throw new RuntimeException("setScope: Attempted to set scope twice!");
+
+ this.scope = cls;
+ }
+
public String getName() {
return this.name;
}
@@ -34,4 +42,12 @@ public abstract class AbstractInstance {
return this.size;
}
+ public AbstractInstance getScope() {
+ /**
+ * Returns the scope of the method, or
+ * `null' if unset.
+ */
+ return this.scope;
+ }
+
}