feat(ast2ir): 添加左值标识支持以改善表达式处理
- 在 scc_ast2ir_expr 函数中添加 is_lvalue 参数来区分左值和右值表达式 - 更新二元表达式处理逻辑,特别是赋值操作符的处理 - 改进标识符表达式的处理,根据是否为左值决定返回存储位置还是加载值 - 修复哈希比较函数的实现 - 移除调试相关的注释代码 refactor(parser): 优化语法分析器错误处理和控制流 - 移除不必要的错误恢复辅助注释 - 修改表达式解析的控制流程,将直接返回改为使用 break 语句 - 添加语义分析回调,在解析完成后进行标识符查找和验证 refactor(sema): 增强语义分析阶段的符号表管理 - 改进标识符查找逻辑,增加对非变量标识符的检查 - 扩展声明处理范围,包括变量和参数声明的符号表注册 - 为函数声明添加作用域管理 fix(parser): 修正单元测试中的类型定义 - 将 long long 类型定义改为 int 类型,解决测试兼容性问题 refactor(sccf): 重构文件格式定义和构建器实现 - 重命名符号类型枚举值 OBJECT 为 EXTERN - 重命名段类型枚举值 RELOC 为 RELOCS - 修正结构体字段命名的一致性问题 - 重新设计 SCCF 构建器的数据结构和API - 添加符号表、字符串表和重定位表的构建支持 refactor(target): 重命名Windows PE相关类型定义 - 将 scc_winpe_* 类型重命名为 scc_pe_* 以保持命名一致性 chore: 添加 sccf2target 模块用于格式转换 - 创建新的库模块用于 SCCF 到目标格式的转换 - 实现 PE 格式转换的基本功能 - 添加示例程序演示格式转换过程
This commit is contained in:
@@ -100,7 +100,7 @@ static inline usize sccf_find_sect_by_type(u8 *base, sccf_enum_t type) {
|
||||
const sccf_header_t *hdr = (const sccf_header_t *)base;
|
||||
for (usize i = 0; i < (usize)hdr->sect_header_num; ++i) {
|
||||
sccf_sect_header_t *sh = sccf_sect_header(base, i);
|
||||
if (sh->scf_sect_type == type)
|
||||
if (sh->sccf_sect_type == type)
|
||||
return i;
|
||||
}
|
||||
return (usize)hdr->sect_header_num;
|
||||
@@ -167,6 +167,9 @@ typedef SCC_VEC(u8) sccf_buffer_t;
|
||||
typedef SCC_VEC(u8) sccf_sect_data_t;
|
||||
typedef SCC_VEC(sccf_sect_data_t) sccf_sect_data_vec_t;
|
||||
typedef SCC_VEC(sccf_sect_header_t) sccf_sect_header_vec_t;
|
||||
typedef SCC_VEC(sccf_sym_t) sccf_sym_vec_t;
|
||||
typedef SCC_VEC(sccf_reloc_t) sccf_reloc_vec_t;
|
||||
typedef SCC_VEC(char) sccf_strtab_t;
|
||||
|
||||
typedef struct {
|
||||
sccf_header_t header;
|
||||
@@ -241,7 +244,7 @@ static inline void sccf_parse(sccf_t *sccf, sccf_buffer_t *buffer, int copied) {
|
||||
* @param[in] sccf
|
||||
* @return usize
|
||||
*/
|
||||
static inline usize sccf_size(sccf_t *sccf) {
|
||||
static inline usize sccf_size(const sccf_t *sccf) {
|
||||
if (scc_vec_size(sccf->sect_datas) != scc_vec_size(sccf->sect_headers) ||
|
||||
scc_vec_size(sccf->sect_headers) != sccf->header.sect_header_num) {
|
||||
Panic();
|
||||
@@ -265,7 +268,7 @@ static inline usize sccf_size(sccf_t *sccf) {
|
||||
* @param[in] sccf
|
||||
* @param[out] buffer
|
||||
*/
|
||||
static inline void sccf_write(sccf_t *sccf, sccf_buffer_t *buffer) {
|
||||
static inline void sccf_write(const sccf_t *sccf, sccf_buffer_t *buffer) {
|
||||
usize size = sccf_size(sccf);
|
||||
if (scc_vec_size(*buffer) < size) {
|
||||
scc_vec_realloc(*buffer, size);
|
||||
|
||||
Reference in New Issue
Block a user