summaryrefslogtreecommitdiff
path: root/boil/library/TypeFactory.java
blob: 8dd910e9ebee9780143aae437db11ee3e00a374e (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
package boil.library;

import java.util.HashMap;
import st.TypeInstance;

public class TypeFactory {

    private int type_num;
    private HashMap<TypeInstance,String> map;

    public void reset() {
        this.type_num = 0;
        this.map = new HashMap<>();
    }

    public String addNewAlias(TypeInstance t) {
        String alias = String.format("t.%d", this.type_num++);
        this.map.put(t, alias);
        return alias;
    }

    public String retrieveAlias(TypeInstance t) {
        return this.map.get(t);
    }
}