mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
style: 自动格式化
This commit is contained in:
@@ -86,15 +86,13 @@ pub fn fold_function(f: &mut IRFunction) -> bool {
|
||||
// VOID 无操作数,恒折 Undefined。
|
||||
OpCode::VOID => Some(Constant::Undefined),
|
||||
// 其余一元:操作数须为已知寄存器。
|
||||
OpCode::NOT | OpCode::TYPEOF | OpCode::NEG | OpCode::UNARY_PLUS | OpCode::BIT_NOT => {
|
||||
match inst.a {
|
||||
Operand::Reg(x) => known
|
||||
.get(x as usize)
|
||||
.and_then(|c| c.as_ref())
|
||||
.and_then(|c| fold_table::fold_unary(inst.op, c)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
OpCode::NOT | OpCode::TYPEOF | OpCode::NEG | OpCode::UNARY_PLUS | OpCode::BIT_NOT => match inst.a {
|
||||
Operand::Reg(x) => known
|
||||
.get(x as usize)
|
||||
.and_then(|c| c.as_ref())
|
||||
.and_then(|c| fold_table::fold_unary(inst.op, c)),
|
||||
_ => None,
|
||||
},
|
||||
// 二元算术:两操作数须为已知寄存器。
|
||||
OpCode::ADD | OpCode::SUB | OpCode::MUL | OpCode::DIV | OpCode::MOD | OpCode::EXP => {
|
||||
match (inst.a, inst.b) {
|
||||
|
||||
@@ -328,10 +328,7 @@ fn fold_add_bigint() {
|
||||
#[test]
|
||||
fn fold_add_bigint_mixed_not_folded() {
|
||||
// 1n + 1 BigInt 混合 → 不折(运行期抛 TypeError)。
|
||||
let (a, b) = (
|
||||
Constant::BigInt(num_bigint::BigInt::from(1)),
|
||||
Constant::Int(1),
|
||||
);
|
||||
let (a, b) = (Constant::BigInt(num_bigint::BigInt::from(1)), Constant::Int(1));
|
||||
let mut f = func(
|
||||
&[a, b],
|
||||
vec![
|
||||
|
||||
Reference in New Issue
Block a user