当参数指定为列表类型时,验证和处理逻辑现在会检查 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): 简化词法分析器非空白标记预览逻辑 优化非空白标记预览函数,减少不必要的标记消费和销毁操作。
54 lines
1.5 KiB
C
54 lines
1.5 KiB
C
#ifndef __SCC_LEXER_UTILS_H__
|
|
#define __SCC_LEXER_UTILS_H__
|
|
|
|
#include "scc_lexer.h"
|
|
|
|
static inline void scc_lexer_gen_number_true(scc_lexer_tok_t *tok) {
|
|
Assert(tok != nullptr && tok->type == SCC_TOK_UNKNOWN);
|
|
tok->type = SCC_TOK_INT_LITERAL;
|
|
tok->lexeme = scc_str_from_cstr("1");
|
|
}
|
|
|
|
static inline void scc_lexer_gen_number_false(scc_lexer_tok_t *tok) {
|
|
Assert(tok != nullptr && tok->type == SCC_TOK_UNKNOWN);
|
|
tok->type = SCC_TOK_INT_LITERAL;
|
|
tok->lexeme = scc_str_from_cstr("0");
|
|
}
|
|
|
|
static inline cbool scc_lexer_peek_non_blank(scc_lexer_tok_ring_t *stream,
|
|
scc_lexer_tok_t *out) {
|
|
cbool ok;
|
|
while (1) {
|
|
scc_ring_peek(*stream, *out, ok);
|
|
if (!ok || out->type != SCC_TOK_BLANK)
|
|
break;
|
|
scc_ring_next(*stream, *out, ok);
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
static inline cbool scc_lexer_next_non_blank(scc_lexer_tok_ring_t *stream,
|
|
scc_lexer_tok_t *out) {
|
|
cbool ok;
|
|
if (!scc_lexer_peek_non_blank(stream, out))
|
|
return false;
|
|
scc_ring_next_consume(*stream, *out, ok);
|
|
return true;
|
|
}
|
|
|
|
static inline void scc_lexer_skip_until_newline(scc_lexer_tok_ring_t *stream) {
|
|
scc_lexer_tok_t tok;
|
|
cbool ok;
|
|
while (1) {
|
|
scc_ring_next_consume(*stream, tok, ok);
|
|
if (!ok)
|
|
break;
|
|
scc_tok_type_t type = tok.type;
|
|
scc_lexer_tok_drop(&tok);
|
|
if (type == SCC_TOK_ENDLINE)
|
|
break;
|
|
}
|
|
}
|
|
|
|
#endif /* __SCC_LEXER_UTILS_H__ */
|