refactor: 移除语句跳转计数辅助

This commit is contained in:
2026-08-05 01:17:22 +08:00
parent dfc14cfce9
commit fd978b7ef8
9 changed files with 28 additions and 175 deletions
@@ -218,6 +218,18 @@ fn compile_switch_break() {
assert!(!module.bytecode.is_empty());
}
#[test]
fn compile_try_finally_resolves_finally_offset() {
let module = compile_source("try { 1; } finally { 2; }");
let try_finally_begin = module
.bytecode
.iter()
.copied()
.find(|&instr| opcode::opcode(instr) == OpCode::TRY_FINALLY_BEGIN)
.expect("try/finally should emit TRY_FINALLY_BEGIN");
assert_ne!(opcode::offset16(try_finally_begin), 0, "finally target offset should be resolved");
}
#[test]
fn compile_continue_in_switch_errors() {
let result = std::panic::catch_unwind(|| {