mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
wasm_interp: tests for memory allocation instructions
This commit is contained in:
parent
06f3726e35
commit
2bd67a3292
3 changed files with 59 additions and 7 deletions
|
@ -790,6 +790,16 @@ impl<'a> MemorySection<'a> {
|
|||
};
|
||||
Ok(min_pages * MemorySection::PAGE_SIZE)
|
||||
}
|
||||
|
||||
pub fn max_bytes(&self) -> Result<Option<u32>, ParseError> {
|
||||
let mut cursor = 0;
|
||||
let memory_limits = Limits::parse((), &self.bytes, &mut cursor)?;
|
||||
let bytes = match memory_limits {
|
||||
Limits::Min(_) => None,
|
||||
Limits::MinMax(_, pages) => Some(pages * MemorySection::PAGE_SIZE),
|
||||
};
|
||||
Ok(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
section_impl!(MemorySection, SectionId::Memory);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue