pub struct BytecodeGenerator<'a> { /* private fields */ }
Expand description
Generates a sequence of bytecode instructions. This generator has:
instructions
: A list of bytecode instructions to use for generationrng
: A random number generator for uniform random choice of next instruction
Implementations§
source§impl<'a> BytecodeGenerator<'a>
impl<'a> BytecodeGenerator<'a>
sourcepub fn new(rng: &'a mut StdRng) -> Self
pub fn new(rng: &'a mut StdRng) -> Self
The BytecodeGenerator
is instantiated with a seed to use with
its random number generator.
sourcepub fn apply_instruction(
&self,
fn_context: &mut FunctionGenerationContext,
state: AbstractState,
bytecode: &mut Vec<Bytecode>,
instruction: Bytecode,
exact: bool
) -> Option<AbstractState>
pub fn apply_instruction( &self, fn_context: &mut FunctionGenerationContext, state: AbstractState, bytecode: &mut Vec<Bytecode>, instruction: Bytecode, exact: bool ) -> Option<AbstractState>
Transition an abstract state, state
to the next state and add the instruction
to the bytecode sequence
sourcepub fn generate_block(
&mut self,
fn_context: &mut FunctionGenerationContext,
abstract_state_in: AbstractState,
abstract_state_out: AbstractState,
module: &CompiledModule
) -> Option<(Vec<Bytecode>, AbstractState)>
pub fn generate_block( &mut self, fn_context: &mut FunctionGenerationContext, abstract_state_in: AbstractState, abstract_state_out: AbstractState, module: &CompiledModule ) -> Option<(Vec<Bytecode>, AbstractState)>
Given a valid starting state abstract_state_in
, generate a valid sequence of
bytecode instructions such that abstract_state_out
is reached.
sourcepub fn generate(
&mut self,
fn_context: &mut FunctionGenerationContext,
locals: &[SignatureToken],
fh: &FunctionHandle,
acquires_global_resources: &[StructDefinitionIndex],
module: &mut CompiledModule,
call_graph: &mut CallGraph
) -> Option<Vec<Bytecode>>
pub fn generate( &mut self, fn_context: &mut FunctionGenerationContext, locals: &[SignatureToken], fh: &FunctionHandle, acquires_global_resources: &[StructDefinitionIndex], module: &mut CompiledModule, call_graph: &mut CallGraph ) -> Option<Vec<Bytecode>>
Generate the body of a function definition given a set of starting locals
and a target
return signature
. The sequence should contain at least target_min
and at most
target_max
instructions.
pub fn generate_module( &mut self, module: CompiledModule ) -> Option<CompiledModule>
sourcepub fn inhabit_with_bytecode_seq(
module: &mut InstantiableModule,
token: &SignatureToken
) -> Vec<Bytecode> ⓘ
pub fn inhabit_with_bytecode_seq( module: &mut InstantiableModule, token: &SignatureToken ) -> Vec<Bytecode> ⓘ
Generate a sequence of instructions whose overall effect is to push a single value of type token on the stack, specifically without consuming any values that existed on the stack prior to the execution of the instruction sequence.