summaryrefslogtreecommitdiff
path: root/src/ast/types/FunctionType.java
blob: 1a04bb647d9694b41f1514aa1d622a48659f599f (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
48
49
50
package ast.types;

/**
 * A Function type.
 */
public class FunctionType extends Type {

    private final int paramNumber;
    private final Type returnType;
    private final String label;
    private int localvarNum;

    public FunctionType(int paramNumber, Type returnType, String label) {
        this.paramNumber = paramNumber;
        this.returnType = returnType;
        this.label = label;
        this.localvarNum = 0;
    }

    public void addLocalVar() {
        localvarNum++;
    }

    public int getLocalvarNum() {
        return localvarNum;
    }

    // Return the number of the parameters
    public int getParamNumber() {
        return paramNumber;
    }

    public Type getReturnType() {
        return returnType;
    }

    public String getLabel() {
        return label;
    }

    @Override
    public String toPrint(String prefix) {
        return prefix + "Function\n";
    }

    @Override
    public String toString() {
        return "NP: " + paramNumber + " RT: " + returnType + " L: " + label;
    }
}