From b8d9ad1f6636f46a832b0f949ce7525ae08f53bd Mon Sep 17 00:00:00 2001 From: lemon Date: Sat, 6 Aug 2022 14:10:19 +0200 Subject: basic method calls & many bugfix --- bootstrap/all.h | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'bootstrap/all.h') diff --git a/bootstrap/all.h b/bootstrap/all.h index 15f932c..ff20c25 100644 --- a/bootstrap/all.h +++ b/bootstrap/all.h @@ -177,6 +177,7 @@ struct type { const char *name; const struct type *ty; }) flds; + slice_t(struct decl) decls; bool fwd; int id; } agg; @@ -263,6 +264,7 @@ enum exprtype { Ezeroini, Eini, Eget, + Emcall, }; struct blockstmt { @@ -316,6 +318,10 @@ struct expr { struct expr *lhs; const char *fld; } get; + struct { + struct fn *met; + slice_t(struct expr) args; + } mcall; }; }; @@ -434,15 +440,27 @@ bswap64(u64 x) { #define vec_slice_cpy(slice, v) \ ((slice)->d = vec_compact(v), \ (slice)->n = (v)->length) + +#define container_of(x, T, fld) \ + (T *)((char *)(x) - offsetof(T, fld)) + /// ///////////////////////////////// /** util.c **/ -u32 jkhash(u32 hash, const u8 *data, size_t length); -#define jkhashv(h, v) jkhash(h, (void *)&(v), sizeof((v))) +#define FNV1A_INI 0x84222325u +u32 fnv1a(u32 hash, const void *data, size_t length); +static inline u32 +fnv1ai(u32 hash, int i) { + return fnv1a(hash, &i, sizeof i); +} +static inline u32 +fnv1aI(u32 hash, i64 i) { + return fnv1a(hash, &i, sizeof i); +} static inline u32 -jkhashu32(u32 h, u32 x) { - return jkhashv(h, x); +fnv1az(u32 hash, size_t i) { + return fnv1a(hash, &i, sizeof i); } int addfilepath(const char *); const char *fileid2path(int); @@ -485,7 +503,7 @@ const struct type *typeof2(const struct type *a, const struct type *b); /** env.c **/ struct decl *envfind(const struct env *, const char *name); -bool envput(struct env *, const struct decl *decl); +struct decl *envput(struct env *, const struct decl *decl); struct env *mkenv(const struct env *parent); /** dump.c **/ -- cgit v1.2.3