diff options
Diffstat (limited to 'bootstrap/all.h')
| -rw-r--r-- | bootstrap/all.h | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/bootstrap/all.h b/bootstrap/all.h index cb221da..bbe23b3 100644 --- a/bootstrap/all.h +++ b/bootstrap/all.h @@ -136,12 +136,16 @@ enum typetype { TYslice, TYfn, TYenum, + TYstruct, + TYunion, + TYeunion, }; struct type { enum typetype t; size_t size, align; bool konst; + int _id; union { bool int_signed; struct { @@ -156,12 +160,22 @@ struct type { struct { const struct type *intty; const char *name; - slice_t(struct enumfield { + slice_t(struct enumval { const char *name; i64 i; }) vals; int id; } enu; + struct { + const char *name; + slice_t(struct aggfield { + size_t off; + const char *name; + const struct type *ty; + }) flds; + bool fwd; + int id; + } agg; }; // for cgen.c hack (mutated later, not hashed or involved in equality) const char *_cname; @@ -242,6 +256,8 @@ enum exprtype { Eblock, Eas, Eenumval, + Ezeroini, + Eini, }; struct blockstmt { @@ -288,9 +304,20 @@ struct expr { i64 i; const char *vname; } enu; + struct { + slice_t(struct iniarg) args; + } ini; }; }; +struct iniarg { + union { + size_t idx; + const char *fld; + }; + struct expr ex; +}; + enum stmttype { Sblock, Sexpr, @@ -376,6 +403,7 @@ static const struct targ { for (T __old = (var), *__dummy = ((var) = (new), NULL); \ !__dummy; \ __dummy++, (var) = __old) +#define ALIGNUP(x,a) (((x) + ((a) - 1)) & -(a)) static inline u32 bswap32(u32 x) { @@ -393,13 +421,16 @@ bswap64(u64 x) { #define vec_slice_cpy(slice, v) \ ((slice)->d = vec_compact(v), \ (slice)->n = (v)->length) - -#define jkhashv(h, v) jkhash(h, (void *)&(v), sizeof((v))) - +/// ///////////////////////////////// /** util.c **/ u32 jkhash(u32 hash, const u8 *data, size_t length); +#define jkhashv(h, v) jkhash(h, (void *)&(v), sizeof((v))) +static inline u32 +jkhashu32(u32 h, u32 x) { + return jkhashv(h, x); +} int addfilepath(const char *); const char *fileid2path(int); void *xmalloc(size_t); @@ -426,6 +457,7 @@ extern const struct type *ty_c_ullong; void inittypes(void); const struct type *interntype(struct type); +void uninterntype(const struct type *); bool typeeql(const struct type *lhs, const struct type *rhs); bool completetype(const struct type *); void putprimtypes(struct env *); |