feat(argparse): 支持列表类型参数解析

当参数指定为列表类型时,验证和处理逻辑现在会检查
vec_store 是否为空或大小为0,而不是检查 str_store。

fix(hir): 初始化聚合类型值的数据结构

在 HIR 值初始化过程中,为聚合类型添加适当的初始化逻辑,
确保其字段向量被正确初始化。

refactor(hir_builder): 优化指针类型创建和GEP操作实现

- 简化全局分配器中的指针类型创建代码
- 扩展 GEP 操作以支持结构体和联合体字段访问
- 添加字段偏移计算支持

feat(hir_dump): 增强HIR类型和值的线性转储功能

- 实现类型定义的线性转储输出
- 改进结构体和联合体的转储格式
- 优化聚合值的转储表示

perf(hir_layout): 优化类型布局计算性能

改进结构体、联合体和聚合类型的对齐和大小计算算法,
提高字段偏移计算的准确性。

fix(hir_module): 完善模块资源清理机制

在模块析构时正确释放结构体和联合体类型的字段向量内存。

docs(lir): 更新文档注释中的空值表示

将初始化数据参数的空值描述从 NULL 统一为 nullptr。

refactor(hir2lir): 改进HIR到LIR的类型转换逻辑

- 重构类型到LIR大小扩展的转换函数
- 修复STORE指令的类型推导逻辑
- 增强GEP指令的规模因子和偏移量计算
- 添加对结构体/联合体字段访问的支持

refactor(x86_isel): 优化x86-64地址加载指令生成

改进LOAD_ADDR指令生成,更好地支持结构体字段访问的零比例因子。

docs(ir2mcode): 统一空值表示文档注释

更新初始化数据参数的空值描述为nullptr。

refactor(lexer): 简化词法分析器非空白标记预览逻辑

优化非空白标记预览函数,减少不必要的标记消费和销毁操作。
This commit is contained in:
zzy
2026-06-03 17:34:16 +08:00
parent be33eb3942
commit 0acea43e4e
17 changed files with 486 additions and 174 deletions

View File

@@ -171,12 +171,20 @@ static int validate_and_cleanup(scc_argparse_context_t *ctx,
scc_vec_foreach(ctx->current_cmd->args, i) {
scc_argparse_arg_t *arg = &scc_vec_at(ctx->current_cmd->args, i);
if (arg->spec.flag_required) {
// 检查是否已存储(非空)
if (arg->spec.store.str_store == nullptr ||
*arg->spec.store.str_store == nullptr) {
errcode = SCC_ARGPARSE_ERR_MISSING_ARG;
ctx->err_ctx = arg->name;
goto END;
if (arg->spec.value_type == SCC_ARGPARSE_VAL_TYPE_LIST) {
if (arg->spec.store.vec_store == nullptr ||
scc_vec_size(*arg->spec.store.vec_store) == 0) {
errcode = SCC_ARGPARSE_ERR_MISSING_ARG;
ctx->err_ctx = arg->name;
goto END;
}
} else {
if (arg->spec.store.str_store == nullptr ||
*arg->spec.store.str_store == nullptr) {
errcode = SCC_ARGPARSE_ERR_MISSING_ARG;
ctx->err_ctx = arg->name;
goto END;
}
}
}
}
@@ -265,9 +273,13 @@ static int handle_positional_arg(scc_argparse_context_t *ctx,
if (ctx->positional_index < (int)scc_vec_size(ctx->current_cmd->args)) {
scc_argparse_arg_t *arg =
&scc_vec_at(ctx->current_cmd->args, ctx->positional_index);
*arg->spec.store.str_store = ctx->result.value;
if (arg->spec.value_type == SCC_ARGPARSE_VAL_TYPE_LIST) {
scc_vec_push(*arg->spec.store.vec_store, ctx->result.value);
} else {
*arg->spec.store.str_store = ctx->result.value;
ctx->positional_index++;
}
arg->spec.raw_value = ctx->result.value;
ctx->positional_index++;
} else {
ctx->parsing_done = true;
return SCC_ARGPARSE_ERR_UNKNOWN_ARG;