Emits the necessary POP instructions for all failure targets in the pattern context, then resets the fail_pop vector.
(&mut self, pc: &mut PatternContext)
| 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<()> { |
no test coverage detected