mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-12 22:41:40 +00:00
globals
This commit is contained in:
@ -12,6 +12,7 @@ use super::{
|
||||
ExportEntry,
|
||||
Opcodes,
|
||||
ValueType,
|
||||
GlobalEntry,
|
||||
};
|
||||
|
||||
use super::types::Type;
|
||||
@ -27,6 +28,7 @@ pub enum Section {
|
||||
Function(FunctionsSection),
|
||||
Table(TableSection),
|
||||
Memory(MemorySection),
|
||||
Global(GlobalSection),
|
||||
Export(ExportSection),
|
||||
Start(u32),
|
||||
Code(CodeSection),
|
||||
@ -62,6 +64,9 @@ impl Deserialize for Section {
|
||||
5 => {
|
||||
Section::Memory(MemorySection::deserialize(reader)?)
|
||||
},
|
||||
6 => {
|
||||
Section::Global(GlobalSection::deserialize(reader)?)
|
||||
},
|
||||
7 => {
|
||||
Section::Export(ExportSection::deserialize(reader)?)
|
||||
},
|
||||
@ -188,6 +193,25 @@ impl Deserialize for MemorySection {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct GlobalSection(Vec<GlobalEntry>);
|
||||
|
||||
impl GlobalSection {
|
||||
pub fn entries(&self) -> &[GlobalEntry] {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Deserialize for GlobalSection {
|
||||
type Error = Error;
|
||||
|
||||
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
|
||||
// todo: maybe use reader.take(section_length)
|
||||
let _section_length = VarUint32::deserialize(reader)?;
|
||||
let entries: Vec<GlobalEntry> = CountedList::deserialize(reader)?.into_inner();
|
||||
Ok(GlobalSection(entries))
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ExportSection(Vec<ExportEntry>);
|
||||
|
||||
impl ExportSection {
|
||||
|
Reference in New Issue
Block a user