mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-22 19:21:59 +00:00
Few renamings
This commit is contained in:
@ -70,7 +70,7 @@ impl<St> ExternVal<St> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ModuleInstance<St> {
|
pub struct ModuleInstance<St> {
|
||||||
types: RefCell<Vec<Rc<FunctionType>>>,
|
types: RefCell<Vec<Rc<FunctionType>>>,
|
||||||
tables: RefCell<Vec<Rc<TableInstance<St>>>>,
|
tables: RefCell<Vec<Rc<TableInstance<St>>>>,
|
||||||
@ -80,8 +80,8 @@ pub struct ModuleInstance<St> {
|
|||||||
exports: RefCell<HashMap<String, ExternVal<St>>>,
|
exports: RefCell<HashMap<String, ExternVal<St>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<St> ModuleInstance<St> {
|
impl<St> Default for ModuleInstance<St> {
|
||||||
fn new() -> ModuleInstance<St> {
|
fn default() -> Self {
|
||||||
ModuleInstance {
|
ModuleInstance {
|
||||||
types: RefCell::new(Vec::new()),
|
types: RefCell::new(Vec::new()),
|
||||||
tables: RefCell::new(Vec::new()),
|
tables: RefCell::new(Vec::new()),
|
||||||
@ -91,9 +91,11 @@ impl<St> ModuleInstance<St> {
|
|||||||
exports: RefCell::new(HashMap::new()),
|
exports: RefCell::new(HashMap::new()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn with_exports(exports: HashMap<String, ExternVal<St>>) -> ModuleInstance<St> {
|
impl<St> ModuleInstance<St> {
|
||||||
let mut instance = Self::new();
|
pub fn with_exports(exports: HashMap<String, ExternVal<St>>) -> Self {
|
||||||
|
let mut instance = Self::default();
|
||||||
instance.exports = RefCell::new(exports);
|
instance.exports = RefCell::new(exports);
|
||||||
instance
|
instance
|
||||||
}
|
}
|
||||||
@ -310,7 +312,7 @@ impl<St> ModuleInstance<St> {
|
|||||||
module: &Module,
|
module: &Module,
|
||||||
extern_vals: &[ExternVal<St>],
|
extern_vals: &[ExternVal<St>],
|
||||||
) -> Result<Rc<ModuleInstance<St>>, Error> {
|
) -> Result<Rc<ModuleInstance<St>>, Error> {
|
||||||
let instance = Rc::new(ModuleInstance::new());
|
let instance = Rc::new(ModuleInstance::default());
|
||||||
|
|
||||||
ModuleInstance::alloc_module(module, extern_vals, &instance)?;
|
ModuleInstance::alloc_module(module, extern_vals, &instance)?;
|
||||||
|
|
||||||
@ -393,8 +395,8 @@ impl<St> ModuleInstance<St> {
|
|||||||
Self::instantiate_with_externvals(module, &extern_vals)
|
Self::instantiate_with_externvals(module, &extern_vals)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn instantiate<'a>(module: &'a Module) -> InstantiationWizard<'a, St> {
|
pub fn new<'a>(module: &'a Module) -> InstantiationBuilder<'a, St> {
|
||||||
InstantiationWizard::new(module)
|
InstantiationBuilder::new(module)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn invoke_index(
|
pub fn invoke_index(
|
||||||
@ -437,14 +439,14 @@ impl<St> ModuleInstance<St> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InstantiationWizard<'a, St: 'a> {
|
pub struct InstantiationBuilder<'a, St: 'a> {
|
||||||
module: &'a Module,
|
module: &'a Module,
|
||||||
imports: Option<Imports<'a, St>>,
|
imports: Option<Imports<'a, St>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, St: 'a> InstantiationWizard<'a, St> {
|
impl<'a, St: 'a> InstantiationBuilder<'a, St> {
|
||||||
fn new(module: &'a Module) -> Self {
|
fn new(module: &'a Module) -> Self {
|
||||||
InstantiationWizard {
|
InstantiationBuilder {
|
||||||
module,
|
module,
|
||||||
imports: None,
|
imports: None,
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ impl<St> ProgramInstance<St> {
|
|||||||
for (module_name, import_resolver) in self.resolvers.iter() {
|
for (module_name, import_resolver) in self.resolvers.iter() {
|
||||||
imports.push_resolver(&**module_name, &**import_resolver);
|
imports.push_resolver(&**module_name, &**import_resolver);
|
||||||
}
|
}
|
||||||
ModuleInstance::instantiate(&module)
|
ModuleInstance::new(&module)
|
||||||
.with_imports(imports)
|
.with_imports(imports)
|
||||||
.run_start(state)?
|
.run_start(state)?
|
||||||
};
|
};
|
||||||
|
@ -37,10 +37,10 @@ fn import_function() {
|
|||||||
.build()
|
.build()
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let external_module = ModuleInstance::instantiate(&module1)
|
let external_module = ModuleInstance::new(&module1)
|
||||||
.assert_no_start()
|
.assert_no_start()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let main_module = ModuleInstance::instantiate(&module2)
|
let main_module = ModuleInstance::new(&module2)
|
||||||
.with_import("external_module", &*external_module)
|
.with_import("external_module", &*external_module)
|
||||||
.assert_no_start()
|
.assert_no_start()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -340,7 +340,7 @@ fn native_ref_state() {
|
|||||||
ext_state: RefCell::new(&mut ext_state),
|
ext_state: RefCell::new(&mut ext_state),
|
||||||
};
|
};
|
||||||
|
|
||||||
let instance = ModuleInstance::instantiate(&main_module)
|
let instance = ModuleInstance::new(&main_module)
|
||||||
.with_import("env", &host_module)
|
.with_import("env", &host_module)
|
||||||
.assert_no_start()
|
.assert_no_start()
|
||||||
.expect("Instantiate module successfully");
|
.expect("Instantiate module successfully");
|
||||||
|
Reference in New Issue
Block a user