refactor(ir): 将IR节点重构为值引用并添加字符串字面量支持

- 将scc_ir_node_ref_t重命名为scc_ir_value_ref_t,并更新所有相关API
- 修改IR定义中的节点标签枚举为值标签枚举(scc_ir_node_tag_t -> scc_ir_value_tag_t)
- 更新AST到IR转换器中所有节点引用的类型声明
- 添加对内置类型(VOID, CHAR, INT等)的完整映射实现
- 实现字符串字面量的常量数组创建功能
- 更新项目名称从"Simple Modual C Compiler"为"Simple C Compiler"
- 在Doxyfile中排除external目录的文档生成
- 移除未使用的strpool字段并重命名decl到IR的映射表

BREAKING CHANGE: IR节点引用类型已更改,所有使用scc_ir_node_ref_t的地方需
替换为scc_ir_value_ref_t。
This commit is contained in:
zzy
2026-03-31 11:42:14 +08:00
parent 4ddad7b456
commit 78e7c800ba
22 changed files with 992 additions and 727 deletions

View File

@@ -5,6 +5,7 @@
typedef struct {
scc_hashtable_t str2libsym;
scc_pe_idata_lib_vec_t idata_libs;
const char *find_path;
} pe_idata_lib_ctx_t;
static void load_from_def(pe_idata_lib_ctx_t *ctx, const char *file_path,
@@ -57,14 +58,15 @@ static void load_from_def(pe_idata_lib_ctx_t *ctx, const char *file_path,
}
}
static void pe_idata_lib_init(pe_idata_lib_ctx_t *ctx) {
static void pe_idata_lib_init(pe_idata_lib_ctx_t *ctx, const char *find_path) {
// Got .dll.def
scc_hashtable_init(&ctx->str2libsym,
(scc_hashtable_hash_func_t)scc_strhash32,
(scc_hashtable_equal_func_t)scc_strcmp);
scc_vec_init(ctx->idata_libs);
load_from_def(ctx, __FILE__ "/../../.dll_def", "ucrtbase.dll");
ctx->find_path = find_path;
load_from_def(ctx, ctx->find_path, "ucrtbase.dll");
}
static cbool pe_idata_get(pe_idata_lib_ctx_t *ctx, const char *name) {
@@ -149,7 +151,7 @@ void sccf2pe(scc_pe_builder_t *builder, const sccf_t *sccf) {
}
pe_idata_lib_ctx_t idata_lib_ctx;
pe_idata_lib_init(&idata_lib_ctx);
pe_idata_lib_init(&idata_lib_ctx, __FILE__ "/../../.dll_def");
scc_vec_foreach(symtab, i) {
sccf_sym_t *sym = &scc_vec_at(symtab, i);
if (sym->sccf_sym_type == SCCF_SYM_TYPE_EXTERN) {
@@ -218,7 +220,6 @@ void sccf2pe(scc_pe_builder_t *builder, const sccf_t *sccf) {
if (reloc->reloc_type == SCCF_RELOC_TYPE_ABS) {
TODO();
}
Assert(reloc->sect_type == SCCF_SECT_CODE);
rva -= code_range.virual_address + reloc->offset + reloc->addend;
Assert(code_data != null);
// FIXME 需要确保宿主机与目标机器大小端一致