阶段3-4:新类型运算验证 + 修复(011 前缀位、func 大小写、位串 AND/OR)

新类型运算验证(综合用例全部正确):
- REAL 算术 ADD.F32、LREAL 算术 ADD.F64
- TIME+ ADD.I64、TIME 比较 CMP_GT.I64
- DATE/TOD/DT 比较 CMP_GT.U32/U32/U64
- DINT 算术 ADD.I32、UDINT 字面量装载+截断
- WORD 位串 AND(短路 JF+MOVE)
- 负例:UINT 溢出拦截

修复的 bug:
1. set_byte0 '011' 分支 0x40→0x60(RRR 指令被误判为 010 区,
   ADD 等显示错乱)——阶段 2 遗留
2. Codegen func_of_name 大小写不敏感(符号表小写/type 表大写,
   否则 REAL 等返回 func 0)
3. Typecheck AND/OR 支持位串(BOOL 逻辑或 bit 按宽度逐位)

已知缺陷(记录):LREAL 字面量装载按 REAL(LOADK.F32),
ADD.F64 运算位模式错位——需 compile_expr 携带目标 func(TODO)。
This commit is contained in:
2026-08-26 09:40:12 +08:00
parent 2c5852797a
commit b19a61aabf
3 changed files with 27 additions and 8 deletions
+1 -1
View File
@@ -209,7 +209,7 @@ void set_byte0(uint8_t* out, const std::string& prefix, uint32_t op) {
} else if (prefix == "10") {
out[0] = static_cast<uint8_t>(0x80 | (op & 0x3F)); // bit7..6 = 10
} else if (prefix == "011") {
out[0] = static_cast<uint8_t>(0x40 | (op & 0x1F));
out[0] = static_cast<uint8_t>(0x60 | (op & 0x1F)); // bit7..5 = 011
} else if (prefix.size() == 6 && prefix.compare(0, 3, "010") == 0) {
const uint32_t shape = static_cast<uint32_t>(prefix[3] - '0') * 4 +
static_cast<uint32_t>(prefix[4] - '0') * 2 +