feat: add SCF format library and rename components to SCC prefix

- Introduce new SCF (SCC Format) library with header, implementation, and test files
- SCF is a minimal executable/linkable format focused on internal linking with external symbol import/export abstraction
- Rename lexer and lex_parser packages from 'smcc_' to 'scc_' prefix for consistency
- Update hashmap implementation to use 'scc_' prefix for types and structures
- Add build configuration for new format library with dependencies on libcore and libutils
This commit is contained in:
zzy
2025-12-11 17:29:12 +08:00
parent d88fa3b8d3
commit 3aaf3a3991
13 changed files with 1048 additions and 56 deletions

View File

@@ -1,13 +1,13 @@
#include "strpool.h"
void init_strpool(strpool_t *pool) {
void scc_strpool_init(scc_strpool_t *pool) {
pool->ht.hash_func = (u32 (*)(const void *))scc_strhash32;
pool->ht.key_cmp = (int (*)(const void *, const void *))scc_strcmp;
hashmap_init(&pool->ht);
scc_hashtable_init(&pool->ht);
}
const char *strpool_intern(strpool_t *pool, const char *str) {
void *existing = hashmap_get(&pool->ht, str);
const char *scc_strpool_intern(scc_strpool_t *pool, const char *str) {
void *existing = scc_hashtable_get(&pool->ht, str);
if (existing) {
return existing;
}
@@ -20,8 +20,13 @@ const char *strpool_intern(strpool_t *pool, const char *str) {
}
scc_memcpy(new_str, str, len);
hashmap_set(&pool->ht, new_str, new_str);
scc_hashtable_set(&pool->ht, new_str, new_str);
return new_str;
}
void strpool_destroy(strpool_t *pool) { hashmap_drop(&pool->ht); }
void scc_strpool_drop(scc_strpool_t *pool) { scc_hashtable_drop(&pool->ht); }
void scc_strpool_foreach(scc_strpool_t *pool, scc_strpool_iter_fn iter_func,
void *context) {
scc_hashmap_foreach(&pool->ht, (scc_hashtable_iter_fn)iter_func, context);
}