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 generation
  • rng: A random number generator for uniform random choice of next instruction

Implementations§

source§

impl<'a> BytecodeGenerator<'a>

source

pub fn new(rng: &'a mut StdRng) -> Self

The BytecodeGenerator is instantiated with a seed to use with its random number generator.

source

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

source

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.

source

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.

source

pub fn generate_module( &mut self, module: CompiledModule ) -> Option<CompiledModule>

source

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.

Trait Implementations§

source§

impl<'a> Debug for BytecodeGenerator<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for BytecodeGenerator<'a>

§

impl<'a> Send for BytecodeGenerator<'a>

§

impl<'a> Sync for BytecodeGenerator<'a>

§

impl<'a> Unpin for BytecodeGenerator<'a>

§

impl<'a> !UnwindSafe for BytecodeGenerator<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more