refactor(log): 统一日志系统并添加链接器实现

- 为所有模块添加统一的 scc_*_log.h 日志头文件,删除旧的 lexer_log.h/c
- 将运行时日志从 scc_utils 迁移到 scc_core 目录,统一日志管理
- 在解析器表达式/语句/类型解析中添加 LOG_TRACE 调试日志
- 实现 SCCF 链接器 (sccf_linker) 支持多目标文件链接
- 重构 CLI 主程序 (main.c/config.c),新增 cmd_log.h 调试支持
- 优化 x86 指令编码操作数对齐检查
- 修复预处理器的指令处理和宏展开逻辑
This commit is contained in:
zzy
2026-06-05 13:07:41 +08:00
parent 0acea43e4e
commit 88846d7479
70 changed files with 1497 additions and 469 deletions

View File

@@ -1,5 +1,7 @@
#include <scc_parser_log.h>
#include <scc_ast_utils.h>
#include <scc_pos_log.h>
#include <scc_parse_type.h>
#include <scc_sema.h>
#include <sema_symtab.h>
@@ -159,6 +161,7 @@ static void expr_callback(scc_sema_ctx_t *sema_ctx,
if (node_type == SCC_AST_UNKNOWN || node == nullptr) {
return;
}
LOG_TRACE("sema_expr: type=%d", node_type);
scc_ast_expr_t *expr = SCC_AST_CAST_TO(scc_ast_expr_t, node);
if (node_type == SCC_AST_EXPR_IDENTIFIER) {
scc_ast_node_t *sym_node =
@@ -242,6 +245,7 @@ static void stmt_callback(scc_sema_ctx_t *sema_ctx,
scc_ast_node_kind_t node_type, void *node) {
scc_sema_symtab_t *sema_symtab = sema_ctx->context;
LOG_TRACE("sema_stmt: node_type=%d", node_type);
if (node_type == scc_ast_stmt_t_BEGIN) {
if (node == nullptr) {
scc_sema_symtab_enter_scope(sema_symtab);
@@ -364,6 +368,7 @@ static void decl_callback(scc_sema_ctx_t *sema_ctx,
scc_ast_node_kind_t node_type, void *node) {
scc_sema_symtab_t *sema_symtab = sema_ctx->context;
LOG_TRACE("sema_decl: node_type=%d", node_type);
// Function declaration scope
// FIXME 使用 node_type 区分其他未来的scope
if (node_type == scc_ast_decl_t_BEGIN) {
@@ -447,6 +452,7 @@ static scc_ast_qual_type_t *got_type_callback(scc_sema_ctx_t *sema_ctx,
}
void scc_sema_init(scc_sema_ctx_t *sema_ctx, scc_ast_module_t *ast_module) {
LOG_DEBUG("scc_sema_init()");
sema_ctx->ast_module = ast_module;
scc_sema_symtab_t *sema_symtab = scc_malloc(sizeof(scc_sema_symtab_t));
if (sema_symtab == nullptr) {