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

Function propagate_line_numbers

crates/codegen/src/ir.rs:2790–2835  ·  view source on GitHub ↗
(blocks: &mut [Block], predecessors: &[u32])

Source from the content-addressed store, hash-verified

2788}
2789
2790fn propagate_line_numbers(blocks: &mut [Block], predecessors: &[u32]) {
2791 let mut current = BlockIdx(0);
2792 while current != BlockIdx::NULL {
2793 let last = blocks[current.idx()].instructions.last().copied();
2794 if let Some(last) = last {
2795 let (next_block, has_fallthrough) = {
2796 let block = &blocks[current.idx()];
2797 (block.next, block_has_fallthrough(block))
2798 };
2799
2800 {
2801 let block = &mut blocks[current.idx()];
2802 let mut prev_location = None;
2803 for instr in &mut block.instructions {
2804 if let Some((location, end_location)) = prev_location {
2805 maybe_propagate_location(instr, location, end_location);
2806 }
2807 prev_location = Some((instr.location, instr.end_location));
2808 }
2809 }
2810
2811 if has_fallthrough {
2812 let target = next_nonempty_block(blocks, next_block);
2813 if target != BlockIdx::NULL && predecessors[target.idx()] == 1 {
2814 propagate_locations_in_block(
2815 &mut blocks[target.idx()],
2816 last.location,
2817 last.end_location,
2818 );
2819 }
2820 }
2821
2822 if is_jump_instruction(&last) {
2823 let target = next_nonempty_block(blocks, last.target);
2824 if target != BlockIdx::NULL && predecessors[target.idx()] == 1 {
2825 propagate_locations_in_block(
2826 &mut blocks[target.idx()],
2827 last.location,
2828 last.end_location,
2829 );
2830 }
2831 }
2832 }
2833 current = blocks[current.idx()].next;
2834 }
2835}
2836
2837fn resolve_line_numbers(blocks: &mut Vec<Block>) {
2838 let mut predecessors = compute_predecessors(blocks);

Callers 1

resolve_line_numbersFunction · 0.85

Calls 9

BlockIdxClass · 0.85
block_has_fallthroughFunction · 0.85
maybe_propagate_locationFunction · 0.85
next_nonempty_blockFunction · 0.85
is_jump_instructionFunction · 0.85
idxMethod · 0.80
SomeClass · 0.50
lastMethod · 0.45

Tested by

no test coverage detected