mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
27 lines
804 B
Rust
27 lines
804 B
Rust
use crate::compiler::{CompileCtx, Compiler};
|
|
use oxide_parser::Statement;
|
|
|
|
impl Compiler {
|
|
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 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),
|
|
}
|
|
}
|
|
}
|