feat: 二元幂运算 opcode 支持 number 与 BigInt

- 新增 EXP opcode(0x94)与 emit 层 Exponential 分支,二元 a ** b 不再 compile error
- dispatch_exp 与 dispatch_compound_exp 共享 exp_result:IEEE-754 powf 快路径 +
  BigInt 幂(负/超 u32 指数 RangeError)+ 混合 BigInt/Number TypeError
- 复合 **= 补 BigInt 语义(此前走 f64 近似),与二元 ** 行为一致
This commit is contained in:
2026-08-15 21:17:49 +08:00
parent b706b8c506
commit c4961fae29
5 changed files with 125 additions and 8 deletions
+1 -1
View File
@@ -57,6 +57,7 @@ impl Emitter {
BinaryOperator::Multiplication => OpCode::MUL,
BinaryOperator::Division => OpCode::DIV,
BinaryOperator::Remainder => OpCode::MOD,
BinaryOperator::Exponential => OpCode::EXP,
BinaryOperator::BitwiseAnd => OpCode::BIT_AND,
BinaryOperator::BitwiseOR => OpCode::BIT_OR,
BinaryOperator::BitwiseXOR => OpCode::BIT_XOR,
@@ -73,7 +74,6 @@ impl Emitter {
BinaryOperator::Instanceof => OpCode::INSTANCEOF,
BinaryOperator::StrictEquality => OpCode::STRICT_EQ,
BinaryOperator::StrictInequality => OpCode::STRICT_NEQ,
_ => return Err(format!("unsupported binary operator: {:?}", bin.operator)),
};
ctx.inst(Inst::new(op, Operand::Reg(left), Operand::Reg(left), Operand::Reg(right)));
Ok(left)