fix(compiler): 完善闭包捕获(cell 索引稳定、参数遮蔽、函数/类名捕获、b 槽立即数)

This commit is contained in:
爱特每羊队
2026-08-05 19:19:29 +08:00
parent 3390b61453
commit b611e26f11
11 changed files with 87 additions and 70 deletions
+1 -8
View File
@@ -146,14 +146,7 @@ impl Compiler {
return Ok(val_reg);
}
// Check if target is a captured cell
if ctx.captured_bindings.contains(name) {
let cell_idx = ctx
.scopes
.cell_registry
.iter()
.find(|(n, _)| n == name)
.map(|(_, idx)| *idx)
.unwrap_or(0);
if let Some(&cell_idx) = ctx.captured_bindings.get(name) {
ctx.inst(Inst::new(OpCode::CELL_SET, Operand::None, Operand::Reg(val_reg as u32), Operand::Imm(cell_idx as u16)));
return Ok(val_reg);
}