work on type inference some more
[ccc.git] / type.h
diff --git a/type.h b/type.h
new file mode 100644 (file)
index 0000000..0bbb2e0
--- /dev/null
+++ b/type.h
@@ -0,0 +1,36 @@
+#ifndef TYPE_H
+#define TYPE_H
+
+#include <stdio.h>
+
+enum basictype {btbool, btchar, btint, btvoid};
+struct type {
+       enum {tarrow,tbasic,tlist,ttuple,tvar} type;
+       union {
+               struct {
+                       struct type *l;
+                       struct type *r;
+               } tarrow;
+               enum basictype tbasic;
+               struct type *tlist;
+               struct {
+                       struct type *l;
+                       struct type *r;
+               } ttuple;
+               char *tvar;
+       } data;
+};
+
+struct type *type_arrow(struct type *l, struct type *r);
+struct type *type_basic(enum basictype type);
+struct type *type_list(struct type *type);
+struct type *type_tuple(struct type *l, struct type *r);
+struct type *type_var(char *ident);
+
+void type_print(struct type *type, FILE *out);
+void type_free(struct type *type);
+
+struct type *type_dup(struct type *t);
+void type_ftv(struct type *r, int *nftv, char ***ftv);
+
+#endif