MCPcopy Index your code
hub / github.com/RustPython/RustPython / compile_op

Method compile_op

crates/codegen/src/compile.rs:7313–7332  ·  view source on GitHub ↗
(&mut self, op: &ast::Operator, inplace: bool)

Source from the content-addressed store, hash-verified

7311 }
7312
7313 fn compile_op(&mut self, op: &ast::Operator, inplace: bool) {
7314 let bin_op = match op {
7315 ast::Operator::Add => BinaryOperator::Add,
7316 ast::Operator::Sub => BinaryOperator::Subtract,
7317 ast::Operator::Mult => BinaryOperator::Multiply,
7318 ast::Operator::MatMult => BinaryOperator::MatrixMultiply,
7319 ast::Operator::Div => BinaryOperator::TrueDivide,
7320 ast::Operator::FloorDiv => BinaryOperator::FloorDivide,
7321 ast::Operator::Mod => BinaryOperator::Remainder,
7322 ast::Operator::Pow => BinaryOperator::Power,
7323 ast::Operator::LShift => BinaryOperator::Lshift,
7324 ast::Operator::RShift => BinaryOperator::Rshift,
7325 ast::Operator::BitOr => BinaryOperator::Or,
7326 ast::Operator::BitXor => BinaryOperator::Xor,
7327 ast::Operator::BitAnd => BinaryOperator::And,
7328 };
7329
7330 let op = if inplace { bin_op.as_inplace() } else { bin_op };
7331 emit!(self, Instruction::BinaryOp { op })
7332 }
7333
7334 /// Implement boolean short circuit evaluation logic.
7335 /// https://en.wikipedia.org/wiki/Short-circuit_evaluation

Callers 2

compile_augassignMethod · 0.80
compile_expressionMethod · 0.80

Calls 1

as_inplaceMethod · 0.80

Tested by

no test coverage detected