#[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
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
impl CompileContext
Sourcepub fn new(nfa: NFA, config: Config) -> Self
pub fn new(nfa: NFA, config: Config) -> Self
Creates a new CompileContext
with the given NFA and configuration.
Sourcepub fn add_function(&mut self, func: Function) -> FunctionIdx
pub fn add_function(&mut self, func: Function) -> FunctionIdx
Declare and define a function.
Sourcepub fn declare_function(&mut self, sig: FunctionSignature) -> FunctionIdx
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.
Sourcepub fn define_function(
&mut self,
func_idx: FunctionIdx,
def: FunctionDefinition,
)
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.
Sourcepub fn add_block_signature(&mut self, signature: BlockSignature) -> TypeIdx
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.
Sourcepub fn state_id_layout(&self) -> &Layout
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.