Move all vm internals out

This commit is contained in:
Syrus Akbary
2023-04-08 00:37:48 -07:00
parent 8be88859be
commit 6c4ea497b9
3 changed files with 31 additions and 16 deletions

View File

@@ -143,6 +143,21 @@ impl Memory {
}
/// Attempts to clone this memory (if its clonable) in a new store
pub fn clone_in_store(
&self,
store: &impl AsStoreRef,
new_store: &mut impl AsStoreMut,
) -> Option<Self> {
if !self.ty(store).shared {
// We should only be able to duplicate in a new store if the memory is shared
return None;
}
self.0
.try_clone(&store)
.map(|new_memory| Self::new_from_existing(new_store, new_memory.into()))
}
/// Attempts to duplicate this memory (if its clonable) in a new store
pub fn duplicate_in_store(
&self,
store: &impl AsStoreRef,