style: 自动格式化

This commit is contained in:
2026-10-12 14:43:58 +00:00
parent 66e240ad00
commit 9dd19bb46a
2 changed files with 8 additions and 13 deletions
+7 -9
View File
@@ -86,15 +86,13 @@ pub fn fold_function(f: &mut IRFunction) -> bool {
// VOID 无操作数,恒折 Undefined。 // VOID 无操作数,恒折 Undefined。
OpCode::VOID => Some(Constant::Undefined), OpCode::VOID => Some(Constant::Undefined),
// 其余一元:操作数须为已知寄存器。 // 其余一元:操作数须为已知寄存器。
OpCode::NOT | OpCode::TYPEOF | OpCode::NEG | OpCode::UNARY_PLUS | OpCode::BIT_NOT => { OpCode::NOT | OpCode::TYPEOF | OpCode::NEG | OpCode::UNARY_PLUS | OpCode::BIT_NOT => match inst.a {
match inst.a { Operand::Reg(x) => known
Operand::Reg(x) => known .get(x as usize)
.get(x as usize) .and_then(|c| c.as_ref())
.and_then(|c| c.as_ref()) .and_then(|c| fold_table::fold_unary(inst.op, c)),
.and_then(|c| fold_table::fold_unary(inst.op, c)), _ => None,
_ => None, },
}
}
// 二元算术:两操作数须为已知寄存器。 // 二元算术:两操作数须为已知寄存器。
OpCode::ADD | OpCode::SUB | OpCode::MUL | OpCode::DIV | OpCode::MOD | OpCode::EXP => { OpCode::ADD | OpCode::SUB | OpCode::MUL | OpCode::DIV | OpCode::MOD | OpCode::EXP => {
match (inst.a, inst.b) { match (inst.a, inst.b) {
+1 -4
View File
@@ -328,10 +328,7 @@ fn fold_add_bigint() {
#[test] #[test]
fn fold_add_bigint_mixed_not_folded() { fn fold_add_bigint_mixed_not_folded() {
// 1n + 1 BigInt 混合 → 不折(运行期抛 TypeError)。 // 1n + 1 BigInt 混合 → 不折(运行期抛 TypeError)。
let (a, b) = ( let (a, b) = (Constant::BigInt(num_bigint::BigInt::from(1)), Constant::Int(1));
Constant::BigInt(num_bigint::BigInt::from(1)),
Constant::Int(1),
);
let mut f = func( let mut f = func(
&[a, b], &[a, b],
vec![ vec![