mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
23 lines
761 B
Rust
23 lines
761 B
Rust
use crate::compiler::{CompileCtx, Compiler};
|
|
use oxide_parser::ClassElement;
|
|
|
|
impl Compiler {
|
|
pub(crate) fn emit_class_static_blocks(
|
|
&self, elements: &[ClassElement], ctor_reg: u8, ctx: &mut CompileCtx,
|
|
) -> Result<(), String> {
|
|
for element in elements {
|
|
if let ClassElement::StaticBlock(block) = element {
|
|
let saved_static_this = ctx.static_block_this_reg;
|
|
ctx.static_block_this_reg = Some(ctor_reg);
|
|
ctx.push_scope();
|
|
for stmt in &block.body {
|
|
self.emit_statement(stmt, ctx)?;
|
|
}
|
|
ctx.pop_scope();
|
|
ctx.static_block_this_reg = saved_static_this;
|
|
}
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|