fn add_locals(cfg: &mut CFG, rng: &mut StdRng, locals: &[SignatureToken], args_len: usize) {
        precondition!(
            !cfg.basic_blocks.is_empty(),
            "Cannot add locals to empty cfg"
        );
        debug!("add locals: {:#?}", locals);
        for block_id in 0..cfg.basic_blocks.len() {
            let cfg_copy = cfg.clone();
            let basic_block = cfg
                .basic_blocks
                .get_mut(&(block_id as BlockIDSize))
                .unwrap();
            if cfg_copy.num_parents(block_id as BlockIDSize) == 0 {
                basic_block.locals_in = locals
                    .iter()
                    .enumerate()
                    .map(|(i, token)| {
                        let borrow_state = if i < args_len {
                            BorrowState::Available
                        } else {
                            BorrowState::Unavailable
                        };
                        (
                            i,
                            (
                                AbstractValue::new_value(token.clone(), AbilitySet::PRIMITIVES),
                                borrow_state,
                            ),
                        )
                    })
                    .collect();
            } else {
                // Implication of precondition
                assume!(!cfg_copy.basic_blocks.is_empty());
                basic_block.locals_in =
                    cfg_copy.merge_locals(cfg_copy.get_parent_ids(block_id as BlockIDSize));
            }
            basic_block.locals_out = CFG::vary_locals(rng, basic_block.locals_in.clone());
        }
    }
/// Add the incoming and outgoing locals for each basic block in the control flow graph.
/// Currently the incoming and outgoing locals are the same for each block.
Add the incoming and outgoing locals for each basic block in the control flow graph.
Currently the incoming and outgoing locals are the same for each block.
Add the incoming and outgoing locals for each basic block in the control flow graph . Currently the incoming and outgoing locals are the same for each block .
fn add_locals(cfg: &mut CFG, rng: &mut StdRng, locals: &[SignatureToken], args_len: usize) {
        precondition!(
            !cfg.basic_blocks.is_empty(),
            "Cannot add locals to empty cfg"
        );
        debug!("add locals: {:#?}", locals);
        for block_id in 0..cfg.basic_blocks.len() {
            let cfg_copy = cfg.clone();
            let basic_block = cfg
                .basic_blocks
                .get_mut(&(block_id as BlockIDSize))
                .unwrap();
            if cfg_copy.num_parents(block_id as BlockIDSize) == 0 {
                basic_block.locals_in = locals
                    .iter()
                    .enumerate()
                    .map(|(i, token)| {
                        let borrow_state = if i < args_len {
                            BorrowState::Available
                        } else {
                            BorrowState::Unavailable
                        };
                        (
                            i,
                            (
                                AbstractValue::new_value(token.clone(), AbilitySet::PRIMITIVES),
                                borrow_state,
                            ),
                        )
                    })
                    .collect();
            } else {
                // Implication of precondition
                assume!(!cfg_copy.basic_blocks.is_empty());
                basic_block.locals_in =
                    cfg_copy.merge_locals(cfg_copy.get_parent_ids(block_id as BlockIDSize));
            }
            basic_block.locals_out = CFG::vary_locals(rng, basic_block.locals_in.clone());
        }
    }
fn add_locals ( cfg : & mut CFG , rng : & mut StdRng , locals : & [ SignatureToken ] , args_len : usize ) { precondition ! ( cfg basic_blocks is_empty ( ) " " ) ; debug ! ( " " locals ) ; for block_id in 0 .. cfg . basic_blocks . len ( ) { let cfg_copy = cfg . clone ( ) ; let basic_block = cfg . basic_blocks . get_mut ( & ( block_id as BlockIDSize ) ) . unwrap ( ) ; if cfg_copy . num_parents ( block_id as BlockIDSize ) == 0 { basic_block . locals_in = locals . iter ( ) . enumerate ( ) . map ( | ( i , token ) | { let borrow_state = if i < args_len { BorrowState :: Available } else { BorrowState :: Unavailable } ; ( i , ( AbstractValue :: new_value ( token . clone ( ) , AbilitySet :: PRIMITIVES ) , borrow_state , ) , ) } ) . collect ( ) ; } else { // Implication of precondition assume ! ( cfg_copy basic_blocks is_empty ( ) ) ; basic_block . locals_in = cfg_copy . merge_locals ( cfg_copy . get_parent_ids ( block_id as BlockIDSize ) ) ; } basic_block . locals_out = CFG :: vary_locals ( rng , basic_block . locals_in . clone ( ) ) ; } }
Add the incoming and outgoing locals for each basic block in the control flow graph.
Add the incoming and outgoing locals for each basic block in the control flow graph .
cfg
&mut CFG
rng
&mut StdRng
locals
&[SignatureToken]
args_len
usize