refactor: 拆分 counter expression 计数分发

This commit is contained in:
2026-06-23 17:58:19 +08:00
parent 0170354250
commit 8a6fac5ef7
11 changed files with 590 additions and 426 deletions
@@ -0,0 +1,29 @@
use super::*;
impl Compiler {
pub(in crate::counter) fn count_this_expression(&self, ctx: &mut CompileCtx) {
ctx.alloc_reg();
ctx.projected_pc += 1; // LOAD_VAR from reg 254
}
pub(in crate::counter) fn count_identifier_expression(&self, expr: &Expression, ctx: &mut CompileCtx) {
let Expression::Identifier(ident) = expr else {
return;
};
if CompileCtx::is_known_builtin(ident.name.as_str()) {
let _ = ctx.lookup_or_builtin(ident.name.as_str());
}
ctx.alloc_reg();
ctx.projected_pc += 1; // LOAD_VAR
}
pub(in crate::counter) fn count_regexp_literal(&self, ctx: &mut CompileCtx) {
ctx.alloc_reg();
ctx.projected_pc += 1;
}
pub(in crate::counter) fn count_default_expression(&self, ctx: &mut CompileCtx) {
ctx.alloc_reg();
ctx.projected_pc += 1; // LOAD_CONST or LOAD_VAR
}
}