Compare commits
3 Commits
master
...
cmichi-der
Author | SHA1 | Date |
---|---|---|
Michael Mueller | e2816f4661 | |
Michael Mueller | a1ea2d689f | |
Michael Mueller | 327d93c785 |
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "wasmi"
|
||||
version = "0.4.5"
|
||||
version = "0.4.6"
|
||||
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Svyatoslav Nikolsky <svyatonik@yandex.ru>", "Sergey Pepyakin <s.pepyakin@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
|
|
@ -37,6 +37,13 @@ use {Error, MemoryInstance, Module, RuntimeValue, Signature, TableInstance};
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct ModuleRef(pub(crate) Rc<ModuleInstance>);
|
||||
|
||||
impl ModuleRef {
|
||||
/// Creates a new `ModuleRef` from a `ModuleInstance`.
|
||||
pub fn new(instance: ModuleInstance) -> ModuleRef {
|
||||
ModuleRef(Rc::new(instance))
|
||||
}
|
||||
}
|
||||
|
||||
impl ::core::ops::Deref for ModuleRef {
|
||||
type Target = ModuleInstance;
|
||||
fn deref(&self) -> &ModuleInstance {
|
||||
|
@ -162,6 +169,31 @@ pub struct ModuleInstance {
|
|||
exports: RefCell<BTreeMap<String, ExternVal>>,
|
||||
}
|
||||
|
||||
impl Clone for ModuleInstance {
|
||||
fn clone(&self) -> Self {
|
||||
let signatures = self.signatures.borrow();
|
||||
let vec = &(*signatures);
|
||||
let signatures = vec
|
||||
.iter()
|
||||
.map(|inner_rc| {
|
||||
let signature = &**inner_rc;
|
||||
let signature_clone = signature.clone();
|
||||
Rc::new(signature_clone)
|
||||
})
|
||||
.collect();
|
||||
let signatures = RefCell::new(signatures);
|
||||
|
||||
ModuleInstance {
|
||||
signatures,
|
||||
tables: self.tables.clone(),
|
||||
funcs: self.funcs.clone(),
|
||||
memories: self.memories.clone(),
|
||||
globals: self.globals.clone(),
|
||||
exports: self.exports.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ModuleInstance {
|
||||
fn default() -> Self {
|
||||
ModuleInstance {
|
||||
|
|
Loading…
Reference in New Issue