summaryrefslogtreecommitdiff
path: root/st/ClassInstance.java
diff options
context:
space:
mode:
authorbd-912 <bdunahu@colostate.edu>2024-04-06 21:10:55 -0600
committerbd-912 <bdunahu@colostate.edu>2024-04-06 21:10:55 -0600
commitbb8d3aff71f8f89bed2ab94f382675a2312b1893 (patch)
treeaea71a22ad5a893083feebb661a50a413f4f0049 /st/ClassInstance.java
parent8e660afb356c1f6d0b9cd115426cf21129e5d304 (diff)
Add test file, fix minor issues in SymbolTable
Diffstat (limited to 'st/ClassInstance.java')
-rw-r--r--st/ClassInstance.java32
1 files changed, 17 insertions, 15 deletions
diff --git a/st/ClassInstance.java b/st/ClassInstance.java
index a5f1493..f926fa6 100644
--- a/st/ClassInstance.java
+++ b/st/ClassInstance.java
@@ -13,20 +13,7 @@ public class ClassInstance extends AbstractInstance {
this.mtds = new ArrayList<>();
}
- public ClassInstance(String name, ClassInstance ext) {
- super(name, TypeEnum.classname);
- this.ext = ext;
- }
-
- public void addAttribute(TypeInstance attr) {
- this.attrs.add(attr);
- }
-
- public void addMethod(MethodInstance mtd) {
- this.mtds.add(mtd);
- }
-
- public AbstractInstance getExtend() {
+ public ClassInstance getExtend() {
/**
* Returns the parent class, or
* `null' if unset.
@@ -38,8 +25,23 @@ public class ClassInstance extends AbstractInstance {
return this.attrs;
}
- public ArrayList<MethodInstance> getMethod() {
+ public ArrayList<MethodInstance> getMethods() {
return this.mtds;
}
+ protected void addAttribute(TypeInstance attr) {
+ this.attrs.add(attr);
+ }
+
+ protected void addMethod(MethodInstance mtd) {
+ this.mtds.add(mtd);
+ }
+
+ protected void setExtend(ClassInstance ext) {
+ if (this.ext != null)
+ throw new RuntimeException("setExtend: Attempted to set extended class twice!");
+
+ this.ext = ext;
+ }
+
}