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

Method compile_pattern_singleton

crates/codegen/src/compile.rs:6747–6763  ·  view source on GitHub ↗
(
        &mut self,
        p: &ast::PatternMatchSingleton,
        pc: &mut PatternContext,
    )

Source from the content-addressed store, hash-verified

6745 }
6746
6747 fn compile_pattern_singleton(
6748 &mut self,
6749 p: &ast::PatternMatchSingleton,
6750 pc: &mut PatternContext,
6751 ) -> CompileResult<()> {
6752 // Load the singleton constant value.
6753 self.emit_load_const(match p.value {
6754 ast::Singleton::None => ConstantData::None,
6755 ast::Singleton::False => ConstantData::Boolean { value: false },
6756 ast::Singleton::True => ConstantData::Boolean { value: true },
6757 });
6758 // Compare using the "Is" operator.
6759 emit!(self, Instruction::IsOp { invert: Invert::No });
6760 // Jump to the failure label if the comparison is false.
6761 self.jump_to_fail_pop(pc, JumpOp::PopJumpIfFalse)?;
6762 Ok(())
6763 }
6764
6765 fn compile_pattern(
6766 &mut self,

Callers 1

compile_patternMethod · 0.80

Calls 2

emit_load_constMethod · 0.80
jump_to_fail_popMethod · 0.80

Tested by

no test coverage detected