aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/all.h
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2022-08-06 14:10:19 +0200
committerlemon <lsof@mailbox.org>2022-08-06 14:10:29 +0200
commitb8d9ad1f6636f46a832b0f949ce7525ae08f53bd (patch)
tree037c7e0a86835b2e284df786e3ba2680b7677cc4 /bootstrap/all.h
parent1dd19e56fb81d1334bb21e4aa097f9593576feb7 (diff)
basic method calls & many bugfix
Diffstat (limited to 'bootstrap/all.h')
-rw-r--r--bootstrap/all.h28
1 files changed, 23 insertions, 5 deletions
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 **/