summaryrefslogtreecommitdiff
path: root/st/TypeInstance.java
blob: e00c1f959f1605b2b7c20868ec4fa58aef6d65b5 (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
package st;

public class TypeInstance extends AbstractInstance {

    private AbstractInstance scope;

    public TypeInstance(String name, TypeEnum type) {
        super(name, type);
        this.scope = null;
    }

    public boolean sameType(TypeInstance other) {
        /**
         * Given a TypeInstance object other,
         * returns true if other object
         * is the same type as this one.
         *
         * We can say two types are equal, as
         * long as they are not equal on a
         * type error!
         */

        return this.type != TypeEnum.ERROR &&
            this.type == other.getType();
    }

    public boolean hasChecked() {
        return type != TypeEnum.ERROR;
    }

    public AbstractInstance getScope() {
        /**
         * Returns the scope of the variable, or
         * `null' if unset.
         */
        return this.scope;
    }

}