feat(ast): 添加汇编器模块并改进AST定义和IR转换

- 在README.md中添加asm汇编器模块说明
- 更新ast_def.h中的枚举注释,添加sema相关信息以明确语义分析作用域
- 重命名函数参数param_types为params,使命名更清晰
- 移除call表达式中的_target字段,简化结构
- 为member、identifier等字段添加///< fill by sema注释说明填充时机
- 为jump语句添加_target字段用于语义分析
- 更新所有AST初始化函数,接受位置信息参数以改进错误定位
- 修复alignof表达式的类型应为ALIGN_OF而非SIZE_OF的问题
- 重构ast2ir.h,引入scc_ast2ir_ctx_t上下文结构体统一管理转换状态
- 添加符号表、节点到IR映射等必要的转换上下文信息
This commit is contained in:
zzy
2026-03-17 20:29:40 +08:00
parent cabd1710ed
commit 2e5e98868d
29 changed files with 1289 additions and 1000 deletions

View File

@@ -69,6 +69,66 @@ scc_pe_section_range scc_pe_reserve_section_header(scc_pe_builder_t *builder,
u32 virtual_size,
u32 data_size);
static inline scc_pe_section_range
scc_pe_reserve_text_section_header(scc_pe_builder_t *builder, u32 data_size) {
return scc_pe_reserve_section_header(
builder, (BYTE *)".text\0\0",
IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ,
data_size, data_size);
}
static inline scc_pe_section_range
scc_pe_reserve_data_section_header(scc_pe_builder_t *builder, u32 data_size) {
return scc_pe_reserve_section_header(builder, (BYTE *)".data\0\0",
IMAGE_SCN_CNT_INITIALIZED_DATA |
IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE,
data_size, data_size);
}
static inline scc_pe_section_range
scc_pe_reserve_rdata_section_header(scc_pe_builder_t *builder, u32 data_size) {
return scc_pe_reserve_section_header(builder, (BYTE *)".rdata\0",
IMAGE_SCN_CNT_INITIALIZED_DATA |
IMAGE_SCN_MEM_READ,
data_size, data_size);
}
static inline scc_pe_section_range
scc_pe_reserve_bss_section_header(scc_pe_builder_t *builder, u32 data_size) {
return scc_pe_reserve_section_header(builder, (BYTE *)".bss\0\0\0",
IMAGE_SCN_CNT_UNINITIALIZED_DATA |
IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE,
data_size, 0);
}
static inline scc_pe_section_range
scc_pe_reserve_idata_section_header(scc_pe_builder_t *builder, u32 data_size) {
scc_pe_section_range range = scc_pe_reserve_section_header(
builder, (BYTE *)".idata\0",
IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_WRITE,
data_size, data_size);
scc_vec_at(builder->image_data_directory_vec,
IMAGE_DIRECTORY_ENTRY_IMPORT) = (IMAGE_DATA_DIRECTORY){
.VirtualAddress = range.virual_address, .Size = range.virual_size};
return range;
}
static inline scc_pe_section_range
scc_pe_reserve_reloc_section_header(scc_pe_builder_t *builder, u32 data_size) {
scc_pe_section_range range = scc_pe_reserve_section_header(
builder, (BYTE *)".reloc\0\0",
IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ |
IMAGE_SCN_MEM_DISCARDABLE,
data_size, data_size);
scc_vec_at(builder->image_data_directory_vec,
IMAGE_DIRECTORY_ENTRY_BASERELOC) = (IMAGE_DATA_DIRECTORY){
.VirtualAddress = range.virual_address, .Size = range.virual_size};
return range;
}
void scc_pe_write_header(scc_pe_builder_t *builder, scc_pe_config_t *config);
void scc_pe_write_section(scc_pe_builder_t *builder,