feat: rename core types to scc prefix for consistency

Updated type names from `core_*` to `scc_*` across lex_parser and stream modules to maintain naming consistency within the SCC codebase. This includes changes to function signatures and internal usage of types like `core_probe_stream_t`, `core_pos_t`, and `cstring_t` to their `scc_*` counterparts.
This commit is contained in:
zzy
2025-12-11 13:00:29 +08:00
parent 35c13ee30a
commit d88fa3b8d3
33 changed files with 741 additions and 745 deletions

View File

@@ -1,11 +1,11 @@
#include <hashmap.h>
#ifndef SMCC_INIT_HASHMAP_SIZE
#define SMCC_INIT_HASHMAP_SIZE (32)
#ifndef SCC_INIT_HASHMAP_SIZE
#define SCC_INIT_HASHMAP_SIZE (32)
#endif
void hashmap_init(hashmap_t *ht) {
vec_init(ht->entries);
scc_vec_init(ht->entries);
ht->count = 0;
ht->tombstone_count = 0;
Assert(ht->key_cmp != NULL && ht->hash_func != NULL);
@@ -31,7 +31,7 @@ static hashmap_entry_t *find_entry(hashmap_t *ht, const void *key, u32 hash) {
hashmap_entry_t *tombstone = NULL;
while (1) {
hashmap_entry_t *entry = &vec_at(ht->entries, index);
hashmap_entry_t *entry = &scc_vec_at(ht->entries, index);
if (entry->state == ENTRY_EMPTY) {
return tombstone ? tombstone : entry;
}
@@ -57,33 +57,33 @@ static void adjust_capacity(hashmap_t *ht, int new_cap) {
new_cap = next_power_of_two(new_cap);
Assert(new_cap >= ht->entries.cap);
VEC(hashmap_entry_t) old_entries;
SCC_VEC(hashmap_entry_t) old_entries;
old_entries.data = ht->entries.data;
old_entries.cap = ht->entries.cap;
// Not used size but for gdb python extention debug
ht->entries.size = new_cap;
ht->entries.cap = new_cap;
ht->entries.data = smcc_realloc(NULL, new_cap * sizeof(hashmap_entry_t));
smcc_memset(ht->entries.data, 0, new_cap * sizeof(hashmap_entry_t));
ht->entries.data = scc_realloc(NULL, new_cap * sizeof(hashmap_entry_t));
scc_memset(ht->entries.data, 0, new_cap * sizeof(hashmap_entry_t));
// rehash the all of the old data
for (usize i = 0; i < old_entries.cap; i++) {
hashmap_entry_t *entry = &vec_at(old_entries, i);
hashmap_entry_t *entry = &scc_vec_at(old_entries, i);
if (entry->state == ENTRY_ACTIVE) {
hashmap_entry_t *dest = find_entry(ht, entry->key, entry->hash);
*dest = *entry;
}
}
vec_free(old_entries);
scc_vec_free(old_entries);
ht->tombstone_count = 0;
}
void *hashmap_set(hashmap_t *ht, const void *key, void *value) {
if (ht->count + ht->tombstone_count >= ht->entries.cap * 0.75) {
int new_cap = ht->entries.cap < SMCC_INIT_HASHMAP_SIZE
? SMCC_INIT_HASHMAP_SIZE
int new_cap = ht->entries.cap < SCC_INIT_HASHMAP_SIZE
? SCC_INIT_HASHMAP_SIZE
: ht->entries.cap * 2;
adjust_capacity(ht, new_cap);
}
@@ -134,14 +134,14 @@ void *hashmap_del(hashmap_t *ht, const void *key) {
}
void hashmap_drop(hashmap_t *ht) {
vec_free(ht->entries);
scc_vec_free(ht->entries);
ht->count = 0;
ht->tombstone_count = 0;
}
void hashmap_foreach(hashmap_t *ht, hashmap_iter_fn iter_func, void *context) {
for (usize i = 0; i < ht->entries.cap; i++) {
hashmap_entry_t *entry = &vec_at(ht->entries, i);
hashmap_entry_t *entry = &scc_vec_at(ht->entries, i);
if (entry->state == ENTRY_ACTIVE) {
if (!iter_func(entry->key, entry->value, context)) {
break; // enable callback function terminal the iter