refactor stack pointer initialisation

This commit is contained in:
Brian Carroll 2021-11-02 14:00:22 +00:00
parent baf896f6f9
commit d8c1017aec
2 changed files with 20 additions and 10 deletions

View file

@ -224,11 +224,15 @@ impl Serialize for Import {
}
}
pub struct ImportSection<'a> { entries: Vec<'a, Import> }
pub struct ImportSection<'a> {
entries: Vec<'a, Import>,
}
impl<'a> ImportSection<'a> {
pub fn new(arena: &'a Bump) -> Self {
ImportSection { entries: bumpalo::vec![in arena] }
ImportSection {
entries: bumpalo::vec![in arena],
}
}
}
@ -303,6 +307,15 @@ impl MemorySection {
MemorySection(Some(Limits::Min(pages)))
}
}
pub fn min_size(&self) -> Option<u32> {
match self {
MemorySection(Some(Limits::Min(min))) | MemorySection(Some(Limits::MinMax(min, _))) => {
Some(min * Self::PAGE_SIZE)
}
MemorySection(None) => None,
}
}
}
impl Serialize for MemorySection {