refactor(ast2ir): 移除废弃的ABI依赖并优化类型转换处理
移除了对scc_abi包的依赖,将相关头文件从libs/abi移动到libs/ast2ir目录下。 重构了基本类型解析功能,将parse_base_type函数提取为独立的 scc_ast2ir_parse_base_type实现,并支持有符号/无符号类型区分。 feat(ast2ir): 实现整数常量表达式求值器 新增了完整的整数常量表达式求值功能,支持C11标准中的常量表达式规则, 包括字面量、标识符、sizeof/_Alignof、一元/二元运算、条件表达式和 类型转换等操作。该功能用于数组大小和枚举值的编译期计算验证。 refactor(ast2ir): 完善类型提升和算术转换机制 改进了整数提升和寻常算术转换的实现,修复了移位操作的符号处理问题, 添加了无符号比较操作的支持,增强了类型安全检查,统一了错误处理流程。 fix(ast2ir): 修复赋值表达式返回值和数组大小计算问题 修正了赋值表达式的返回值处理,确保返回右侧值而不是存储指令引用。 使用新的常量表达式求值器替代原有的硬编码数组大小计算,提高了 数组声明的正确性。
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
* @brief Arbitrary Precision Library
|
||||
*
|
||||
*/
|
||||
#ifdef __SCC__
|
||||
#ifndef __NO_SCC_RUNTIME__
|
||||
#include <scc_core.h>
|
||||
#define SCC_AP_DIGIT u64
|
||||
#define SCC_AP_PANIC Panic
|
||||
@@ -49,21 +49,21 @@ typedef struct {
|
||||
} scc_ap_t;
|
||||
|
||||
static inline void scc_ap_init(scc_ap_t *ap) {
|
||||
ap->len = 0;
|
||||
ap->capacity = -1;
|
||||
ap->len = 1;
|
||||
ap->data.digit = 0;
|
||||
}
|
||||
|
||||
static inline void scc_ap_set_int(scc_ap_t *ap, int val) {
|
||||
ap->capacity = -1;
|
||||
SCC_AP_ASSERT(sizeof(scc_ap_digit) >= sizeof(int));
|
||||
if (val < 0) {
|
||||
ap->len = -1;
|
||||
ap->data.digit = (scc_ap_digit)(-(int64_t)val);
|
||||
} else {
|
||||
ap->len = 1;
|
||||
ap->data.digit = (scc_ap_digit)val;
|
||||
}
|
||||
SCC_AP_ASSERT(sizeof(scc_ap_digit) >= sizeof(int));
|
||||
ap->capacity = -1;
|
||||
ap->data.digit = val;
|
||||
}
|
||||
|
||||
void scc_ap_drop(scc_ap_t *ap);
|
||||
@@ -77,13 +77,20 @@ void scc_ap_mul(scc_ap_t *to, const scc_ap_t *from_a, const scc_ap_t *from_b);
|
||||
void scc_ap_div(scc_ap_t *to, const scc_ap_t *from_a, const scc_ap_t *from_b);
|
||||
void scc_ap_mod(scc_ap_t *to, const scc_ap_t *from_a, const scc_ap_t *from_b);
|
||||
|
||||
/**
|
||||
* @brief equal
|
||||
*
|
||||
* @param a
|
||||
* @param b
|
||||
* @return int
|
||||
*/
|
||||
void scc_ap_shl(scc_ap_t *to, const scc_ap_t *from, unsigned shift);
|
||||
void scc_ap_shr(scc_ap_t *to, const scc_ap_t *from, unsigned shift);
|
||||
void scc_ap_lshr(scc_ap_t *to, const scc_ap_t *from, unsigned shift);
|
||||
|
||||
void scc_ap_and(scc_ap_t *to, const scc_ap_t *a, const scc_ap_t *b);
|
||||
void scc_ap_or(scc_ap_t *to, const scc_ap_t *a, const scc_ap_t *b);
|
||||
void scc_ap_xor(scc_ap_t *to, const scc_ap_t *a, const scc_ap_t *b);
|
||||
void scc_ap_not(scc_ap_t *to, const scc_ap_t *from);
|
||||
|
||||
void scc_ap_neg(scc_ap_t *to, const scc_ap_t *from);
|
||||
|
||||
int scc_ap_cmp(const scc_ap_t *a, const scc_ap_t *b);
|
||||
int scc_ap_is_zero(const scc_ap_t *ap);
|
||||
|
||||
int scc_ap_eql(const scc_ap_t *a, const scc_ap_t *b);
|
||||
|
||||
typedef void (*ap_dump_fn)(const char ch, void *user_data);
|
||||
|
||||
Reference in New Issue
Block a user