diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-12 02:19:23 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-12 02:19:23 +0300 |
| commit | e1f17535a043b55ce34de4d7583928d8c94bb71a (patch) | |
| tree | 256299aeb970730e56a48e6ad72ac82e848a14d1 /include | |
| parent | 7294673a9889f968eef86930d4e09f47070439fc (diff) | |
| download | ek-e1f17535a043b55ce34de4d7583928d8c94bb71a.tar.gz ek-e1f17535a043b55ce34de4d7583928d8c94bb71a.zip | |
start work on struct handling
Diffstat (limited to 'include')
| -rw-r--r-- | include/ek/ast.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/include/ek/ast.h b/include/ek/ast.h index de195c6..9770e91 100644 --- a/include/ek/ast.h +++ b/include/ek/ast.h @@ -220,6 +220,7 @@ struct type { /* next */ struct type *n; + long long size; struct src_loc loc; struct scope *scope; }; @@ -261,6 +262,10 @@ struct type *tgen_type(enum type_kind kind, char *id, struct src_loc loc); +size_t align3k(size_t o); +size_t type_size(struct type *t); +size_t type_offsetof(struct type *t, char *m); + #define tgen_primitive(kind, id, def, loc) \ tgen_type(kind, NULL, NULL, def, NULL, id, loc) @@ -364,17 +369,17 @@ static inline bool is_primitive(struct type *t) return false; } -#define gen_str_type1(k, s, t, a, loc) gen_ast(k, a, NULL, NULL, NULL, t, s, 0, \ +#define gen_str_type1(k, s, t, a, loc) gen_ast(k, a, NULL, NULL, NULL, t, s, -1, \ loc) #define gen_str_type(k, s, t, loc) gen_str_type1(k, s, t, NULL, loc) -#define gen_type(k, a, type, loc) gen_ast(k, a, NULL, NULL, NULL, type, NULL, 0, \ +#define gen_type(k, a, type, loc) gen_ast(k, a, NULL, NULL, NULL, type, NULL, -1, \ loc) -#define gen_str2(k, s, a, b, loc) gen_ast(k, a, b, NULL, NULL, NULL, s, 0, loc) +#define gen_str2(k, s, a, b, loc) gen_ast(k, a, b, NULL, NULL, NULL, s, -1, loc) #define gen_str1(k, s, a, loc) gen_str2(k, s, a, NULL, loc) -#define gen_str(k, s, loc) gen_ast(k, NULL, NULL, NULL, NULL, NULL, s, 0, loc) +#define gen_str(k, s, loc) gen_ast(k, NULL, NULL, NULL, NULL, NULL, s, -1, loc) -#define gen4(k, a, b, c, d, loc) gen_ast(k, a, b, c, d, NULL, NULL, 0, loc) +#define gen4(k, a, b, c, d, loc) gen_ast(k, a, b, c, d, NULL, NULL, -1, loc) #define gen3(k, a, b, c, loc) gen4(k, a, b, c, NULL, loc) #define gen2(k, a, b, loc) gen3(k, a, b, NULL, loc) #define gen1(k, a, loc) gen2(k, a, NULL, loc) |
