Files
scc/runtime/scc_utils/include/scc_strpool.h
zzy b753ae0911 refactor(lex_parser): 重命名libcore为scc_core并重构头文件包含
- 将依赖项从libcore重命名为scc_core
- 更新头文件包含路径从<libcore.h>到<scc_core.h>
- 保持原有功能不变

refactor(lexer): 重命名libcore为scc_core并添加词法流式解析功能

- 将依赖项从libcore重命名为scc_core
- 移除不再需要的scc_lexer_token结构体定义
- 重命名struct cc_lexer为struct scc_lexer
- 添加scc_lexer_stream_t流式解析器相关定义和实现
- 新增lexer_stream.c文件实现流式token缓冲功能

refactor(lexer_log): 重命名logger变量和头文件定义

- 将头文件保护宏从__SMCC_LEXER_LOG_H__改为__SCC_LEXER_LOG_H__
- 将logger变量从__smcc_lexer_log改为__scc_lexer_log
- 更新头文件包含从<libcore.h>到<scc_core.h>

refactor(lexer_token): 重新组织token头文件结构

- 将头文件保护宏从__SMCC_CC_TOKEN_H__改为__SCC_LEXER_TOKEN_H__
- 更新头文件包含从<libcore.h>到<scc_core.h>
- 将scc_lexer_token结构体定义移至该文件

refactor(lexer): 简化token匹配代码格式

- 移除LCC相关的注释内容
- 优化括号符号的token匹配代码格式,使用clang-format控制

refactor(pprocessor): 更新依赖项名称和头文件包含

- 将libcore重命名为scc_core
- 将libutils重命名为scc_utils
- 更新头文件包含路径

refactor(runtime): 重命名libcore为scc_core并重构目录结构

- 将libcore目录重命名为scc_core
- 将libutils目录重命名为scc_utils
- 更新所有相关的头文件包含路径
- 修改cbuild.toml中的包名称
- 更新core_vec.h中的宏定义以支持标准库模式
2026-01-08 11:22:27 +08:00

70 lines
1.8 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file strpool.h
* @brief 字符串池实现
*
* 提供字符串驻留String Interning功能保证相同字符串的唯一性存储
*/
#ifndef __SCC_STRPOOL_H__
#define __SCC_STRPOOL_H__
#include "scc_hashtable.h"
#include <scc_core.h>
/**
* @struct strpool_t
* @brief 字符串池上下文
*
* 组合哈希表和专用内存分配器实现的高效字符串存储池
*/
typedef struct strpool {
scc_hashtable_t ht; /**< 哈希表用于快速查找已存储字符串 */
} scc_strpool_t;
/**
* @brief 初始化字符串池
* @param pool 字符串池实例指针
*/
void scc_strpool_init(scc_strpool_t *pool);
/**
* @brief 驻留字符串到池中
* @param pool 字符串池实例指针
* @param str 要驻留的 C 字符串
* @return 池中唯一字符串的持久指针
*
* @note 返回值生命周期与字符串池一致
* @note 重复插入相同字符串会返回已有指针
*/
const char *scc_strpool_intern(scc_strpool_t *pool, const char *str);
/**
* @brief 销毁字符串池
* @param pool 字符串池实例指针
*
* @warning 销毁后已获取的字符串指针将失效
* @note 会自动释放所有驻留字符串内存
*/
void scc_strpool_drop(scc_strpool_t *pool);
/**
* @typedef scc_hashtable_iter_fn
* @brief 哈希表迭代回调函数类型
* @param key 当前键指针
* @param value 当前值指针
* @param context 用户上下文指针
* @return 返回非0停止迭代
*/
typedef int (*scc_strpool_iter_fn)(const char *key, char *value, void *context);
/**
* @brief 遍历字符串表所有有效条目
* @param ht 字符串表实例指针
* @param iter_func 迭代回调函数
* @param context 用户上下文指针
*/
void scc_strpool_foreach(scc_strpool_t *pool, scc_strpool_iter_fn iter_func,
void *context);
#endif /* __SCC_STRPOOL_H__ */