aboutsummaryrefslogtreecommitdiff
path: root/type.h
blob: 6e6e0f690e8e04ae6ae882eca2499f79d79ea2f9 (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
#pragma once

#include <stdio.h>


enum type_tag {
	T_INT,
	T_VOID,
	T_PTR
};

struct type {
	enum type_tag tag;
	union {
		struct {  // T_INT
			int size;
		};
		struct {};  // T_VOID
		struct {  // T_PTR
			struct type *target;
		};
	};
};


void type_cache_cleanup(void);

struct type* type_int(int size);
struct type* type_void(void);
struct type* type_ptr(struct type *type);

void type_print(struct type *type, FILE *f);