-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsema.h
More file actions
76 lines (68 loc) · 1.16 KB
/
sema.h
File metadata and controls
76 lines (68 loc) · 1.16 KB
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
#ifndef SEMA_H
#define SEMA_H
#include <stdbool.h>
#include "parser.h"
#include "stb_ds.h"
#include "utils.h"
typedef enum {
TYPE_VOID,
TYPE_BOOL,
TYPE_PTR,
TYPE_SLICE,
TYPE_FLOAT,
TYPE_FLOAT_CONST,
TYPE_INTEGER,
TYPE_INTEGER_CONST,
TYPE_UINTEGER,
TYPE_STRUCT,
TYPE_UNION,
TYPE_ENUM, /* TODO */
TYPE_GENERIC, /* TODO */
} type_tag;
typedef struct _type {
type_tag tag;
usize size;
usize alignment;
char *name;
union {
u8 integer;
u8 flt; // float
struct {
bool is_const;
bool is_volatile;
struct _type *child;
} ptr;
struct {
usize len;
bool is_const;
bool is_volatile;
struct _type *child;
} slice;
struct {
char *name;
usize name_len;
member *members;
struct { char *key; struct _type *value; } *member_types;
} structure;
struct {
char *name;
usize name_len;
variant *variants;
} enm; /* TODO */
} data;
} type;
typedef struct {
char *name;
type *type;
type **parameters;
} prototype;
typedef struct _scope {
struct _scope *parent;
struct { char *key; type *value; } *defs;
} scope;
typedef struct {
arena *allocator;
ast_node *ast;
} sema;
sema *sema_init(parser *p, arena *a);
#endif