MCPcopy Create free account
hub / github.com/dada-lang/dada / execute_binary_op

Method execute_binary_op

components/dada-codegen/src/cx/generate_expr.rs:226–244  ·  view source on GitHub ↗

Push the correct instructions to execute `binary_op` on operands of type `lhs_ty` and `rhs_ty`

(
        &mut self,
        binary_op: SymBinaryOp,
        lhs_ty: SymTy<'db>,
        rhs_ty: SymTy<'db>,
    )

Source from the content-addressed store, hash-verified

224
225 /// Push the correct instructions to execute `binary_op` on operands of type `lhs_ty` and `rhs_ty`
226 fn execute_binary_op(
227 &mut self,
228 binary_op: SymBinaryOp,
229 lhs_ty: SymTy<'db>,
230 rhs_ty: SymTy<'db>,
231 ) {
232 match self.primitive_kind(lhs_ty) {
233 Ok(prim_kind) => {
234 assert_eq!(self.primitive_kind(rhs_ty), Ok(prim_kind));
235 self.execute_binary_op_on_primitives(binary_op, prim_kind)
236 }
237 Err(e) => match e {
238 NotPrimitive::DeadCode => (),
239 NotPrimitive::OtherType => {
240 panic!("don't know how to execute a binary op on ({lhs_ty:?}, {rhs_ty:?})")
241 }
242 },
243 }
244 }
245
246 /// Push the correct instructions to execute `binary_op` on operands of type `prim_kind`
247 fn execute_binary_op_on_primitives(

Callers 1

push_exprMethod · 0.80

Calls 2

primitive_kindMethod · 0.80

Tested by

no test coverage detected