mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-16 07:28:52 +00:00
Fix ir interp
This commit is contained in:
@@ -545,13 +545,22 @@ mod calculator {
|
|||||||
rhs: OrderedFloat<f64>,
|
rhs: OrderedFloat<f64>,
|
||||||
width: usize,
|
width: usize,
|
||||||
) -> Result<Value, ()> {
|
) -> Result<Value, ()> {
|
||||||
|
let (lhs, rhs) = if width == Dtype::SIZE_OF_FLOAT * Dtype::BITS_OF_BYTE {
|
||||||
|
(
|
||||||
|
lhs.into_inner() as f32 as f64,
|
||||||
|
rhs.into_inner() as f32 as f64,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(lhs.into_inner(), rhs.into_inner())
|
||||||
|
};
|
||||||
|
|
||||||
let result = match op {
|
let result = match op {
|
||||||
ast::BinaryOperator::Plus => lhs.into_inner() + rhs.into_inner(),
|
ast::BinaryOperator::Plus => lhs + rhs,
|
||||||
ast::BinaryOperator::Minus => lhs.into_inner() - rhs.into_inner(),
|
ast::BinaryOperator::Minus => lhs - rhs,
|
||||||
ast::BinaryOperator::Multiply => lhs.into_inner() * rhs.into_inner(),
|
ast::BinaryOperator::Multiply => lhs * rhs,
|
||||||
ast::BinaryOperator::Divide => {
|
ast::BinaryOperator::Divide => {
|
||||||
assert!(rhs.into_inner() != 0.0);
|
assert!(rhs != 0.0);
|
||||||
lhs.into_inner() / rhs.into_inner()
|
lhs / rhs
|
||||||
}
|
}
|
||||||
ast::BinaryOperator::Equals => {
|
ast::BinaryOperator::Equals => {
|
||||||
let order = lhs
|
let order = lhs
|
||||||
|
|||||||
Reference in New Issue
Block a user