transition to protected_caller

This commit is contained in:
Lachlan Sneff
2019-01-18 14:30:15 -08:00
parent 539db9f577
commit 9ed0018045
7 changed files with 69 additions and 47 deletions

View File

@ -1,8 +1,8 @@
use crate::{
backing::ImportBacking,
error::CompileResult,
error::RuntimeResult,
module::ModuleInner,
backing::ImportBacking,
types::{FuncIndex, LocalFuncIndex, Value},
vm,
};

View File

@ -13,8 +13,8 @@ use crate::{
},
vm,
};
use std::rc::Rc;
use std::mem;
use std::rc::Rc;
pub(crate) struct InstanceInner {
#[allow(dead_code)]
@ -201,17 +201,15 @@ impl InstanceInner {
.expect("broken invariant, incorrect func index");
let (func_ptr, ctx) = match func_index.local_or_import(module) {
LocalOrImport::Local(local_func_index) => {
(
module
.func_resolver
.get(&module, local_func_index)
.expect("broken invariant, func resolver not synced with module.exports")
.cast()
.as_ptr() as *const _,
Context::Internal,
)
}
LocalOrImport::Local(local_func_index) => (
module
.func_resolver
.get(&module, local_func_index)
.expect("broken invariant, func resolver not synced with module.exports")
.cast()
.as_ptr() as *const _,
Context::Internal,
),
LocalOrImport::Import(imported_func_index) => {
let imported_func = &self.import_backing.functions[imported_func_index];
(

View File

@ -19,6 +19,7 @@ use std::rc::Rc;
pub struct ModuleInner {
pub func_resolver: Box<dyn FuncResolver>,
pub protected_caller: Box<dyn ProtectedCaller>,
// This are strictly local and the typsystem ensures that.
pub memories: Map<LocalMemoryIndex, Memory>,
pub globals: Map<LocalGlobalIndex, Global>,