refactor: 拆分 counter expression 计数分发

This commit is contained in:
爱特每羊队
2026-06-23 17:58:19 +08:00
parent fd11b7636a
commit 4ef7274283
11 changed files with 590 additions and 426 deletions
@@ -0,0 +1,17 @@
use super::*;
impl Compiler {
pub(in crate::counter) fn count_chain_expression(&self, expr: &Expression, ctx: &mut CompileCtx) {
let Expression::ChainExpression(chain) = expr else {
return;
};
let id = ctx.next_label_id();
self.count_chain_element(&chain.expression, true, ctx);
ctx.alloc_reg();
ctx.projected_pc += 1; // LOAD_VAR result <- chain value
ctx.projected_pc += 1; // JMP over short-circuit writer
ctx.label_map.insert(Label::TernaryElse(id), ctx.projected_pc);
ctx.projected_pc += 1; // LOAD_CONST undefined
ctx.label_map.insert(Label::TernaryEnd(id), ctx.projected_pc);
}
}