refactor: CompileCtx 拆分为 LabelCtx/ScopeCtx,字面量域改用注册表入口

This commit is contained in:
爱特每羊队
2026-06-25 19:46:35 +08:00
parent bb3f1cf0e9
commit db0444dabd
17 changed files with 180 additions and 113 deletions
@@ -1,6 +1,17 @@
use super::*;
impl Compiler {
/// Domain entry point: count any literal expression. The central
/// `count_expression` match delegates all literal variants here in one arm.
/// Numeric/String/Boolean/Null share the default single-`LOAD_CONST` shape;
/// RegExp emits three instructions.
pub(in crate::counter) fn count_literal(&self, expr: &Expression, ctx: &mut CompileCtx) {
match expr {
Expression::RegExpLiteral(_) => self.count_regexp_literal(ctx),
_ => self.count_default_expression(ctx),
}
}
pub(in crate::counter) fn count_this_expression(&self, ctx: &mut CompileCtx) {
ctx.alloc_reg();
ctx.projected_pc += 1; // LOAD_VAR from reg 254