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

Function compute_predecessors

crates/codegen/src/ir.rs:2694–2721  ·  view source on GitHub ↗
(blocks: &[Block])

Source from the content-addressed store, hash-verified

2692}
2693
2694fn compute_predecessors(blocks: &[Block]) -> Vec<u32> {
2695 let mut predecessors = vec![0u32; blocks.len()];
2696 if blocks.is_empty() {
2697 return predecessors;
2698 }
2699
2700 predecessors[0] = 1;
2701 let mut current = BlockIdx(0);
2702 while current != BlockIdx::NULL {
2703 let block = &blocks[current.idx()];
2704 if block_has_fallthrough(block) {
2705 let next = next_nonempty_block(blocks, block.next);
2706 if next != BlockIdx::NULL {
2707 predecessors[next.idx()] += 1;
2708 }
2709 }
2710 for ins in &block.instructions {
2711 if ins.target != BlockIdx::NULL {
2712 let target = next_nonempty_block(blocks, ins.target);
2713 if target != BlockIdx::NULL {
2714 predecessors[target.idx()] += 1;
2715 }
2716 }
2717 }
2718 current = block.next;
2719 }
2720 predecessors
2721}
2722
2723fn duplicate_exits_without_lineno(blocks: &mut Vec<Block>, predecessors: &mut Vec<u32>) {
2724 let mut current = BlockIdx(0);

Callers 1

resolve_line_numbersFunction · 0.85

Calls 5

BlockIdxClass · 0.85
block_has_fallthroughFunction · 0.85
next_nonempty_blockFunction · 0.85
idxMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected