mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-26 03:31:12 +08:00
refactor: 清除旧代码并展开 crate
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
use crate::compiler::{CompileCtx, Compiler};
|
||||
use oxide_parser::Statement;
|
||||
|
||||
impl Compiler {
|
||||
fn count_block_statement(&self, block: &oxide_parser::BlockStatement<'_>, ctx: &mut CompileCtx) {
|
||||
for s in &block.body {
|
||||
self.count_statement(s, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_block_statement(&self, stmt: &Statement, ctx: &mut CompileCtx) -> Result<Option<u8>, String> {
|
||||
let Statement::BlockStatement(block) = stmt else {
|
||||
return Ok(None);
|
||||
};
|
||||
ctx.push_scope();
|
||||
let mut r = None;
|
||||
for s in &block.body {
|
||||
if let Some(rr) = self.emit_statement(s, ctx)? {
|
||||
r = Some(rr);
|
||||
}
|
||||
}
|
||||
ctx.pop_scope();
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
pub(crate) fn count_block_domain(&self, stmt: &Statement, ctx: &mut CompileCtx) {
|
||||
if let Statement::BlockStatement(block) = stmt {
|
||||
self.count_block_statement(block, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn emit_block_domain(&self, stmt: &Statement, ctx: &mut CompileCtx) -> Result<Option<u8>, String> {
|
||||
match stmt {
|
||||
Statement::BlockStatement(_) => self.emit_block_statement(stmt, ctx),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user