refactor: opcode 语义单张声明式表(def/use/pure/jump/term/ic 六维收敛)

This commit is contained in:
爱特每羊队
2026-08-10 12:23:19 +08:00
parent 00d547b395
commit 223f1a04e7
5 changed files with 821 additions and 466 deletions
+1 -15
View File
@@ -120,7 +120,7 @@ fn operand_pair_to_u8(a: &Operand, b: &Operand) -> (u8, u8) {
}
fn encode_inst(inst: &Inst, instrs: &mut Vec<u32>, jumps: &mut Vec<(usize, u32)>) -> Result<(), String> {
if is_jump_op(inst.op) {
if inst.op.is_jump() {
let label = match inst.b {
Operand::Label(id) => id,
_ => return Err(format!("jump op {:?} requires Label operand in b slot", inst.op)),
@@ -148,17 +148,3 @@ fn encode_inst(inst: &Inst, instrs: &mut Vec<u32>, jumps: &mut Vec<(usize, u32)>
instrs.extend_from_slice(&inst.ext);
Ok(())
}
fn is_jump_op(op: OpCode) -> bool {
matches!(
op,
OpCode::JMP
| OpCode::BREAK
| OpCode::CONTINUE
| OpCode::JMP_IF_FALSE
| OpCode::JMP_IF_TRUE
| OpCode::JMP_IF_NULLISH
| OpCode::TRY_BEGIN
| OpCode::TRY_FINALLY_BEGIN
)
}