pub struct CompiledModuleStrategyGen { /* private fields */ }
Expand description

Contains configuration to generate CompiledModule instances.

If you don’t care about customizing these parameters, see CompiledModule::valid_strategy.

A CompiledModule can be looked at as a graph, with several kinds of nodes, and a nest of pointers among those nodes. This graph has some properties:

  1. The graph has cycles. Generating DAGs is often simpler, but is not an option in this case.
  2. The actual structure of the graph is well-defined in terms of the kinds of nodes and pointers that exist.

TODO: the graph also has pointers out of it, via address references to other modules. This doesn’t need to be handled when viewing modules in isolation, but some verification passes will need to look at the entire set of modules. The work to make generating such modules possible remains to be done.

Intermediate types

The pointers are represented as indexes into vectors of other kinds of nodes. One of the bigger problems is that the number of types, functions etc isn’t known upfront so it is impossible to know what range to pick from for the index types (ModuleHandleIndex, StructHandleIndex, etc). To deal with this, the code generates a bunch of intermediate structures (sometimes tuples, other times more complicated structures with their own internal constraints), with “holes” represented by Index instances. Once all the lengths are known, there’s a final “materialize” step at the end that “fills in” these holes.

One alternative would have been to generate lengths up front, then create vectors of those lengths. This would have worked fine for generation but would have made shrinking take much longer, because the shrinker would be less aware of the overall structure of the problem and would have ended up redoing a lot of work. The approach taken here does end up being more verbose but should perform optimally.

See proptest issue #130 for more discussion about this.

Implementations§

source§

impl CompiledModuleStrategyGen

source

pub fn new(size: TableSize) -> Self

Create a new configuration for randomly generating CompiledModule instances.

source

pub fn zeros_all(&mut self) -> &mut Self

Zero out all fields, type parameters, arguments and return types of struct and functions.

source

pub fn generate(self) -> impl Strategy<Value = CompiledModule>

Create a proptest strategy for CompiledModule instances using this configuration.

Trait Implementations§

source§

impl Clone for CompiledModuleStrategyGen

source§

fn clone(&self) -> CompiledModuleStrategyGen

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CompiledModuleStrategyGen

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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, 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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