diff options
Diffstat (limited to 'st/AbstractInstance.java')
-rw-r--r-- | st/AbstractInstance.java | 22 |
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; + } + } |