Struct CompileContext

Source
#[non_exhaustive]
pub struct CompileContext { pub nfa: NFA, pub config: Config, pub sections: Sections, state_id_layout: Layout, }
Expand description

This struct contains all the input and intermediate state needed to compile the WASM module.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§nfa: NFA§config: Config§sections: Sections§state_id_layout: Layout

Implementations§

Source§

impl CompileContext

Source

pub fn new(nfa: NFA, config: Config) -> Self

Creates a new CompileContext with the given NFA and configuration.

Source

pub fn add_function(&mut self, func: Function) -> FunctionIdx

Declare and define a function.

Source

pub fn declare_function(&mut self, sig: FunctionSignature) -> FunctionIdx

Declares a function’s signature (name, parameters, return types, export status).

This adds entries to the Type, Function, and potentially Export sections. A FunctionIdx is returned, which should be used later to provide the definition.

Source

pub fn define_function( &mut self, func_idx: FunctionIdx, def: FunctionDefinition, )

Defines a previously declared function.

The func_idx must correspond to a function previously returned by declare_function. The definition includes the body, local names, label names, and branch hints.

Source

pub fn add_block_signature(&mut self, signature: BlockSignature) -> TypeIdx

Adds a block signature to the type section.

This is used for block types in control flow instructions.

Source

pub fn state_id_layout(&self) -> &Layout

Return the minimal layout for a state ID for the current NFA.

This function will minimize the size of the state ID layout based on the number of states in the current NFA.

Source

fn compute_state_id_layout(nfa: &NFA) -> Layout

Source§

impl CompileContext

Source

pub fn compile(self, state_overall: &Layout) -> Module

This function takes all the individual settings/functions/data segments/layouts and compiles them into a single WASM [Module].

Trait Implementations§

Source§

impl Debug for CompileContext

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.