work on type inference some more
[ccc.git] / type.h
1 #ifndef TYPE_H
2 #define TYPE_H
3
4 #include <stdio.h>
5
6 enum basictype {btbool, btchar, btint, btvoid};
7 struct type {
8 enum {tarrow,tbasic,tlist,ttuple,tvar} type;
9 union {
10 struct {
11 struct type *l;
12 struct type *r;
13 } tarrow;
14 enum basictype tbasic;
15 struct type *tlist;
16 struct {
17 struct type *l;
18 struct type *r;
19 } ttuple;
20 char *tvar;
21 } data;
22 };
23
24 struct type *type_arrow(struct type *l, struct type *r);
25 struct type *type_basic(enum basictype type);
26 struct type *type_list(struct type *type);
27 struct type *type_tuple(struct type *l, struct type *r);
28 struct type *type_var(char *ident);
29
30 void type_print(struct type *type, FILE *out);
31 void type_free(struct type *type);
32
33 struct type *type_dup(struct type *t);
34 void type_ftv(struct type *r, int *nftv, char ***ftv);
35
36 #endif