refactor(hashtable): 简化哈希表初始化接口并优化文件打开模式
- 将哈希表初始化从两步设置改为一步完成,直接传递哈希函数和比较函数 - 重构scc_hashtable_init函数签名,接受函数指针参数 - 更新内部字段名从key_cmp为cmp_func以保持一致性 - 添加类型定义scc_hashtable_hash_func_t和scc_hashtable_equal_func_t - 修改PAL层文件操作接口,使用枚举模式替代固定只读模式 - 更新IR上下文、预处理器宏表等组件使用新的初始化方式 - 移除AST头文件中未使用的语义分析回调类型定义 - 修复预处理器中的空指针访问问题
This commit is contained in:
@@ -143,9 +143,7 @@ static int hash_cmp(const void *key1, const void *key2) {
|
||||
|
||||
void scc_pproc_marco_table_init(scc_pproc_macro_table_t *macros) {
|
||||
Assert(macros != null);
|
||||
macros->table.hash_func = hash_func;
|
||||
macros->table.key_cmp = hash_cmp;
|
||||
scc_hashtable_init(¯os->table);
|
||||
scc_hashtable_init(¯os->table, hash_func, hash_cmp);
|
||||
}
|
||||
|
||||
static int macro_free(const void *key, void *value, void *context) {
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
#include <scc_pproc.h>
|
||||
|
||||
static int pproc_next_one_file(scc_pproc_t *pp, scc_lexer_tok_t *out) {
|
||||
scc_lexer_tok_ring_t *stream = pp->cur_ring;
|
||||
scc_lexer_tok_ring_t *stream = null;
|
||||
scc_lexer_tok_t tok = {0};
|
||||
int ok = 0;
|
||||
CONTINUE:
|
||||
stream = pp->cur_ring;
|
||||
if (pp->expanded_ring.cap) {
|
||||
scc_ring_next_consume(pp->expanded_ring, *out, ok);
|
||||
if (ok == false) {
|
||||
@@ -71,8 +72,9 @@ CONTINUE:
|
||||
}
|
||||
|
||||
static int pproc_next(scc_pproc_t *pp, scc_lexer_tok_t *tok) {
|
||||
int ret = pproc_next_one_file(pp, tok);
|
||||
int ret = 0;
|
||||
CONTINUE:
|
||||
ret = pproc_next_one_file(pp, tok);
|
||||
if (ret != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user