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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#ifndef CERC_TYPE_H
#define CERC_TYPE_H
#include <stdbool.h>
#include <stdint.h>
struct cer_int {
bool sign;
short bits;
};
struct cer_float {
bool is64;
};
struct cer_array {
struct type *member_type;
int length;
};
struct cer_slice {
struct type *member_type;
};
struct field {
const char *name;
struct type *type;
};
struct cer_struct {
struct field *fields;
};
struct variant {
const char *name;
uint64_t tag;
};
struct cer_enum {
struct cer_int tag_type;
struct variant variants[];
};
struct cer_union {
struct type *alts;
};
enum type_kind {
TYP_ARRAY,
TYP_BOOL,
TYP_ENUM,
TYP_FALLIBLE,
TYP_FLOAT,
TYP_INT,
TYP_OPTIONAL,
TYP_POINTER,
TYP_SLICE,
TYP_STRUCT,
TYP_UNION,
};
union type_desc {
struct cer_int i;
struct cer_float f;
struct cer_array array;
struct cer_slice slice;
struct cer_struct s;
struct cer_enum en;
struct cer_union un;
};
struct type {
enum type_kind kind;
union type_desc desc;
};
/**
* Builtin types
*/
extern const struct cer_int int8_b, uint8_b;
extern const struct cer_int int16_b, uint16_b;
extern const struct cer_int int32_b, uint32_b;
extern const struct cer_int int64_b, uint64_b;
extern const struct cer_int int_b, uint_b;
extern const struct cer_float float32_b, float64_b;
#endif
|