refactor: 拆分属性与成员分发并统一 LOAD_CONST 发射

This commit is contained in:
爱特每羊队
2026-06-09 00:27:09 +08:00
parent a0c1181fdc
commit e6ae7fbc46
6 changed files with 574 additions and 645 deletions
+9
View File
@@ -96,6 +96,15 @@ impl CompileCtx {
self.bytecode.push(instr);
}
pub(crate) fn emit_load_const(&mut self, reg: u8, idx: u16) {
self.emit(opcode::encode(
OpCode::LOAD_CONST,
reg,
(idx & 0xFF) as u8,
((idx >> 8) & 0xFF) as u8,
));
}
pub(crate) fn alloc_reg(&mut self) -> u8 {
let r = self.next_reg;
self.next_reg = self.next_reg.wrapping_add(1);