Add comments.

This commit is contained in:
losfair 2019-05-14 16:13:42 +08:00
parent 32f9aee6fe
commit 1e7a928d64
2 changed files with 20 additions and 12 deletions

View File

@ -91,9 +91,12 @@ pub trait RunnableModule: Send + Sync {
unsafe fn do_early_trap(&self, data: Box<dyn Any>) -> !;
/// Returns the machine code associated with this module.
fn get_code(&self) -> Option<&[u8]> {
None
}
/// Returns the beginning offsets of all functions, including import trampolines.
fn get_offsets(&self) -> Option<Vec<usize>> {
None
}

View File

@ -42,24 +42,29 @@ impl fmt::Debug for InternalEvent {
pub struct BkptInfo {}
pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator<E>, RM: RunnableModule, E: Debug> {
/// Creates a new module code generator.
fn new() -> Self;
/// Returns the backend id associated with this MCG.
fn backend_id() -> Backend;
fn check_precondition(&mut self, module_info: &ModuleInfo) -> Result<(), E>;
/// Creates a new function and returns the function-scope code generator for it.
fn next_function(&mut self) -> Result<&mut FCG, E>;
fn finalize(self, module_info: &ModuleInfo) -> Result<(RM, Box<dyn CacheGen>), E>;
fn feed_signatures(&mut self, signatures: Map<SigIndex, FuncSig>) -> Result<(), E>;
/// Sets function signatures.
fn feed_function_signatures(&mut self, assoc: Map<FuncIndex, SigIndex>) -> Result<(), E>;
/// Adds an import function.
fn feed_import_function(&mut self) -> Result<(), E>;
/// Feeds the compiler config.
fn feed_compiler_config(&mut self, _config: &CompilerConfig) -> Result<(), E> {
Ok(())
}
/// Adds an import function.
fn feed_import_function(&mut self) -> Result<(), E>;
fn feed_signatures(&mut self, signatures: Map<SigIndex, FuncSig>) -> Result<(), E>;
/// Sets function signatures.
fn feed_function_signatures(&mut self, assoc: Map<FuncIndex, SigIndex>) -> Result<(), E>;
/// Checks the precondition for a module.
fn check_precondition(&mut self, module_info: &ModuleInfo) -> Result<(), E>;
/// Creates a new function and returns the function-scope code generator for it.
fn next_function(&mut self) -> Result<&mut FCG, E>;
/// Finalizes this module.
fn finalize(self, module_info: &ModuleInfo) -> Result<(RM, Box<dyn CacheGen>), E>;
/// Creates a module from cache.
unsafe fn from_cache(cache: Artifact, _: Token) -> Result<ModuleInner, CacheError>;
}