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 AbstractInstance scope; // the surrounding method or class public AbstractInstance(String name, TypeEnum type) { this.type = type; this.name = name; } public String toString() { return this.name; } public boolean equals(AbstractInstance other) { return this.name == other.getName() && this.type == this.type; } public int hashCode() { 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; } public TypeEnum getType() { return this.type; } public int getSize() { return this.size; } public AbstractInstance getScope() { /** * Returns the scope of the method, or * `null' if unset. */ return this.scope; } }