aboutsummaryrefslogtreecommitdiffhomepage
path: root/c/c.h
diff options
context:
space:
mode:
author lemon<lsof@mailbox.org>2025-12-30 10:34:11 +0100
committer lemon<lsof@mailbox.org>2025-12-30 10:37:13 +0100
commite77538515802276d76dfcb28c9b8dc140d5afe02 (patch)
tree48ece54a12bc4a447db386214b29b3e9890925e7 /c/c.h
parent2b6b6b79beba618ab46c353a59a1c90539340021 (diff)
c: SYM expr should store decl ref as an index, not pointer
Because envdecls (now declsbuf) can be resized and invalidate those pointers. I missed this because the default initialization size of that buffer (and the fact that it would mostly only manifest with function-local expressions) made it not really come up in practice. Silly
Diffstat (limited to 'c/c.h')
-rw-r--r--c/c.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/c/c.h b/c/c.h
index a31a1fd..da30616 100644
--- a/c/c.h
+++ b/c/c.h
@@ -45,7 +45,8 @@ struct expr {
};
uint n;
} s; /* ESTRLIT */
- struct decl *sym; /* ESYM */
+ int decl; /* ESYM, index into declsbuf */
+ internstr implicitsym; /* ESYM (undeclared) */
struct init *init; /* EINIT */
};
};
@@ -101,9 +102,10 @@ struct decl {
};
};
+extern struct envdecls {vec_of(struct decl);} declsbuf;
extern union type cvalistty;
struct function;
-struct decl *envadddecl(struct env *env, const struct decl *d);
+int 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);