feat(argparse): 添加枚举类型选项支持

添加了对命令行参数枚举类型的支持,允许用户从预定义的选项中进行选择,
并在解析时进行验证。同时修复了空值检查问题。

refactor(mir): 重构pass管理系统

将原有的pass管理器系统简化为直接的pass执行函数,移除了复杂的
依赖管理和流水线构建机制,使系统更加简洁明了。

chore(ir): 添加Windows x64 ABI实现

实现了Windows x64平台的ABI约定,包括参数传递、寄存器使用和
栈帧布局的处理逻辑。

feat(config): 统一编译阶段控制配置

将多个独立的布尔类型编译阶段控制改为统一的枚举类型,便于
管理和扩展新的编译阶段。
This commit is contained in:
zzy
2026-05-10 15:02:36 +08:00
parent e5cb70732e
commit 902ee6dea3
13 changed files with 486 additions and 345 deletions

View File

@@ -69,6 +69,10 @@ static inline void prepare_cmd(scc_optparse_t *optparse,
min_args = 1;
max_args = 65535; // FIXME maybe INT_MAX ?
break;
case SCC_ARGPARSE_VAL_TYPE_ENUM:
min_args = 1;
max_args = 1;
break;
default:
min_args = 0;
max_args = 0;
@@ -136,13 +140,22 @@ static int transite_error(scc_argparse_context_t *ctx) {
return error;
}
static int check_choices(const scc_argparse_spec_t *spec, const char *value) {
static int check_choices(const scc_argparse_spec_t *spec, const char *value,
int *out_index) {
if (!spec->choices.values || spec->choices.count == 0) {
return SCC_ARGPARSE_ERR_NONE;
}
if (value == nullptr) {
return SCC_ARGPARSE_ERR_MISSING_VALUE;
}
if (out_index)
*out_index = -1;
for (int i = 0; i < spec->choices.count; i += 1) {
if (scc_strcmp(value, spec->choices.values[i]) == 0) {
if (out_index)
*out_index = i;
return SCC_ARGPARSE_ERR_NONE;
}
}
@@ -219,6 +232,9 @@ static int handle_option(scc_argparse_context_t *ctx, scc_argparse_t *parser) {
if (opt->spec.value_type == SCC_ARGPARSE_VAL_TYPE_BOOL) {
*opt->spec.store.bool_store = true;
} else if (opt->spec.value_type == SCC_ARGPARSE_VAL_TYPE_ENUM) {
return check_choices(&opt->spec, ctx->result.value,
opt->spec.store.int_store);
}
if (!ctx->result.value) {