阶段2-6:V2 生成侧 bug 修复与验证收尾

- Codec:set_byte0 的 11/10 前缀位修正(0xC0/0x80);新增 JC 形态偏移
  专用读写(off@55..24,字节 3..6)——修复 JF rd 被 off 覆盖
- Stb:offset_meta=0(空段)时值段大小校验按 SHA 尾计算(修复
  values segment size mismatch)
- Codegen:实例字段带 func(field_func),LOAD_OFF/STORE_OFF 按字段
  类型设 func(pt=TIME → I64)
- main.cpp:--disasm 按 instr_len 迭代变长字节码
- 验证:13 个正例全部编译出 V2 产物 + disasm 自读通过(RET/CAL.TON/
  STORE_OFF.I64/JF 偏移等抽查正确);ctest 11/13(vm/cases 待阶段 4)
This commit is contained in:
2026-08-25 20:23:32 +08:00
parent 924c0c1923
commit 4785cf3e3b
5 changed files with 79 additions and 31 deletions
+6 -2
View File
@@ -60,8 +60,10 @@ namespace compiler {
uint32_t imm32_of(const uint8_t* code);
/// @brief 取 slot3255..24SLOT 形态)。
uint32_t slot32_of(const uint8_t* code);
/// @brief 取 off3247..16JMP/JC 形态,有符号字节偏移)。
/// @brief 取 off3247..16JMP 形态,有符号字节偏移)。
int32_t off32_of(const uint8_t* code);
/// @brief 取 off3255..24JC 形态,有符号字节偏移)。
int32_t off32_jc_of(const uint8_t* code);
/// @brief 取 fn_id3247..16CALL 形态)。
uint32_t fn_id32_of(const uint8_t* code);
/// @brief 取 fb_id1631..16CAL 形态)。
@@ -93,8 +95,10 @@ namespace compiler {
void set_imm32(uint8_t* out, uint32_t v);
/// @brief 写 slot3255..24)。
void set_slot32(uint8_t* out, uint32_t v);
/// @brief 写 off3247..16)。
/// @brief 写 off3247..16JMP 形态)。
void set_off32(uint8_t* out, int32_t v);
/// @brief 写 off3255..24JC 形态)。
void set_off32_jc(uint8_t* out, int32_t v);
/// @brief 写 fn_id3247..16)。
void set_fn_id32(uint8_t* out, uint32_t v);
/// @brief 写 fb_id1631..16)。