pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule, E: Debug> {
// Required methods
fn new() -> Self;
fn new_with_target(
triple: Option<String>,
cpu_name: Option<String>,
cpu_features: Option<String>,
) -> Self;
fn backend_id() -> &'static str;
fn feed_import_function(&mut self, _sigindex: SigIndex) -> Result<(), E>;
fn feed_signatures(
&mut self,
signatures: Map<SigIndex, FuncSig>,
) -> Result<(), E>;
fn feed_function_signatures(
&mut self,
assoc: Map<FuncIndex, SigIndex>,
) -> Result<(), E>;
fn check_precondition(&mut self, module_info: &ModuleInfo) -> Result<(), E>;
fn next_function(
&mut self,
module_info: Arc<RwLock<ModuleInfo>>,
loc: WasmSpan,
) -> Result<&mut FCG, E>;
fn finalize(
self,
module_info: &ModuleInfo,
) -> Result<(RM, Option<DebugMetadata>, Box<dyn CacheGen>), E>;
unsafe fn from_cache(
cache: Artifact,
_: Token,
) -> Result<ModuleInner, CacheError>;
// Provided methods
fn requires_pre_validation() -> bool { ... }
fn feed_compiler_config(
&mut self,
_config: &CompilerConfig,
) -> Result<(), E> { ... }
}
Expand description
A trait that represents the functions needed to be implemented to generate code for a module.
Required Methods§
Sourcefn new_with_target(
triple: Option<String>,
cpu_name: Option<String>,
cpu_features: Option<String>,
) -> Self
fn new_with_target( triple: Option<String>, cpu_name: Option<String>, cpu_features: Option<String>, ) -> Self
Creates a new module code generator for specified target.
Sourcefn backend_id() -> &'static str
fn backend_id() -> &'static str
Returns the backend id associated with this MCG.
Sourcefn feed_import_function(&mut self, _sigindex: SigIndex) -> Result<(), E>
fn feed_import_function(&mut self, _sigindex: SigIndex) -> Result<(), E>
Adds an import function.
Sourcefn feed_signatures(
&mut self,
signatures: Map<SigIndex, FuncSig>,
) -> Result<(), E>
fn feed_signatures( &mut self, signatures: Map<SigIndex, FuncSig>, ) -> Result<(), E>
Sets the signatures.
Sourcefn feed_function_signatures(
&mut self,
assoc: Map<FuncIndex, SigIndex>,
) -> Result<(), E>
fn feed_function_signatures( &mut self, assoc: Map<FuncIndex, SigIndex>, ) -> Result<(), E>
Sets function signatures.
Sourcefn check_precondition(&mut self, module_info: &ModuleInfo) -> Result<(), E>
fn check_precondition(&mut self, module_info: &ModuleInfo) -> Result<(), E>
Checks the precondition for a module.
Sourcefn next_function(
&mut self,
module_info: Arc<RwLock<ModuleInfo>>,
loc: WasmSpan,
) -> Result<&mut FCG, E>
fn next_function( &mut self, module_info: Arc<RwLock<ModuleInfo>>, loc: WasmSpan, ) -> Result<&mut FCG, E>
Creates a new function and returns the function-scope code generator for it.
Sourcefn finalize(
self,
module_info: &ModuleInfo,
) -> Result<(RM, Option<DebugMetadata>, Box<dyn CacheGen>), E>
fn finalize( self, module_info: &ModuleInfo, ) -> Result<(RM, Option<DebugMetadata>, Box<dyn CacheGen>), E>
Finalizes this module.
Sourceunsafe fn from_cache(
cache: Artifact,
_: Token,
) -> Result<ModuleInner, CacheError>
unsafe fn from_cache( cache: Artifact, _: Token, ) -> Result<ModuleInner, CacheError>
Creates a module from cache.
Provided Methods§
Sourcefn requires_pre_validation() -> bool
fn requires_pre_validation() -> bool
It sets if the current compiler requires validation before compilation
Sourcefn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E>
fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E>
Feeds the compiler config.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.