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

Method jump_to_fail_pop

crates/codegen/src/compile.rs:5919–5945  ·  view source on GitHub ↗
(&mut self, pc: &mut PatternContext, op: JumpOp)

Source from the content-addressed store, hash-verified

5917 }
5918
5919 fn jump_to_fail_pop(&mut self, pc: &mut PatternContext, op: JumpOp) -> CompileResult<()> {
5920 // Compute the total number of items to pop:
5921 // items on top plus the captured objects.
5922 let pops = pc.on_top + pc.stores.len();
5923 // Ensure that the fail_pop vector has at least `pops + 1` elements.
5924 self.ensure_fail_pop(pc, pops)?;
5925 // Emit a jump using the jump target stored at index `pops`.
5926 match op {
5927 JumpOp::Jump => {
5928 emit!(
5929 self,
5930 PseudoInstruction::Jump {
5931 delta: pc.fail_pop[pops]
5932 }
5933 );
5934 }
5935 JumpOp::PopJumpIfFalse => {
5936 emit!(
5937 self,
5938 Instruction::PopJumpIfFalse {
5939 delta: pc.fail_pop[pops]
5940 }
5941 );
5942 }
5943 }
5944 Ok(())
5945 }
5946
5947 /// Emits the necessary POP instructions for all failure targets in the pattern context,
5948 /// then resets the fail_pop vector.

Callers 6

compile_pattern_classMethod · 0.80
compile_pattern_orMethod · 0.80
compile_pattern_valueMethod · 0.80

Calls 2

ensure_fail_popMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected