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

Method compile_addcompare

crates/codegen/src/compile.rs:6885–6921  ·  view source on GitHub ↗

[CPython `compiler_addcompare`](https://github.com/python/cpython/blob/627894459a84be3488a1789919679c997056a03c/Python/compile.c#L2880-L2924)

(&mut self, op: &ast::CmpOp)

Source from the content-addressed store, hash-verified

6883
6884 /// [CPython `compiler_addcompare`](https://github.com/python/cpython/blob/627894459a84be3488a1789919679c997056a03c/Python/compile.c#L2880-L2924)
6885 fn compile_addcompare(&mut self, op: &ast::CmpOp) {
6886 use bytecode::ComparisonOperator::*;
6887 match op {
6888 ast::CmpOp::Eq => emit!(self, Instruction::CompareOp { opname: Equal }),
6889 ast::CmpOp::NotEq => emit!(self, Instruction::CompareOp { opname: NotEqual }),
6890 ast::CmpOp::Lt => emit!(self, Instruction::CompareOp { opname: Less }),
6891 ast::CmpOp::LtE => emit!(
6892 self,
6893 Instruction::CompareOp {
6894 opname: LessOrEqual
6895 }
6896 ),
6897 ast::CmpOp::Gt => emit!(self, Instruction::CompareOp { opname: Greater }),
6898 ast::CmpOp::GtE => {
6899 emit!(
6900 self,
6901 Instruction::CompareOp {
6902 opname: GreaterOrEqual
6903 }
6904 )
6905 }
6906 ast::CmpOp::In => emit!(self, Instruction::ContainsOp { invert: Invert::No }),
6907 ast::CmpOp::NotIn => emit!(
6908 self,
6909 Instruction::ContainsOp {
6910 invert: Invert::Yes
6911 }
6912 ),
6913 ast::CmpOp::Is => emit!(self, Instruction::IsOp { invert: Invert::No }),
6914 ast::CmpOp::IsNot => emit!(
6915 self,
6916 Instruction::IsOp {
6917 invert: Invert::Yes
6918 }
6919 ),
6920 }
6921 }
6922
6923 /// Compile a chained comparison.
6924 ///

Callers 2

compile_compareMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected