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

Method emit_and_reset_fail_pop

crates/codegen/src/compile.rs:5949–5967  ·  view source on GitHub ↗

Emits the necessary POP instructions for all failure targets in the pattern context, then resets the fail_pop vector.

(&mut self, pc: &mut PatternContext)

Source from the content-addressed store, hash-verified

5947 /// Emits the necessary POP instructions for all failure targets in the pattern context,
5948 /// then resets the fail_pop vector.
5949 fn emit_and_reset_fail_pop(&mut self, pc: &mut PatternContext) -> CompileResult<()> {
5950 // If the fail_pop vector is empty, nothing needs to be done.
5951 if pc.fail_pop.is_empty() {
5952 debug_assert!(pc.fail_pop.is_empty());
5953 return Ok(());
5954 }
5955 // Iterate over the fail_pop vector in reverse order, skipping the first label.
5956 for &label in pc.fail_pop.iter().skip(1).rev() {
5957 self.switch_to_block(label);
5958 // Emit the POP instruction.
5959 emit!(self, Instruction::PopTop);
5960 }
5961 // Finally, use the first label.
5962 self.switch_to_block(pc.fail_pop[0]);
5963 pc.fail_pop.clear();
5964 // Free the memory used by the vector.
5965 pc.fail_pop.shrink_to_fit();
5966 Ok(())
5967 }
5968
5969 /// Duplicate the effect of Python 3.10's ROT_* instructions using SWAPs.
5970 fn pattern_helper_rotate(&mut self, mut count: usize) -> CompileResult<()> {

Callers 2

compile_pattern_orMethod · 0.80
compile_match_innerMethod · 0.80

Calls 7

switch_to_blockMethod · 0.80
shrink_to_fitMethod · 0.80
is_emptyMethod · 0.45
revMethod · 0.45
skipMethod · 0.45
iterMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected