-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.h
57 lines (40 loc) · 984 Bytes
/
types.h
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
51
52
53
54
55
56
57
#ifndef TYPES_H
#define TYPES_H
#include "symbol.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum
{
NIL, UNKNOWN, BOOL, INT, DOUBLE, STRING, CHAR,
FN, LAMBDA, ARRAY, TUPLE, DATATYPE, TYPEVAR
} typ_t;
typedef struct type_t
{
typ_t typ;
int arity;
struct type_t ** param;
struct type_t * ret;
struct sym_t ** slot;
struct sym_t * sym;
} type_t;
extern type_t * t_nil;
extern type_t * t_int;
extern type_t * t_bool;
extern type_t * t_double;
extern type_t * t_string;
extern type_t * t_char;
void type_init(void);
type_t * new_type(typ_t typ);
int type_equal(type_t * t1, type_t * t2);
type_t * fn_type(type_t * ret, int num, type_t ** param);
type_t * tuple_type(int num, type_t ** param);
type_t * array_type(type_t * param);
type_t * data_type(int num, type_t ** param, sym_t * sym, sym_t ** slots);
type_t * fn_to_lambda_type(type_t * type);
type_t * new_typevar(void);
void print_type(type_t * t);
#ifdef __cplusplus
}
#endif
#endif