feat: 添加严格比较运算符与一元加法

This commit is contained in:
2026-06-06 20:08:10 +08:00
parent bbd6c6396d
commit 87a7224c2d
7 changed files with 263 additions and 0 deletions
+7
View File
@@ -399,6 +399,8 @@ impl Compiler {
BinaryOperator::LessEqualThan => OpCode::LTE,
BinaryOperator::GreaterEqualThan => OpCode::GTE,
BinaryOperator::In => OpCode::IN,
BinaryOperator::StrictEquality => OpCode::STRICT_EQ,
BinaryOperator::StrictInequality => OpCode::STRICT_NEQ,
_ => return Err(format!("unsupported binary operator: {:?}", bin.operator)),
};
let r = ctx.alloc_reg();
@@ -428,6 +430,11 @@ impl Compiler {
ctx.emit(opcode::encode(OpCode::NOT, r, arg, 0));
Ok(r)
}
UnaryOperator::UnaryPlus => {
let r = ctx.alloc_reg();
ctx.emit(opcode::encode(OpCode::UNARY_PLUS, r, arg, 0));
Ok(r)
}
_ => Err(format!("unsupported unary operator: {:?}", un.operator)),
}
}