Improve error handling, and start refactoring Instance.

Introduce proper error handling in several places, and perform a first
pass at refactoring Instance to make it easier to use.
This commit is contained in:
Dan Gohman
2018-12-07 15:32:51 -05:00
parent fe562297a7
commit 7dcca6be5b
24 changed files with 949 additions and 565 deletions

View File

@@ -0,0 +1,30 @@
use cranelift_entity::PrimaryMap;
use cranelift_wasm::{FuncIndex, GlobalIndex, MemoryIndex, TableIndex};
use vmcontext::{VMGlobal, VMMemory, VMTable};
/// Resolved import pointers.
#[derive(Debug)]
pub struct Imports {
/// Resolved addresses for imported functions.
pub functions: PrimaryMap<FuncIndex, *const u8>,
/// Resolved addresses for imported tables.
pub tables: PrimaryMap<TableIndex, *mut VMTable>,
/// Resolved addresses for imported globals.
pub globals: PrimaryMap<GlobalIndex, *mut VMGlobal>,
/// Resolved addresses for imported memories.
pub memories: PrimaryMap<MemoryIndex, *mut VMMemory>,
}
impl Imports {
pub fn new() -> Self {
Self {
functions: PrimaryMap::new(),
tables: PrimaryMap::new(),
globals: PrimaryMap::new(),
memories: PrimaryMap::new(),
}
}
}