mirror of
https://github.com/fluencelabs/wasmer
synced 2025-07-18 17:11:56 +00:00
Rework imports
This commit is contained in:
lib
clif-backend
runtime
build
examples
src
tests
semantics.rs
spectests
_common.rsaddress.rsalign.rsbinary.rsblock.rsbr.rsbr_if.rsbr_table.rsbreak_drop.rscall.rscall_indirect.rscomments.rsconst_.rsconversions.rscustom.rsdata.rselem.rsendianness.rsexports.rsf32_.rsf32_bitwise.rsf32_cmp.rsf64_.rsf64_bitwise.rsf64_cmp.rsfac.rsfloat_exprs.rsfloat_literals.rsfloat_memory.rsfloat_misc.rsforward.rsfunc.rsfunc_ptrs.rsget_local.rsglobals.rsi32_.rsi64_.rsif_.rsint_exprs.rsint_literals.rslabels.rsleft_to_right.rsloop_.rsmemory.rsmemory_grow.rsmemory_redundancy.rsmemory_trap.rsnop.rsreturn_.rsselect.rsset_local.rsstack.rsstart.rsswitch.rstee_local.rstraps.rstypes.rsunwind.rs
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
backend::FuncResolver,
|
||||
import::ImportResolver,
|
||||
import::Imports,
|
||||
sig_registry::SigRegistry,
|
||||
types::{
|
||||
FuncIndex, Global, GlobalDesc, GlobalIndex, Map, MapIndex, Memory, MemoryIndex, SigIndex,
|
||||
@@ -9,10 +9,10 @@ use crate::{
|
||||
Instance,
|
||||
};
|
||||
use hashbrown::HashMap;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
|
||||
/// This is used to instantiate a new webassembly module.
|
||||
#[doc(hidden)]
|
||||
pub struct ModuleInner {
|
||||
pub func_resolver: Box<dyn FuncResolver>,
|
||||
pub memories: Map<MemoryIndex, Memory>,
|
||||
@@ -37,14 +37,13 @@ pub struct ModuleInner {
|
||||
pub struct Module(Rc<ModuleInner>);
|
||||
|
||||
impl Module {
|
||||
#[inline]
|
||||
pub fn new(inner: ModuleInner) -> Self {
|
||||
Module(Rc::new(inner))
|
||||
pub(crate) fn new(inner: Rc<ModuleInner>) -> Self {
|
||||
Module(inner)
|
||||
}
|
||||
|
||||
/// Instantiate a webassembly module with the provided imports.
|
||||
pub fn instantiate(&self, imports: Rc<dyn ImportResolver>) -> Result<Instance, String> {
|
||||
Instance::new(Module(Rc::clone(&self.0)), imports)
|
||||
pub fn instantiate(&self, imports: &Imports) -> Result<Instance, String> {
|
||||
Instance::new(Rc::clone(&self.0), imports)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,14 +57,7 @@ impl ModuleInner {
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Module {
|
||||
type Target = ModuleInner;
|
||||
|
||||
fn deref(&self) -> &ModuleInner {
|
||||
&*self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ImportName {
|
||||
pub namespace: String,
|
||||
|
Reference in New Issue
Block a user