mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-05-23 12:41:34 +00:00
Allow specifying a shared memory import
This commit is contained in:
parent
a411a15b0c
commit
a056b41b56
@ -95,7 +95,7 @@ impl<F> ImportExternalBuilder<F> where F: Invoke<elements::External> {
|
||||
|
||||
/// Memory mapping with specified limits
|
||||
pub fn memory(mut self, min: u32, max: Option<u32>) -> F::Result {
|
||||
self.binding = elements::External::Memory(elements::MemoryType::new(min, max));
|
||||
self.binding = elements::External::Memory(elements::MemoryType::new(min, max, false));
|
||||
self.callback.invoke(self.binding)
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ impl<F> ModuleBuilder<F> where F: Invoke<elements::Module> {
|
||||
/// Push linear memory region
|
||||
pub fn push_memory(&mut self, mut memory: memory::MemoryDefinition) -> u32 {
|
||||
let entries = self.module.memory.entries_mut();
|
||||
entries.push(elements::MemoryType::new(memory.min, memory.max));
|
||||
entries.push(elements::MemoryType::new(memory.min, memory.max, false));
|
||||
let memory_index = (entries.len() - 1) as u32;
|
||||
for data in memory.data.drain(..) {
|
||||
self.module.data.entries_mut()
|
||||
|
@ -162,9 +162,14 @@ pub struct MemoryType(ResizableLimits);
|
||||
|
||||
impl MemoryType {
|
||||
/// New memory definition
|
||||
pub fn new(min: u32, max: Option<u32>) -> Self {
|
||||
MemoryType(ResizableLimits::new(min, max))
|
||||
pub fn new(min: u32, max: Option<u32>, shared: bool) -> Self {
|
||||
let mut r = ResizableLimits::new(min, max);
|
||||
if shared {
|
||||
r.flags |= 0x2;
|
||||
}
|
||||
MemoryType(r)
|
||||
}
|
||||
|
||||
/// Limits of the memory entry.
|
||||
pub fn limits(&self) -> &ResizableLimits {
|
||||
&self.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user