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:
30
lib/execute/src/imports.rs
Normal file
30
lib/execute/src/imports.rs
Normal 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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user