Introduce proper error handling in several places, and perform a first pass at refactoring Instance to make it easier to use.
31 lines
883 B
Rust
31 lines
883 B
Rust
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(),
|
|
}
|
|
}
|
|
}
|