rename FunctionsSection -> FunctionSection

This commit is contained in:
NikVolf
2017-06-03 23:31:38 +03:00
parent edafa0cdf5
commit 35f22f3cdd
5 changed files with 17 additions and 17 deletions

View File

@ -165,9 +165,9 @@ impl<F> Invoke<u32> for SignaturesBuilder<F> {
} }
} }
impl<F> SignaturesBuilder<F> where F: Invoke<elements::FunctionsSection> { impl<F> SignaturesBuilder<F> where F: Invoke<elements::FunctionSection> {
pub fn build(self) -> F::Result { pub fn build(self) -> F::Result {
let mut result = elements::FunctionsSection::default(); let mut result = elements::FunctionSection::default();
for f in self.section.into_iter() { for f in self.section.into_iter() {
if let Signature::TypeReference(type_ref) = f { if let Signature::TypeReference(type_ref) = f {
result.entries_mut().push(elements::Func::new(type_ref)); result.entries_mut().push(elements::Func::new(type_ref));

View File

@ -23,7 +23,7 @@ pub struct CodeLocation {
struct ModuleScaffold { struct ModuleScaffold {
pub types: elements::TypeSection, pub types: elements::TypeSection,
pub import: elements::ImportSection, pub import: elements::ImportSection,
pub functions: elements::FunctionsSection, pub functions: elements::FunctionSection,
pub table: elements::TableSection, pub table: elements::TableSection,
pub memory: elements::MemorySection, pub memory: elements::MemorySection,
pub global: elements::GlobalSection, pub global: elements::GlobalSection,
@ -39,7 +39,7 @@ impl From<elements::Module> for ModuleScaffold {
fn from(module: elements::Module) -> Self { fn from(module: elements::Module) -> Self {
let mut types: Option<elements::TypeSection> = None; let mut types: Option<elements::TypeSection> = None;
let mut import: Option<elements::ImportSection> = None; let mut import: Option<elements::ImportSection> = None;
let mut funcs: Option<elements::FunctionsSection> = None; let mut funcs: Option<elements::FunctionSection> = None;
let mut table: Option<elements::TableSection> = None; let mut table: Option<elements::TableSection> = None;
let mut memory: Option<elements::MemorySection> = None; let mut memory: Option<elements::MemorySection> = None;
let mut global: Option<elements::GlobalSection> = None; let mut global: Option<elements::GlobalSection> = None;
@ -327,12 +327,12 @@ impl<F> ModuleBuilder<F> where F: Invoke<elements::Module> {
} }
} }
impl<F> Invoke<elements::FunctionsSection> for ModuleBuilder<F> impl<F> Invoke<elements::FunctionSection> for ModuleBuilder<F>
where F: Invoke<elements::Module> where F: Invoke<elements::Module>
{ {
type Result = Self; type Result = Self;
fn invoke(self, section: elements::FunctionsSection) -> Self { fn invoke(self, section: elements::FunctionSection) -> Self {
self.with_section(elements::Section::Function(section)) self.with_section(elements::Section::Function(section))
} }
} }

View File

@ -15,7 +15,7 @@ mod segment;
pub use self::module::Module; pub use self::module::Module;
pub use self::section::{ pub use self::section::{
Section, FunctionsSection, CodeSection, MemorySection, DataSection, Section, FunctionSection, CodeSection, MemorySection, DataSection,
ImportSection, ExportSection, GlobalSection, TypeSection, ElementSection, ImportSection, ExportSection, GlobalSection, TypeSection, ElementSection,
TableSection, TableSection,
}; };

View File

@ -1,7 +1,7 @@
use std::io; use std::io;
use super::{Deserialize, Serialize, Error, Uint32}; use super::{Deserialize, Serialize, Error, Uint32};
use super::section::{ use super::section::{
Section, CodeSection, TypeSection, ImportSection, ExportSection, FunctionsSection, Section, CodeSection, TypeSection, ImportSection, ExportSection, FunctionSection,
GlobalSection, TableSection, ElementSection, DataSection, MemorySection GlobalSection, TableSection, ElementSection, DataSection, MemorySection
}; };
@ -123,7 +123,7 @@ impl Module {
} }
/// Functions signatures section, if any. /// Functions signatures section, if any.
pub fn functions_section(&self) -> Option<&FunctionsSection> { pub fn functions_section(&self) -> Option<&FunctionSection> {
for section in self.sections() { for section in self.sections() {
if let &Section::Function(ref sect) = section { return Some(sect); } if let &Section::Function(ref sect) = section { return Some(sect); }
} }

View File

@ -38,7 +38,7 @@ pub enum Section {
/// Import section /// Import section
Import(ImportSection), Import(ImportSection),
/// Function signatures section /// Function signatures section
Function(FunctionsSection), Function(FunctionSection),
/// Table definition section /// Table definition section
Table(TableSection), Table(TableSection),
/// Memory definition section /// Memory definition section
@ -79,7 +79,7 @@ impl Deserialize for Section {
Section::Import(ImportSection::deserialize(reader)?) Section::Import(ImportSection::deserialize(reader)?)
}, },
3 => { 3 => {
Section::Function(FunctionsSection::deserialize(reader)?) Section::Function(FunctionSection::deserialize(reader)?)
}, },
4 => { 4 => {
Section::Table(TableSection::deserialize(reader)?) Section::Table(TableSection::deserialize(reader)?)
@ -276,12 +276,12 @@ impl Serialize for ImportSection {
/// Section with function signatures definition. /// Section with function signatures definition.
#[derive(Default)] #[derive(Default)]
pub struct FunctionsSection(Vec<Func>); pub struct FunctionSection(Vec<Func>);
impl FunctionsSection { impl FunctionSection {
/// New function signatures section with provided entries /// New function signatures section with provided entries
pub fn with_entries(entries: Vec<Func>) -> Self { pub fn with_entries(entries: Vec<Func>) -> Self {
FunctionsSection(entries) FunctionSection(entries)
} }
/// List of all functions in the section, mutable /// List of all functions in the section, mutable
@ -295,7 +295,7 @@ impl FunctionsSection {
} }
} }
impl Deserialize for FunctionsSection { impl Deserialize for FunctionSection {
type Error = Error; type Error = Error;
fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> { fn deserialize<R: io::Read>(reader: &mut R) -> Result<Self, Self::Error> {
@ -306,11 +306,11 @@ impl Deserialize for FunctionsSection {
.into_iter() .into_iter()
.map(|f| Func::new(f.into())) .map(|f| Func::new(f.into()))
.collect(); .collect();
Ok(FunctionsSection(funcs)) Ok(FunctionSection(funcs))
} }
} }
impl Serialize for FunctionsSection { impl Serialize for FunctionSection {
type Error = Error; type Error = Error;
fn serialize<W: io::Write>(self, writer: &mut W) -> Result<(), Self::Error> { fn serialize<W: io::Write>(self, writer: &mut W) -> Result<(), Self::Error> {