diff --git a/src/back/msl.rs b/src/back/msl.rs index 4152245b6e..a5460c7b31 100644 --- a/src/back/msl.rs +++ b/src/back/msl.rs @@ -420,10 +420,17 @@ impl Writer { ref other => panic!("Unexpected load pointer {:?}", other), } } - crate::Expression::Mul(left, right) => { + crate::Expression::Binary { op, left, right } => { + let op_ch = match op { + crate::BinaryOperator::Add => '+', + crate::BinaryOperator::Multiply => '*', + crate::BinaryOperator::Divide => '/', + crate::BinaryOperator::Modulo => '%', + _ => panic!("Unsupported binary op {:?}", op), + }; write!(self.out, "(")?; let ty_left = self.put_expression(left, expressions, module)?; - write!(self.out, " * ")?; + write!(self.out, " {} ", op_ch)?; let ty_right = self.put_expression(right, expressions, module)?; write!(self.out, ")")?; Ok(match (ty_left.borrow(), ty_right.borrow()) { diff --git a/src/front/spirv.rs b/src/front/spirv.rs index 4c6904ea67..a0b9d4d4b6 100644 --- a/src/front/spirv.rs +++ b/src/front/spirv.rs @@ -577,7 +577,11 @@ impl> Parser { crate::TypeInner::Scalar { kind: crate::ScalarKind::Float, width } if width == res_width => (), _ => return Err(Error::UnsupportedType(scalar_type_lookup.handle)), }; - let expr = crate::Expression::Mul(vector_lexp.handle, scalar_lexp.handle); + let expr = crate::Expression::Binary { + op: crate::BinaryOperator::Multiply, + left: vector_lexp.handle, + right: scalar_lexp.handle, + }; self.lookup_expression.insert(result_id, LookupExpression { handle: fun.expressions.append(expr), type_id: result_type_id, @@ -606,7 +610,11 @@ impl> Parser { crate::TypeInner::Vector { size, kind: crate::ScalarKind::Float, width } if size == columns && width == res_width => (), _ => return Err(Error::UnsupportedType(vector_type_lookup.handle)), }; - let expr = crate::Expression::Mul(matrix_lexp.handle, vector_lexp.handle); + let expr = crate::Expression::Binary { + op: crate::BinaryOperator::Multiply, + left: matrix_lexp.handle, + right: vector_lexp.handle, + }; self.lookup_expression.insert(result_id, LookupExpression { handle: fun.expressions.append(expr), type_id: result_type_id, diff --git a/src/lib.rs b/src/lib.rs index 82b78745f1..ada6124734 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -197,7 +197,6 @@ pub enum Expression { Load { pointer: Handle, }, - Mul(Handle, Handle), ImageSample { image: Handle, sampler: Handle, diff --git a/src/proc/typifier.rs b/src/proc/typifier.rs index a1f08e79cc..700a6b32f9 100644 --- a/src/proc/typifier.rs +++ b/src/proc/typifier.rs @@ -65,7 +65,6 @@ impl Typifier { crate::Expression::GlobalVariable(h) => global_vars[h].ty, crate::Expression::LocalVariable(h) => local_vars[h].ty, crate::Expression::Load { .. } => unimplemented!(), - crate::Expression::Mul(_, _) => unimplemented!(), crate::Expression::ImageSample { .. } => unimplemented!(), crate::Expression::Unary { expr, .. } => self.types[expr.index()], crate::Expression::Binary { op, left, right } => {