pub fn new_backward(code: &[Bytecode], from_all_blocks: bool) -> Self {
        let blocks = Self::collect_blocks(code);
        let mut block_id_to_predecessors: Map<BlockId, Vec<BlockId>> =
            blocks.keys().map(|block_id| (*block_id, vec![])).collect();
        for (block_id, block) in &blocks {
            for succ_block_id in &block.successors {
                if from_all_blocks && *succ_block_id == DUMMY_EXIT {
                    continue;
                }
                let predecessors = &mut block_id_to_predecessors.get_mut(succ_block_id).unwrap();
                predecessors.push(*block_id);
            }
        }
        if from_all_blocks {
            let predecessors = &mut block_id_to_predecessors.get_mut(&DUMMY_EXIT).unwrap();
            blocks.keys().for_each(|block_id| {
                if *block_id != DUMMY_ENTRANCE && *block_id != DUMMY_EXIT {
                    predecessors.push(*block_id);
                }
            });
        }
        Self {
            entry_block_id: DUMMY_EXIT,
            blocks: block_id_to_predecessors
                .into_iter()
                .map(|(block_id, predecessors)| {
                    (
                        block_id,
                        Block {
                            successors: predecessors,
                            content: blocks[&block_id].content,
                        },
                    )
                })
                .collect(),
            backward: true,
        }
    }
/// If from_all_blocks is false, perform backward analysis only from blocks that may exit.
/// If from_all_blocks is true, perform backward analysis from all blocks.
If from_all_blocks is false, perform backward analysis only from blocks that may exit.
If from_all_blocks is true, perform backward analysis from all blocks.
If from_all_blocks is false perform backward analysis only from blocks that may exit . If from_all_blocks is true perform backward analysis from all blocks .
pub fn new_backward(code: &[Bytecode], from_all_blocks: bool) -> Self {
        let blocks = Self::collect_blocks(code);
        let mut block_id_to_predecessors: Map<BlockId, Vec<BlockId>> =
            blocks.keys().map(|block_id| (*block_id, vec![])).collect();
        for (block_id, block) in &blocks {
            for succ_block_id in &block.successors {
                if from_all_blocks && *succ_block_id == DUMMY_EXIT {
                    continue;
                }
                let predecessors = &mut block_id_to_predecessors.get_mut(succ_block_id).unwrap();
                predecessors.push(*block_id);
            }
        }
        if from_all_blocks {
            let predecessors = &mut block_id_to_predecessors.get_mut(&DUMMY_EXIT).unwrap();
            blocks.keys().for_each(|block_id| {
                if *block_id != DUMMY_ENTRANCE && *block_id != DUMMY_EXIT {
                    predecessors.push(*block_id);
                }
            });
        }
        Self {
            entry_block_id: DUMMY_EXIT,
            blocks: block_id_to_predecessors
                .into_iter()
                .map(|(block_id, predecessors)| {
                    (
                        block_id,
                        Block {
                            successors: predecessors,
                            content: blocks[&block_id].content,
                        },
                    )
                })
                .collect(),
            backward: true,
        }
    }
pub fn new_backward ( code : & [ Bytecode ] , from_all_blocks : bool ) -> Self { let blocks = Self :: collect_blocks ( code ) ; let mut block_id_to_predecessors : Map < BlockId , Vec < BlockId > > = blocks . keys ( ) . map ( | block_id | ( * block_id , vec ! [ ] ) ) . collect ( ) ; for ( block_id , block ) in & blocks { for succ_block_id in & block . successors { if from_all_blocks && * succ_block_id == DUMMY_EXIT { continue ; } let predecessors = & mut block_id_to_predecessors . get_mut ( succ_block_id ) . unwrap ( ) ; predecessors . push ( * block_id ) ; } } if from_all_blocks { let predecessors = & mut block_id_to_predecessors . get_mut ( & DUMMY_EXIT ) . unwrap ( ) ; blocks . keys ( ) . for_each ( | block_id | { if * block_id != DUMMY_ENTRANCE && * block_id != DUMMY_EXIT { predecessors . push ( * block_id ) ; } } ) ; } Self { entry_block_id : DUMMY_EXIT , blocks : block_id_to_predecessors . into_iter ( ) . map ( | ( block_id , predecessors ) | { ( block_id , Block { successors : predecessors , content : blocks [ & block_id ] . content , } , ) } ) . collect ( ) , backward : true , } }
If from_all_blocks is false, perform backward analysis only from blocks that may exit.
If from_all_blocks is false perform backward analysis only from blocks that may exit .
code
&[Bytecode]
from_all_blocks
bool