environment fully working

This commit is contained in:
Syrus Akbary 2018-10-14 20:37:42 +02:00
parent ac9edf39e6
commit 8bd6657e84
3 changed files with 12 additions and 1 deletions

View File

@ -417,6 +417,7 @@ impl<'environment> FuncEnvironmentTrait for FuncEnvironment<'environment> {
fn make_indirect_sig(&mut self, func: &mut ir::Function, index: SignatureIndex) -> ir::SigRef {
// A real implementation would probably change the calling convention and add `vmctx` and
// signature index arguments.
// func.import_signature(self.module.signatures[index].clone())
func.import_signature(self.vmctx_sig(index))
}

View File

@ -152,6 +152,11 @@ impl Instance {
pub fn memories(&self) -> Arc<Vec<LinearMemory>> {
self.memories.clone()
}
// pub fn start_func(&self) -> extern fn(&VmCtx) {
// self.start_func
// }
}
impl Clone for Instance {

View File

@ -67,8 +67,13 @@ pub struct ImportObject {
/// Errors:
/// If the operation fails, the Result rejects with a
/// WebAssembly.CompileError, WebAssembly.LinkError, or
/// WebAssembly.RuntimeError, depending on the cause of the failure.
/// WebAssembly.RuntimeError, depending on the cause of the failure.
pub fn instantiate(buffer_source: Vec<u8>, import_object: Option<ImportObject>) -> Result<ModuleInstance, ErrorKind> {
// TODO: This should be automatically validated when creating the ModuleInstance
if !validate(&buffer_source) {
return Err(ErrorKind::CompileError("Module not valid".to_string()));
}
let flags = Flags::new(settings::builder());
let return_mode = ReturnMode::NormalReturns;
let mut environ =