mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 03:01:12 +08:00
refactor: 移除迭代计数辅助
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user