aboutsummaryrefslogtreecommitdiff
path: root/src/3p
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-03-10 02:37:19 +0000
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-06 16:41:13 +0100
commit244fea664121acf12871ab5858a5fe95a2606b52 (patch)
treee42b1990ef97adc0f0ab48b9be7e11de7fee0558 /src/3p
parentd86b7b41453c69b3854baa7cdc05a79a3cdfe092 (diff)
downloadsst-244fea664121acf12871ab5858a5fe95a2606b52.tar.gz
sst-244fea664121acf12871ab5858a5fe95a2606b52.zip
Rewrite and redesign codegen and feature system
Also switch to somewhat proper C23 flags while we're at it. This is a huge change. It took me forever, in between being really busy. Sorry about that. But the good news is I'm now free to start integrating the various patches that have accumulated since last release. Well, at least in between still being really busy. Gotta manage expectations. The main benefit of introducing GAMESPECIFIC() is that features that don't apply to a particular game no longer show up *at all*, and less time is wasted on init. It also enables a cool optimisation wherein unnecessary REQUIRE_GAMEDATA() checks can elided at compile time whenever the gamedata is known up-front to always exist in supported games. The DEF_FEAT_CVAR macro family meanwhile makes it easier to manage the lifecycle of cvars/ccmds, with less manual registering, unhiding and such. Originally I was going to try and just hack these features into the existing codegen abomination, but it just got too terrible. This rewrite should make it easier to continue tweaking codegen behaviour in future. It also has slightly better error messages.
Diffstat (limited to 'src/3p')
-rw-r--r--src/3p/chibicc/chibicc.h3
-rw-r--r--src/3p/chibicc/hashmap.c7
2 files changed, 5 insertions, 5 deletions
diff --git a/src/3p/chibicc/chibicc.h b/src/3p/chibicc/chibicc.h
index 2a80ecf..f3f87ab 100644
--- a/src/3p/chibicc/chibicc.h
+++ b/src/3p/chibicc/chibicc.h
@@ -117,9 +117,6 @@ static inline char *format(const char *fmt, ...) {
return ret;
}
-#define unreachable() \
- error("internal error at %s:%d", __FILE__, __LINE__)
-
//
// type.c
//
diff --git a/src/3p/chibicc/hashmap.c b/src/3p/chibicc/hashmap.c
index 47110c6..2090274 100644
--- a/src/3p/chibicc/hashmap.c
+++ b/src/3p/chibicc/hashmap.c
@@ -2,6 +2,9 @@
#include "chibicc.h"
+// mike: moved from chibicc.h and also renamed, to avoid conflicts with langext.h
+#define chibi_unreachable() error("internal error at %s:%d", __FILE__, __LINE__)
+
// Initial hash bucket size
#define INIT_SIZE 16
@@ -70,7 +73,7 @@ static HashEntry *get_entry(HashMap *map, char *key, int keylen) {
if (ent->key == NULL)
return NULL;
}
- unreachable();
+ chibi_unreachable();
}
static HashEntry *get_or_insert_entry(HashMap *map, char *key, int keylen) {
@@ -102,7 +105,7 @@ static HashEntry *get_or_insert_entry(HashMap *map, char *key, int keylen) {
return ent;
}
}
- unreachable();
+ chibi_unreachable();
}
void *hashmap_get(HashMap *map, char *key) {