diff options
| author | 2025-11-14 18:49:04 +0100 | |
|---|---|---|
| committer | 2025-11-14 19:04:51 +0100 | |
| commit | a287fe5aeb6b681ab405c0297841dce64ab4b946 (patch) | |
| tree | 5ae81f3b60cc910cd356059a77e89dd50ca83b42 /c/c.h | |
| parent | fc91a4ce139fd0236ad9e8c4fe1e7dad42f0b178 (diff) | |
preeliminary va_list support
Diffstat (limited to 'c/c.h')
| -rw-r--r-- | c/c.h | 38 |
1 files changed, 34 insertions, 4 deletions
@@ -5,7 +5,7 @@ /*************/ enum exprkind { - EXXX, ENUMLIT, ESTRLIT, ESYM, EINIT, EGETF, ECALL, ECOND, + EXXX, ENUMLIT, ESTRLIT, ESYM, EVAARG, EINIT, EGETF, ECALL, ECOND, /* unary */ EPLUS, ENEG, ECOMPL, ELOGNOT, EDEREF, EADDROF, ECAST, EPREINC, EPOSTINC, EPREDEC, EPOSTDEC, @@ -59,6 +59,18 @@ struct init { } *vals, **tail; }; +/** C compiler state **/ +struct comp { + struct lexer *lx; + struct env *env; + struct arena *fnarena, *exarena; + struct span fnblkspan; + uint loopdepth, switchdepth; + struct block *breakto, *loopcont; + struct switchstmt *switchstmt; + struct label *labels; +}; + enum storageclass { SCNONE, SCTYPEDEF = 1<<0, @@ -72,17 +84,35 @@ enum storageclass { struct decl { union type ty; uchar scls; - uchar qual : 2; - uchar isenum : 1; - uchar isdef : 1; + uchar qual : 2, + isenum : 1, + isdef : 1, + isbuiltin : 1; struct span span; const char *name; union { struct { ushort align; int id; }; vlong value; + const struct builtin *builtin; }; }; +extern union type cvalistty; +struct function; +struct decl *envadddecl(struct env *env, const struct decl *d); +bool assigncheck(union type t, const struct expr *src); +union ref expraddr(struct function *, const struct expr *); +union ref compileexpr(struct function *, const struct expr *, bool discard); + +/** builtin.c **/ +struct builtin { + bool (*sema)(struct comp *, struct expr *); + union ref (*comp)(struct function *, struct expr *, bool discard); +}; +void putbuiltins(struct env *); +union ref builtin_va_arg_comp(struct function *, const struct expr *, bool discard); + +/** eval.c **/ enum evalmode { EVNONE, EVINTCONST, |