refactor: 清除旧代码并展开 crate

This commit is contained in:
爱特每羊队
2026-07-05 18:43:22 +08:00
parent f9c36ad679
commit 13cf9127e3
66 changed files with 1413 additions and 2566 deletions
@@ -0,0 +1,19 @@
use crate::compiler::{CompileCtx, Compiler};
use oxide_bytecode::opcode::{self, OpCode};
use oxide_parser::Statement;
impl Compiler {
pub(crate) fn count_throw_statement(&self, stmt: &oxide_parser::ThrowStatement<'_>, ctx: &mut CompileCtx) {
self.count_expression(&stmt.argument, ctx);
ctx.projected_pc += 1;
}
pub(crate) fn emit_throw_statement(&self, stmt: &Statement, ctx: &mut CompileCtx) -> Result<Option<u8>, String> {
let Statement::ThrowStatement(ts) = stmt else {
return Ok(None);
};
let exc_reg = self.emit_expression(&ts.argument, ctx)?;
ctx.emit(opcode::encode(OpCode::THROW, exc_reg, 0, 0));
Ok(None)
}
}