diff options
author | bd-912 <bdunahu@colostate.edu> | 2024-03-27 22:53:08 -0600 |
---|---|---|
committer | bd-912 <bdunahu@colostate.edu> | 2024-03-27 22:53:08 -0600 |
commit | b01fe1e8e5541d6c11f905d7fbb949d747f29230 (patch) | |
tree | d348b6b471fa2ebb2cece61daaf672c8b27b4299 /st/ClassInstance.java | |
parent | 8131ddc22af5d39114a55349d71bcdc467599187 (diff) |
SymbolTable to separate library, Class/Method Instances
Diffstat (limited to 'st/ClassInstance.java')
-rw-r--r-- | st/ClassInstance.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/st/ClassInstance.java b/st/ClassInstance.java new file mode 100644 index 0000000..c1b07af --- /dev/null +++ b/st/ClassInstance.java @@ -0,0 +1,37 @@ +package st; + +import java.util.ArrayList; + +public class ClassInstance extends AbstractInstance { + private ArrayList<TypeInstance> attrs; // the list of class-fields + private ArrayList<MethodInstance> mtds; // the list of methods + private String ext; // the name of the extended class (null if none) + + public ClassInstance(String name) { + super(name, TypeEnum.classname); + this.ext = null; + } + + public ClassInstance(String name, String ext) { + super(name, TypeEnum.classname); + this.ext = ext; + } + + public String toString() { + return this.name + ":" + this.type + "(" + + this.ext + ")"; + } + + public void add_attribute(TypeInstance attr) { + this.attrs.add(attr); + } + + public void add_attribute(MethodInstance mtd) { + this.mtds.add(mtd); + } + + public String get_extend() { + return this.ext; + } + +} |