docs: 补充注释与格式化

This commit is contained in:
2026-08-06 23:10:27 +08:00
parent e36a69976e
commit 31e28a03a6
156 changed files with 2393 additions and 1687 deletions
@@ -5,7 +5,9 @@ use oxide_ir::inst::Inst;
use oxide_parser::Statement;
impl Emitter {
pub(crate) fn emit_do_while_statement(&self, stmt: &Statement, ctx: &mut CompileCtx) -> Result<Option<u32>, String> {
pub(crate) fn emit_do_while_statement(
&self, stmt: &Statement, ctx: &mut CompileCtx,
) -> Result<Option<u32>, String> {
let Statement::DoWhileStatement(dw) = stmt else {
return Ok(None);
};
+8 -3
View File
@@ -1,10 +1,10 @@
//! for 语句 emit:`emit_for_statement` 含 init/test/update 三段与循环跳转。
use crate::{CompileCtx, Emitter};
use oxide_ir::inst::Inst;
use oxide_ir::operand::Operand;
use oxide_bytecode::module::Constant;
use oxide_bytecode::opcode::OpCode;
use oxide_ir::inst::Inst;
use oxide_ir::operand::Operand;
use oxide_parser::{BindingPattern, ForStatementInit, Statement, VariableDeclarationKind};
impl Emitter {
@@ -40,7 +40,12 @@ impl Emitter {
ctx.declare(bi.name.as_str(), var_reg, decl.kind, is_const)?;
var_reg
};
ctx.inst(Inst::new(OpCode::STORE_VAR, Operand::Reg(target_reg), Operand::Reg(tmp), Operand::None));
ctx.inst(Inst::new(
OpCode::STORE_VAR,
Operand::Reg(target_reg),
Operand::Reg(tmp),
Operand::None,
));
ctx.init_var(bi.name.as_str());
}
}
@@ -1,9 +1,9 @@
//! for-in 语句 emit:`emit_for_in_statement` 遍历可枚举属性名。
use crate::{CompileCtx, Emitter};
use oxide_bytecode::opcode::OpCode;
use oxide_ir::inst::Inst;
use oxide_ir::operand::Operand;
use oxide_bytecode::opcode::OpCode;
use oxide_parser::{ForStatementLeft, Statement, VariableDeclarationKind};
impl Emitter {
@@ -1,9 +1,9 @@
//! for-of 语句 emit:`emit_for_of_statement` 迭代器协议遍历。
use crate::{CompileCtx, Emitter};
use oxide_bytecode::opcode::OpCode;
use oxide_ir::inst::Inst;
use oxide_ir::operand::Operand;
use oxide_bytecode::opcode::OpCode;
use oxide_parser::{ForStatementLeft, Statement};
impl Emitter {