clean up implementation

This commit is contained in:
Mark McCaskey
2019-03-27 14:01:27 -07:00
parent f9a29445ca
commit 09068c1a74
11 changed files with 109 additions and 58 deletions

View File

@ -14,6 +14,8 @@ use crate::{
};
use std::{any::Any, ptr::NonNull};
use hashbrown::HashMap;
pub mod sys {
pub use crate::sys::*;
}
@ -38,11 +40,28 @@ impl Token {
}
}
/// Configuration data for the compiler
pub struct CompilerConfig {
/// Symbol information generated from emscripten; used for more detailed debug messages
pub symbol_map: Option<HashMap<u32, String>>,
}
impl Default for CompilerConfig {
fn default() -> CompilerConfig {
CompilerConfig { symbol_map: None }
}
}
pub trait Compiler {
/// Compiles a `Module` from WebAssembly binary format.
/// The `CompileToken` parameter ensures that this can only
/// be called from inside the runtime.
fn compile(&self, wasm: &[u8], _: Token) -> CompileResult<ModuleInner>;
fn compile(
&self,
wasm: &[u8],
comp_conf: CompilerConfig,
_: Token,
) -> CompileResult<ModuleInner>;
unsafe fn from_cache(&self, cache: Artifact, _: Token) -> Result<ModuleInner, CacheError>;
}