mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Formatted code files
This commit is contained in:
@@ -449,27 +449,33 @@ impl<'a, 'b> FunctionCompiler<'a, 'b> {
|
||||
}
|
||||
|
||||
// Floats and Integers
|
||||
(_, JitValue::Int(a), JitValue::Float(b)) |
|
||||
(_, JitValue::Float(a), JitValue::Int(b)) =>{
|
||||
|
||||
(_, JitValue::Int(a), JitValue::Float(b))
|
||||
| (_, JitValue::Float(a), JitValue::Int(b)) => {
|
||||
let operand_one = match a_type.unwrap() {
|
||||
JitType::Int => self.builder.ins().fcvt_from_sint(types::F64, a),
|
||||
_=> a
|
||||
_ => a,
|
||||
};
|
||||
|
||||
let operand_two = match b_type.unwrap() {
|
||||
JitType::Int => self.builder.ins().fcvt_from_sint(types::F64, b),
|
||||
_=> b
|
||||
_ => b,
|
||||
};
|
||||
|
||||
match op{
|
||||
BinaryOperator::Add => JitValue::Float(self.builder.ins().fadd(operand_one, operand_two)),
|
||||
BinaryOperator::Subtract => JitValue::Float(self.builder.ins().fsub(operand_one, operand_two)),
|
||||
BinaryOperator::Multiply => JitValue::Float(self.builder.ins().fmul(operand_one, operand_two)),
|
||||
BinaryOperator::Divide => JitValue::Float(self.builder.ins().fdiv(operand_one, operand_two)),
|
||||
_ => return Err(JitCompileError::NotSupported)
|
||||
match op {
|
||||
BinaryOperator::Add => {
|
||||
JitValue::Float(self.builder.ins().fadd(operand_one, operand_two))
|
||||
}
|
||||
BinaryOperator::Subtract => {
|
||||
JitValue::Float(self.builder.ins().fsub(operand_one, operand_two))
|
||||
}
|
||||
BinaryOperator::Multiply => {
|
||||
JitValue::Float(self.builder.ins().fmul(operand_one, operand_two))
|
||||
}
|
||||
BinaryOperator::Divide => {
|
||||
JitValue::Float(self.builder.ins().fdiv(operand_one, operand_two))
|
||||
}
|
||||
_ => return Err(JitCompileError::NotSupported),
|
||||
}
|
||||
|
||||
}
|
||||
_ => return Err(JitCompileError::NotSupported),
|
||||
};
|
||||
|
||||
@@ -105,9 +105,9 @@ fn test_mul_with_integer() {
|
||||
assert_approx_eq!(mul(5.2, 2), Ok(10.4));
|
||||
assert_approx_eq!(mul(3.4, -1), Ok(-3.4));
|
||||
assert_bits_eq!(mul(1.0, 0), Ok(0.0f64));
|
||||
assert_bits_eq!(mul(-0.0,1), Ok(-0.0f64));
|
||||
assert_bits_eq!(mul(-0.0, 1), Ok(-0.0f64));
|
||||
assert_bits_eq!(mul(0.0, -1), Ok(-0.0f64));
|
||||
assert_bits_eq!(mul(-0.0,-1), Ok(0.0f64));
|
||||
assert_bits_eq!(mul(-0.0, -1), Ok(0.0f64));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user