refactor: 移除迭代计数辅助

This commit is contained in:
2026-08-05 01:23:39 +08:00
parent fd978b7ef8
commit c4ea84bda1
8 changed files with 1 additions and 188 deletions
@@ -2,18 +2,6 @@ use crate::compiler::{CompileCtx, Compiler, Label};
use oxide_parser::Statement;
impl Compiler {
pub(crate) fn count_while_statement(&self, stmt: &oxide_parser::WhileStatement<'_>, ctx: &mut CompileCtx) {
let id = ctx.next_label_id();
let start_label = Label::WhileStart(id);
let end_label = Label::WhileEnd(id);
ctx.labels.label_map.insert(start_label, ctx.projected_pc);
self.count_expression(&stmt.test, ctx);
ctx.projected_pc += 1;
self.count_statement(&stmt.body, ctx);
ctx.projected_pc += 1;
ctx.labels.label_map.insert(end_label, ctx.projected_pc);
}
pub(crate) fn emit_while_statement(&self, stmt: &Statement, ctx: &mut CompileCtx) -> Result<Option<u8>, String> {
let Statement::WhileStatement(wh) = stmt else {
return Ok(None);