blob: f926fa66c11a2cf53ed437dd83d25d4d5c5fecd4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package st;
import java.util.ArrayList;
public class ClassInstance extends AbstractInstance {
private ClassInstance ext; // the name of the extended class (null if none)
private ArrayList<TypeInstance> attrs; // the list of class-fields
private ArrayList<MethodInstance> mtds; // the list of methods
public ClassInstance(String name) {
super(name, TypeEnum.classname);
this.attrs = new ArrayList<>();
this.mtds = new ArrayList<>();
}
public ClassInstance getExtend() {
/**
* Returns the parent class, or
* `null' if unset.
*/
return this.ext;
}
public ArrayList<TypeInstance> getAttributes() {
return this.attrs;
}
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;
}
}
|