summaryrefslogtreecommitdiff
path: root/st/ClassInstance.java
blob: a5f1493e3cc67a52570d2652fb9e476b8a95158f (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
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(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() {
        /**
         * Returns the parent class, or
         * `null' if unset.
         */
        return this.ext;
    }

    public ArrayList<TypeInstance> getAttributes() {
        return this.attrs;
    }

    public ArrayList<MethodInstance> getMethod() {
        return this.mtds;
    }

}