fn candidate_instructions(
        &mut self,
        state: AbstractState,
        locals_len: usize,
        module: CompiledModuleMut,
    ) -> Vec<(StackEffect, Bytecode)> {
        let mut matches: Vec<(StackEffect, Bytecode)> = Vec::new();
        let instructions = &self.instructions;
        for (stack_effect, instruction) in instructions.iter() {
            let instruction: Bytecode = match instruction {
                BytecodeType::NoArg(instruction) => instruction.clone(),
                BytecodeType::LocalIndex(instruction) => {
                    // Generate a random index into the locals
                    if locals_len > 0 {
                        instruction(self.rng.gen_range(0, locals_len) as LocalIndex)
                    } else {
                        instruction(0)
                    }
                }
                BytecodeType::CodeOffset(instruction) => {
                    // Set 0 as the offset. This will be set correctly during serialization
                    instruction(0)
                }
                BytecodeType::U64(instruction) => {
                    // Generate a random u64 constant to load
                    instruction(self.rng.gen_range(0, u64::max_value()))
                }
                BytecodeType::UserStringIndex(instruction) => {
                    // Select a random user string
                    instruction(UserStringIndex::new(
                        self.rng.gen_range(0, module.user_strings.len()) as TableIndex,
                    ))
                }
                BytecodeType::AddressPoolIndex(instruction) => {
                    // Select a random address from the module's address pool
                    instruction(AddressPoolIndex::new(
                        self.rng.gen_range(0, module.address_pool.len()) as TableIndex,
                    ))
                }
                BytecodeType::ByteArrayPoolIndex(instruction) => {
                    // Select a random byte array from the module's byte array pool
                    instruction(ByteArrayPoolIndex::new(
                        self.rng.gen_range(0, module.byte_array_pool.len()) as TableIndex,
                    ))
                }
                BytecodeType::StructAndLocalIndex(instruction) => {
                    // Select a random struct definition and local signature
                    instruction(
                        StructDefinitionIndex::new(
                            self.rng.gen_range(0, module.struct_defs.len()) as TableIndex
                        ),
                        LocalsSignatureIndex::new(
                            self.rng.gen_range(0, module.locals_signatures.len()) as TableIndex,
                        ),
                    )
                }
                BytecodeType::FieldDefinitionIndex(instruction) => {
                    // Select a field definition from the module's field definitions
                    instruction(FieldDefinitionIndex::new(
                        self.rng.gen_range(0, module.field_defs.len()) as TableIndex,
                    ))
                }
                BytecodeType::FunctionAndLocalIndex(instruction) => {
                    // Select a random function handle and local signature
                    instruction(
                        FunctionHandleIndex::new(
                            self.rng.gen_range(0, module.function_handles.len()) as TableIndex,
                        ),
                        LocalsSignatureIndex::new(
                            self.rng.gen_range(0, module.locals_signatures.len()) as TableIndex,
                        ),
                    )
                }
            };
            let summary = summaries::instruction_summary(instruction.clone());
            let unsatisfied_preconditions = summary
                .preconditions
                .iter()
                .filter(|precondition| !precondition(&state))
                .count();
            if (NEGATE_PRECONDITIONS
                && !summary.preconditions.is_empty()
                && unsatisfied_preconditions > self.rng.gen_range(0, summary.preconditions.len())
                && self.rng.gen_range(0, 101) > 100 - (NEGATION_PROBABILITY * 100.0) as u8)
                || unsatisfied_preconditions == 0
            {
                // The size of matches cannot be greater than the number of bytecode instructions
                verify!(matches.len() < usize::max_value());
                matches.push((*stack_effect, instruction));
            }
        }
        matches
    }
/// Given an `AbstractState`, `state`, and a the number of locals the function has,
/// this function returns a list of instructions whose preconditions are satisfied for
/// the state.
Given an `AbstractState`, `state`, and a the number of locals the function has,
this function returns a list of instructions whose preconditions are satisfied for
the state.
Given an ` AbstractState ` ` state ` and a the number of locals the function has this function returns a list of instructions whose preconditions are satisfied for the state .
fn candidate_instructions(
        &mut self,
        state: AbstractState,
        locals_len: usize,
        module: CompiledModuleMut,
    ) -> Vec<(StackEffect, Bytecode)> {
        let mut matches: Vec<(StackEffect, Bytecode)> = Vec::new();
        let instructions = &self.instructions;
        for (stack_effect, instruction) in instructions.iter() {
            let instruction: Bytecode = match instruction {
                BytecodeType::NoArg(instruction) => instruction.clone(),
                BytecodeType::LocalIndex(instruction) => {
                    // Generate a random index into the locals
                    if locals_len > 0 {
                        instruction(self.rng.gen_range(0, locals_len) as LocalIndex)
                    } else {
                        instruction(0)
                    }
                }
                BytecodeType::CodeOffset(instruction) => {
                    // Set 0 as the offset. This will be set correctly during serialization
                    instruction(0)
                }
                BytecodeType::U64(instruction) => {
                    // Generate a random u64 constant to load
                    instruction(self.rng.gen_range(0, u64::max_value()))
                }
                BytecodeType::UserStringIndex(instruction) => {
                    // Select a random user string
                    instruction(UserStringIndex::new(
                        self.rng.gen_range(0, module.user_strings.len()) as TableIndex,
                    ))
                }
                BytecodeType::AddressPoolIndex(instruction) => {
                    // Select a random address from the module's address pool
                    instruction(AddressPoolIndex::new(
                        self.rng.gen_range(0, module.address_pool.len()) as TableIndex,
                    ))
                }
                BytecodeType::ByteArrayPoolIndex(instruction) => {
                    // Select a random byte array from the module's byte array pool
                    instruction(ByteArrayPoolIndex::new(
                        self.rng.gen_range(0, module.byte_array_pool.len()) as TableIndex,
                    ))
                }
                BytecodeType::StructAndLocalIndex(instruction) => {
                    // Select a random struct definition and local signature
                    instruction(
                        StructDefinitionIndex::new(
                            self.rng.gen_range(0, module.struct_defs.len()) as TableIndex
                        ),
                        LocalsSignatureIndex::new(
                            self.rng.gen_range(0, module.locals_signatures.len()) as TableIndex,
                        ),
                    )
                }
                BytecodeType::FieldDefinitionIndex(instruction) => {
                    // Select a field definition from the module's field definitions
                    instruction(FieldDefinitionIndex::new(
                        self.rng.gen_range(0, module.field_defs.len()) as TableIndex,
                    ))
                }
                BytecodeType::FunctionAndLocalIndex(instruction) => {
                    // Select a random function handle and local signature
                    instruction(
                        FunctionHandleIndex::new(
                            self.rng.gen_range(0, module.function_handles.len()) as TableIndex,
                        ),
                        LocalsSignatureIndex::new(
                            self.rng.gen_range(0, module.locals_signatures.len()) as TableIndex,
                        ),
                    )
                }
            };
            let summary = summaries::instruction_summary(instruction.clone());
            let unsatisfied_preconditions = summary
                .preconditions
                .iter()
                .filter(|precondition| !precondition(&state))
                .count();
            if (NEGATE_PRECONDITIONS
                && !summary.preconditions.is_empty()
                && unsatisfied_preconditions > self.rng.gen_range(0, summary.preconditions.len())
                && self.rng.gen_range(0, 101) > 100 - (NEGATION_PROBABILITY * 100.0) as u8)
                || unsatisfied_preconditions == 0
            {
                // The size of matches cannot be greater than the number of bytecode instructions
                verify!(matches.len() < usize::max_value());
                matches.push((*stack_effect, instruction));
            }
        }
        matches
    }
fn candidate_instructions ( & mut self , state : AbstractState , locals_len : usize , module : CompiledModuleMut , ) -> Vec < ( StackEffect , Bytecode ) > { let mut matches : Vec < ( StackEffect , Bytecode ) > = Vec :: new ( ) ; let instructions = & self . instructions ; for ( stack_effect , instruction ) in instructions . iter ( ) { let instruction : Bytecode = match instruction { BytecodeType :: NoArg ( instruction ) => instruction . clone ( ) , BytecodeType :: LocalIndex ( instruction ) => { // Generate a random index into the locals if locals_len > 0 { instruction ( self . rng . gen_range ( 0 , locals_len ) as LocalIndex ) } else { instruction ( 0 ) } } BytecodeType :: CodeOffset ( instruction ) => { // Set 0 as the offset. This will be set correctly during serialization instruction ( 0 ) } BytecodeType :: U64 ( instruction ) => { // Generate a random u64 constant to load instruction ( self . rng . gen_range ( 0 , u64 :: max_value ( ) ) ) } BytecodeType :: UserStringIndex ( instruction ) => { // Select a random user string instruction ( UserStringIndex :: new ( self . rng . gen_range ( 0 , module . user_strings . len ( ) ) as TableIndex , ) ) } BytecodeType :: AddressPoolIndex ( instruction ) => { // Select a random address from the module's address pool instruction ( AddressPoolIndex :: new ( self . rng . gen_range ( 0 , module . address_pool . len ( ) ) as TableIndex , ) ) } BytecodeType :: ByteArrayPoolIndex ( instruction ) => { // Select a random byte array from the module's byte array pool instruction ( ByteArrayPoolIndex :: new ( self . rng . gen_range ( 0 , module . byte_array_pool . len ( ) ) as TableIndex , ) ) } BytecodeType :: StructAndLocalIndex ( instruction ) => { // Select a random struct definition and local signature instruction ( StructDefinitionIndex :: new ( self . rng . gen_range ( 0 , module . struct_defs . len ( ) ) as TableIndex ) , LocalsSignatureIndex :: new ( self . rng . gen_range ( 0 , module . locals_signatures . len ( ) ) as TableIndex , ) , ) } BytecodeType :: FieldDefinitionIndex ( instruction ) => { // Select a field definition from the module's field definitions instruction ( FieldDefinitionIndex :: new ( self . rng . gen_range ( 0 , module . field_defs . len ( ) ) as TableIndex , ) ) } BytecodeType :: FunctionAndLocalIndex ( instruction ) => { // Select a random function handle and local signature instruction ( FunctionHandleIndex :: new ( self . rng . gen_range ( 0 , module . function_handles . len ( ) ) as TableIndex , ) , LocalsSignatureIndex :: new ( self . rng . gen_range ( 0 , module . locals_signatures . len ( ) ) as TableIndex , ) , ) } } ; let summary = summaries :: instruction_summary ( instruction . clone ( ) ) ; let unsatisfied_preconditions = summary . preconditions . iter ( ) . filter ( | precondition | ! precondition ( & state ) ) . count ( ) ; if ( NEGATE_PRECONDITIONS && ! summary . preconditions . is_empty ( ) && unsatisfied_preconditions > self . rng . gen_range ( 0 , summary . preconditions . len ( ) ) && self . rng . gen_range ( 0 , 101 ) > 100 - ( NEGATION_PROBABILITY * 100.0 ) as u8 ) || unsatisfied_preconditions == 0 { // The size of matches cannot be greater than the number of bytecode instructions verify ! ( matches len ( ) usize max_value ( ) ) ; matches . push ( ( * stack_effect , instruction ) ) ; } } matches }
Given an `AbstractState`, `state`, and a the number of locals the function has,
this function returns a list of instructions whose preconditions are satisfied for
the state.
Given an ` AbstractState ` ` state ` and a the number of locals the function has this function returns a list of instructions whose preconditions are satisfied for the state .
&mut self
state
AbstractState
locals_len
usize
module
CompiledModuleMut