mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-05-23 20:51:33 +00:00
Merge remote-tracking branch 'origin/master' into drop-wast
This commit is contained in:
commit
b8f0b22132
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "parity-wasm"
|
name = "parity-wasm"
|
||||||
version = "0.35.2"
|
version = "0.35.3"
|
||||||
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Svyatoslav Nikolsky <svyatonik@yandex.ru>", "Sergey Shulepov <s.pepyakin@gmail.com>"]
|
authors = ["Nikolay Volf <nikvolf@gmail.com>", "Svyatoslav Nikolsky <svyatonik@yandex.ru>", "Sergey Shulepov <s.pepyakin@gmail.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
BIN
res/cases/v1/start_mut.wasm
Normal file
BIN
res/cases/v1/start_mut.wasm
Normal file
Binary file not shown.
24
res/cases/v1/start_mut.wast
Normal file
24
res/cases/v1/start_mut.wast
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
(module
|
||||||
|
(type $0 (func (param i32) (result i32)))
|
||||||
|
(type $1 (func (result i32)))
|
||||||
|
(type $2 (func))
|
||||||
|
(import "env" "memoryBase" (global $gimport$0 i32))
|
||||||
|
(import "env" "memory" (memory $0 256))
|
||||||
|
(import "env" "table" (table 0 anyfunc))
|
||||||
|
(import "env" "tableBase" (global $gimport$4 i32))
|
||||||
|
(import "env" "_puts" (func $fimport$1 (param i32) (result i32)))
|
||||||
|
(global $global$0 (mut i32) (i32.const 0))
|
||||||
|
(global $global$1 (mut i32) (i32.const 0))
|
||||||
|
(global $global$2 i32 (i32.const 0))
|
||||||
|
(data (i32.const 13) "hello, world!")
|
||||||
|
(export "_main" (func $0))
|
||||||
|
(start $0)
|
||||||
|
(func $0 (type $2)
|
||||||
|
(drop
|
||||||
|
(call $fimport$1
|
||||||
|
(get_global $gimport$0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
@ -56,7 +56,7 @@ pub struct ExportEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ExportEntry {
|
impl ExportEntry {
|
||||||
/// New export entry
|
/// New export entry.
|
||||||
pub fn new(field: String, internal: Internal) -> Self {
|
pub fn new(field: String, internal: Internal) -> Self {
|
||||||
ExportEntry {
|
ExportEntry {
|
||||||
field_str: field,
|
field_str: field,
|
||||||
@ -64,10 +64,10 @@ impl ExportEntry {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Public name
|
/// Public name.
|
||||||
pub fn field(&self) -> &str { &self.field_str }
|
pub fn field(&self) -> &str { &self.field_str }
|
||||||
|
|
||||||
/// Public name (mutable)
|
/// Public name (mutable).
|
||||||
pub fn field_mut(&mut self) -> &mut String { &mut self.field_str }
|
pub fn field_mut(&mut self) -> &mut String { &mut self.field_str }
|
||||||
|
|
||||||
/// Internal reference of the export entry.
|
/// Internal reference of the export entry.
|
||||||
|
@ -89,12 +89,12 @@ pub struct FuncBody {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl FuncBody {
|
impl FuncBody {
|
||||||
/// New function body with given `locals` and `instructions`
|
/// New function body with given `locals` and `instructions`.
|
||||||
pub fn new(locals: Vec<Local>, instructions: Instructions) -> Self {
|
pub fn new(locals: Vec<Local>, instructions: Instructions) -> Self {
|
||||||
FuncBody { locals: locals, instructions: instructions }
|
FuncBody { locals: locals, instructions: instructions }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of individual instructions
|
/// List of individual instructions.
|
||||||
pub fn empty() -> Self {
|
pub fn empty() -> Self {
|
||||||
FuncBody { locals: Vec::new(), instructions: Instructions::empty() }
|
FuncBody { locals: Vec::new(), instructions: Instructions::empty() }
|
||||||
}
|
}
|
||||||
@ -103,6 +103,7 @@ impl FuncBody {
|
|||||||
pub fn locals(&self) -> &[Local] { &self.locals }
|
pub fn locals(&self) -> &[Local] { &self.locals }
|
||||||
|
|
||||||
/// Instruction list of the function body. Minimal instruction list
|
/// Instruction list of the function body. Minimal instruction list
|
||||||
|
///
|
||||||
/// is just `&[Instruction::End]`
|
/// is just `&[Instruction::End]`
|
||||||
pub fn code(&self) -> &Instructions { &self.instructions }
|
pub fn code(&self) -> &Instructions { &self.instructions }
|
||||||
|
|
||||||
@ -117,7 +118,6 @@ impl Deserialize for FuncBody {
|
|||||||
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> {
|
||||||
// todo: maybe use reader.take(section_length)
|
|
||||||
let mut body_reader = SectionReader::new(reader)?;
|
let mut body_reader = SectionReader::new(reader)?;
|
||||||
let locals: Vec<Local> = CountedList::<Local>::deserialize(&mut body_reader)?.into_inner();
|
let locals: Vec<Local> = CountedList::<Local>::deserialize(&mut body_reader)?.into_inner();
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ pub struct GlobalEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalEntry {
|
impl GlobalEntry {
|
||||||
/// New global entry
|
/// New global entry.
|
||||||
pub fn new(global_type: GlobalType, init_expr: InitExpr) -> Self {
|
pub fn new(global_type: GlobalType, init_expr: InitExpr) -> Self {
|
||||||
GlobalEntry {
|
GlobalEntry {
|
||||||
global_type: global_type,
|
global_type: global_type,
|
||||||
@ -20,9 +20,9 @@ impl GlobalEntry {
|
|||||||
pub fn global_type(&self) -> &GlobalType { &self.global_type }
|
pub fn global_type(&self) -> &GlobalType { &self.global_type }
|
||||||
/// Initialization expression (instructions) for global.
|
/// Initialization expression (instructions) for global.
|
||||||
pub fn init_expr(&self) -> &InitExpr { &self.init_expr }
|
pub fn init_expr(&self) -> &InitExpr { &self.init_expr }
|
||||||
/// Global type (mutable)
|
/// Global type (mutable).
|
||||||
pub fn global_type_mut(&mut self) -> &mut GlobalType { &mut self.global_type }
|
pub fn global_type_mut(&mut self) -> &mut GlobalType { &mut self.global_type }
|
||||||
/// Initialization expression (instructions) for global (mutable)
|
/// Initialization expression (instructions) for global (mutable).
|
||||||
pub fn init_expr_mut(&mut self) -> &mut InitExpr { &mut self.init_expr }
|
pub fn init_expr_mut(&mut self) -> &mut InitExpr { &mut self.init_expr }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ pub struct ResizableLimits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ResizableLimits {
|
impl ResizableLimits {
|
||||||
/// New memory limits definition
|
/// New memory limits definition.
|
||||||
pub fn new(min: u32, max: Option<u32>) -> Self {
|
pub fn new(min: u32, max: Option<u32>) -> Self {
|
||||||
ResizableLimits {
|
ResizableLimits {
|
||||||
initial: min,
|
initial: min,
|
||||||
@ -116,11 +116,11 @@ impl ResizableLimits {
|
|||||||
shared: false,
|
shared: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Initial size
|
/// Initial size.
|
||||||
pub fn initial(&self) -> u32 { self.initial }
|
pub fn initial(&self) -> u32 { self.initial }
|
||||||
/// Maximum size
|
/// Maximum size.
|
||||||
pub fn maximum(&self) -> Option<u32> { self.maximum }
|
pub fn maximum(&self) -> Option<u32> { self.maximum }
|
||||||
/// Whether or not this is a shared array buffer
|
/// Whether or not this is a shared array buffer.
|
||||||
pub fn shared(&self) -> bool { self.shared }
|
pub fn shared(&self) -> bool { self.shared }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ pub use self::reloc_section::{
|
|||||||
RelocSection, RelocationEntry,
|
RelocSection, RelocationEntry,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Deserialization from serial i/o
|
/// Deserialization from serial i/o.
|
||||||
pub trait Deserialize : Sized {
|
pub trait Deserialize : Sized {
|
||||||
/// Serialization error produced by deserialization routine.
|
/// Serialization error produced by deserialization routine.
|
||||||
type Error: From<io::Error>;
|
type Error: From<io::Error>;
|
||||||
@ -82,68 +82,68 @@ pub trait Serialize {
|
|||||||
/// Deserialization/serialization error
|
/// Deserialization/serialization error
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Unexpected end of input
|
/// Unexpected end of input.
|
||||||
UnexpectedEof,
|
UnexpectedEof,
|
||||||
/// Invalid magic
|
/// Invalid magic.
|
||||||
InvalidMagic,
|
InvalidMagic,
|
||||||
/// Unsupported version
|
/// Unsupported version.
|
||||||
UnsupportedVersion(u32),
|
UnsupportedVersion(u32),
|
||||||
/// Inconsistence between declared and actual length
|
/// Inconsistence between declared and actual length.
|
||||||
InconsistentLength {
|
InconsistentLength {
|
||||||
/// Expected length of the definition
|
/// Expected length of the definition.
|
||||||
expected: usize,
|
expected: usize,
|
||||||
/// Actual length of the definition
|
/// Actual length of the definition.
|
||||||
actual: usize
|
actual: usize
|
||||||
},
|
},
|
||||||
/// Other static error
|
/// Other static error.
|
||||||
Other(&'static str),
|
Other(&'static str),
|
||||||
/// Other allocated error
|
/// Other allocated error.
|
||||||
HeapOther(String),
|
HeapOther(String),
|
||||||
/// Invalid/unknown value type declaration
|
/// Invalid/unknown value type declaration.
|
||||||
UnknownValueType(i8),
|
UnknownValueType(i8),
|
||||||
/// Invalid/unknown table element type declaration
|
/// Invalid/unknown table element type declaration.
|
||||||
UnknownTableElementType(i8),
|
UnknownTableElementType(i8),
|
||||||
/// Non-utf8 string
|
/// Non-utf8 string.
|
||||||
NonUtf8String,
|
NonUtf8String,
|
||||||
/// Unknown external kind code
|
/// Unknown external kind code.
|
||||||
UnknownExternalKind(u8),
|
UnknownExternalKind(u8),
|
||||||
/// Unknown internal kind code
|
/// Unknown internal kind code.
|
||||||
UnknownInternalKind(u8),
|
UnknownInternalKind(u8),
|
||||||
/// Unknown opcode encountered
|
/// Unknown opcode encountered.
|
||||||
UnknownOpcode(u8),
|
UnknownOpcode(u8),
|
||||||
/// Unknown SIMD opcode encountered
|
/// Unknown SIMD opcode encountered.
|
||||||
UnknownSimdOpcode(u32),
|
UnknownSimdOpcode(u32),
|
||||||
/// Invalid VarUint1 value
|
/// Invalid VarUint1 value.
|
||||||
InvalidVarUint1(u8),
|
InvalidVarUint1(u8),
|
||||||
/// Invalid VarInt32 value
|
/// Invalid VarInt32 value.
|
||||||
InvalidVarInt32,
|
InvalidVarInt32,
|
||||||
/// Invalid VarInt64 value
|
/// Invalid VarInt64 value.
|
||||||
InvalidVarInt64,
|
InvalidVarInt64,
|
||||||
/// Invalid VarUint32 value
|
/// Invalid VarUint32 value.
|
||||||
InvalidVarUint32,
|
InvalidVarUint32,
|
||||||
/// Invalid VarUint64 value
|
/// Invalid VarUint64 value.
|
||||||
InvalidVarUint64,
|
InvalidVarUint64,
|
||||||
/// Inconsistent metadata
|
/// Inconsistent metadata.
|
||||||
InconsistentMetadata,
|
InconsistentMetadata,
|
||||||
/// Invalid section id
|
/// Invalid section id.
|
||||||
InvalidSectionId(u8),
|
InvalidSectionId(u8),
|
||||||
/// Sections are out of order
|
/// Sections are out of order.
|
||||||
SectionsOutOfOrder,
|
SectionsOutOfOrder,
|
||||||
/// Duplicated sections
|
/// Duplicated sections.
|
||||||
DuplicatedSections(u8),
|
DuplicatedSections(u8),
|
||||||
/// Invalid memory reference (should be 0)
|
/// Invalid memory reference (should be 0).
|
||||||
InvalidMemoryReference(u8),
|
InvalidMemoryReference(u8),
|
||||||
/// Invalid table reference (should be 0)
|
/// Invalid table reference (should be 0).
|
||||||
InvalidTableReference(u8),
|
InvalidTableReference(u8),
|
||||||
/// Invalid value used for flags in limits type.
|
/// Invalid value used for flags in limits type.
|
||||||
InvalidLimitsFlags(u8),
|
InvalidLimitsFlags(u8),
|
||||||
/// Unknown function form (should be 0x60)
|
/// Unknown function form (should be 0x60).
|
||||||
UnknownFunctionForm(u8),
|
UnknownFunctionForm(u8),
|
||||||
/// Invalid varint7 (should be in -64..63 range)
|
/// Invalid varint7 (should be in -64..63 range).
|
||||||
InvalidVarInt7(u8),
|
InvalidVarInt7(u8),
|
||||||
/// Number of function body entries and signatures does not match
|
/// Number of function body entries and signatures does not match.
|
||||||
InconsistentCode,
|
InconsistentCode,
|
||||||
/// Only flags 0, 1, and 2 are accepted on segments
|
/// Only flags 0, 1, and 2 are accepted on segments.
|
||||||
InvalidSegmentFlags(u32),
|
InvalidSegmentFlags(u32),
|
||||||
/// Sum of counts of locals is greater than 2^32.
|
/// Sum of counts of locals is greater than 2^32.
|
||||||
TooManyLocals,
|
TooManyLocals,
|
||||||
@ -232,7 +232,7 @@ impl From<io::Error> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unparsed part of the module/section
|
/// Unparsed part of the module/section.
|
||||||
pub struct Unparsed(pub Vec<u8>);
|
pub struct Unparsed(pub Vec<u8>);
|
||||||
|
|
||||||
impl Deserialize for Unparsed {
|
impl Deserialize for Unparsed {
|
||||||
|
@ -61,12 +61,14 @@ impl Module {
|
|||||||
pub fn version(&self) -> u32 { self.version }
|
pub fn version(&self) -> u32 { self.version }
|
||||||
|
|
||||||
/// Sections list.
|
/// Sections list.
|
||||||
|
///
|
||||||
/// Each known section is optional and may appear at most once.
|
/// Each known section is optional and may appear at most once.
|
||||||
pub fn sections(&self) -> &[Section] {
|
pub fn sections(&self) -> &[Section] {
|
||||||
&self.sections
|
&self.sections
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sections list (mutable)
|
/// Sections list (mutable).
|
||||||
|
///
|
||||||
/// Each known section is optional and may appear at most once.
|
/// Each known section is optional and may appear at most once.
|
||||||
pub fn sections_mut(&mut self) -> &mut Vec<Section> {
|
pub fn sections_mut(&mut self) -> &mut Vec<Section> {
|
||||||
&mut self.sections
|
&mut self.sections
|
||||||
@ -241,7 +243,34 @@ impl Module {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Changes the module's start section.
|
||||||
|
pub fn set_start_section(&mut self, new_start : u32) {
|
||||||
|
for section in self.sections_mut() {
|
||||||
|
if let &mut Section::Start(_sect) = section {
|
||||||
|
*section = Section::Start(new_start);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.sections_mut().push(Section::Start(new_start));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Removes the module's start section.
|
||||||
|
pub fn clear_start_section(&mut self) {
|
||||||
|
let sections = self.sections_mut();
|
||||||
|
let mut rmidx = sections.len();
|
||||||
|
for (index, section) in sections.iter_mut().enumerate() {
|
||||||
|
if let Section::Start(_sect) = section {
|
||||||
|
rmidx = index;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if rmidx < sections.len() {
|
||||||
|
sections.remove(rmidx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Functions signatures section reference, if any.
|
/// Functions signatures section reference, if any.
|
||||||
|
///
|
||||||
/// NOTE: name section is not parsed by default so `names_section` could return None even if name section exists.
|
/// NOTE: name section is not parsed by default so `names_section` could return None even if name section exists.
|
||||||
/// Call `parse_names` to parse name section
|
/// Call `parse_names` to parse name section
|
||||||
pub fn names_section(&self) -> Option<&NameSection> {
|
pub fn names_section(&self) -> Option<&NameSection> {
|
||||||
@ -252,6 +281,7 @@ impl Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Functions signatures section mutable reference, if any.
|
/// Functions signatures section mutable reference, if any.
|
||||||
|
///
|
||||||
/// NOTE: name section is not parsed by default so `names_section` could return None even if name section exists.
|
/// NOTE: name section is not parsed by default so `names_section` could return None even if name section exists.
|
||||||
/// Call `parse_names` to parse name section
|
/// Call `parse_names` to parse name section
|
||||||
pub fn names_section_mut(&mut self) -> Option<&mut NameSection> {
|
pub fn names_section_mut(&mut self) -> Option<&mut NameSection> {
|
||||||
@ -261,7 +291,8 @@ impl Module {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to parse name section in place
|
/// Try to parse name section in place/
|
||||||
|
///
|
||||||
/// Corresponding custom section with proper header will convert to name sections
|
/// Corresponding custom section with proper header will convert to name sections
|
||||||
/// If some of them will fail to be decoded, Err variant is returned with the list of
|
/// If some of them will fail to be decoded, Err variant is returned with the list of
|
||||||
/// (index, Error) tuples of failed sections.
|
/// (index, Error) tuples of failed sections.
|
||||||
@ -295,7 +326,8 @@ impl Module {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to parse reloc section in place
|
/// Try to parse reloc section in place.
|
||||||
|
///
|
||||||
/// Corresponding custom section with proper header will convert to reloc sections
|
/// Corresponding custom section with proper header will convert to reloc sections
|
||||||
/// If some of them will fail to be decoded, Err variant is returned with the list of
|
/// If some of them will fail to be decoded, Err variant is returned with the list of
|
||||||
/// (index, Error) tuples of failed sections.
|
/// (index, Error) tuples of failed sections.
|
||||||
@ -336,7 +368,7 @@ impl Module {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Count imports by provided type
|
/// Count imports by provided type.
|
||||||
pub fn import_count(&self, count_type: ImportCountType) -> usize {
|
pub fn import_count(&self, count_type: ImportCountType) -> usize {
|
||||||
self.import_section()
|
self.import_section()
|
||||||
.map(|is|
|
.map(|is|
|
||||||
@ -350,25 +382,25 @@ impl Module {
|
|||||||
.unwrap_or(0)
|
.unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query functions space
|
/// Query functions space.
|
||||||
pub fn functions_space(&self) -> usize {
|
pub fn functions_space(&self) -> usize {
|
||||||
self.import_count(ImportCountType::Function) +
|
self.import_count(ImportCountType::Function) +
|
||||||
self.function_section().map(|fs| fs.entries().len()).unwrap_or(0)
|
self.function_section().map(|fs| fs.entries().len()).unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query globals space
|
/// Query globals space.
|
||||||
pub fn globals_space(&self) -> usize {
|
pub fn globals_space(&self) -> usize {
|
||||||
self.import_count(ImportCountType::Global) +
|
self.import_count(ImportCountType::Global) +
|
||||||
self.global_section().map(|gs| gs.entries().len()).unwrap_or(0)
|
self.global_section().map(|gs| gs.entries().len()).unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query table space
|
/// Query table space.
|
||||||
pub fn table_space(&self) -> usize {
|
pub fn table_space(&self) -> usize {
|
||||||
self.import_count(ImportCountType::Table) +
|
self.import_count(ImportCountType::Table) +
|
||||||
self.table_section().map(|ts| ts.entries().len()).unwrap_or(0)
|
self.table_section().map(|ts| ts.entries().len()).unwrap_or(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Query memory space
|
/// Query memory space.
|
||||||
pub fn memory_space(&self) -> usize {
|
pub fn memory_space(&self) -> usize {
|
||||||
self.import_count(ImportCountType::Memory) +
|
self.import_count(ImportCountType::Memory) +
|
||||||
self.memory_section().map(|ms| ms.entries().len()).unwrap_or(0)
|
self.memory_section().map(|ms| ms.entries().len()).unwrap_or(0)
|
||||||
@ -463,7 +495,7 @@ impl<'a> io::Read for PeekSection<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns size of the module in the provided stream
|
/// Returns size of the module in the provided stream.
|
||||||
pub fn peek_size(source: &[u8]) -> usize {
|
pub fn peek_size(source: &[u8]) -> usize {
|
||||||
if source.len() < 9 {
|
if source.len() < 9 {
|
||||||
return 0;
|
return 0;
|
||||||
@ -713,4 +745,14 @@ mod integration_tests {
|
|||||||
let module = deserialize_file("./res/cases/v1/two-mems.wasm").expect("failed to deserialize");
|
let module = deserialize_file("./res/cases/v1/two-mems.wasm").expect("failed to deserialize");
|
||||||
assert_eq!(module.memory_space(), 2);
|
assert_eq!(module.memory_space(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn mut_start() {
|
||||||
|
let mut module = deserialize_file("./res/cases/v1/start_mut.wasm").expect("failed to deserialize");
|
||||||
|
assert_eq!(module.start_section().expect("Did not find any start section"), 1);
|
||||||
|
module.set_start_section(0);
|
||||||
|
assert_eq!(module.start_section().expect("Did not find any start section"), 0);
|
||||||
|
module.clear_start_section();
|
||||||
|
assert_eq!(None, module.start_section());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,13 @@ pub struct InitExpr(Vec<Instruction>);
|
|||||||
|
|
||||||
impl InitExpr {
|
impl InitExpr {
|
||||||
/// New initialization expression from instruction list.
|
/// New initialization expression from instruction list.
|
||||||
|
///
|
||||||
/// `code` must end with the `Instruction::End` instruction!
|
/// `code` must end with the `Instruction::End` instruction!
|
||||||
pub fn new(code: Vec<Instruction>) -> Self {
|
pub fn new(code: Vec<Instruction>) -> Self {
|
||||||
InitExpr(code)
|
InitExpr(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Empty expression with only `Instruction::End` instruction
|
/// Empty expression with only `Instruction::End` instruction.
|
||||||
pub fn empty() -> Self {
|
pub fn empty() -> Self {
|
||||||
InitExpr(vec![Instruction::End])
|
InitExpr(vec![Instruction::End])
|
||||||
}
|
}
|
||||||
@ -102,7 +103,7 @@ impl Deserialize for InitExpr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Instruction
|
/// Instruction.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum Instruction {
|
pub enum Instruction {
|
||||||
@ -561,7 +562,8 @@ impl Instruction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Is this instruction determines the termination of instruction sequence
|
/// Is this instruction determines the termination of instruction sequence?
|
||||||
|
///
|
||||||
/// `true` for `Instruction::End`
|
/// `true` for `Instruction::End`
|
||||||
pub fn is_terminal(&self) -> bool {
|
pub fn is_terminal(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
|
@ -141,7 +141,7 @@ impl From<u64> for VarUint64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 7-bit unsigned integer, encoded in LEB128 (always 1 byte length)
|
/// 7-bit unsigned integer, encoded in LEB128 (always 1 byte length).
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct VarUint7(u8);
|
pub struct VarUint7(u8);
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ impl Serialize for Uint8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// 32-bit signed integer, encoded in LEB128 (can be 1-5 bytes length)
|
/// 32-bit signed integer, encoded in LEB128 (can be 1-5 bytes length).
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct VarInt32(i32);
|
pub struct VarInt32(i32);
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ impl Serialize for VarInt32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 64-bit signed integer, encoded in LEB128 (can be 1-9 bytes length)
|
/// 64-bit signed integer, encoded in LEB128 (can be 1-9 bytes length).
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct VarInt64(i64);
|
pub struct VarInt64(i64);
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ impl Serialize for VarInt64 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 32-bit unsigned integer, encoded in little endian
|
/// 32-bit unsigned integer, encoded in little endian.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct Uint32(u32);
|
pub struct Uint32(u32);
|
||||||
|
|
||||||
@ -442,7 +442,7 @@ impl From<u32> for Uint32 {
|
|||||||
fn from(u: u32) -> Self { Uint32(u) }
|
fn from(u: u32) -> Self { Uint32(u) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 64-bit unsigned integer, encoded in little endian
|
/// 64-bit unsigned integer, encoded in little endian.
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct Uint64(u64);
|
pub struct Uint64(u64);
|
||||||
|
|
||||||
@ -479,7 +479,7 @@ impl From<Uint64> for u64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// VarUint1, 1-bit value (0/1)
|
/// VarUint1, 1-bit value (0/1).
|
||||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct VarUint1(bool);
|
pub struct VarUint1(bool);
|
||||||
|
|
||||||
@ -545,7 +545,7 @@ impl Serialize for String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// List for reading sequence of elements typed `T`, given
|
/// List for reading sequence of elements typed `T`, given
|
||||||
/// they are preceded by length (serialized as VarUint32)
|
/// they are preceded by length (serialized as VarUint32).
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CountedList<T: Deserialize>(Vec<T>);
|
pub struct CountedList<T: Deserialize>(Vec<T>);
|
||||||
|
|
||||||
@ -574,7 +574,7 @@ pub struct CountedWriter<'a, W: 'a + io::Write> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, W: 'a + io::Write> CountedWriter<'a, W> {
|
impl<'a, W: 'a + io::Write> CountedWriter<'a, W> {
|
||||||
/// New counted writer on top of the given serial writer
|
/// New counted writer on top of the given serial writer.
|
||||||
pub fn new(writer: &'a mut W) -> Self {
|
pub fn new(writer: &'a mut W) -> Self {
|
||||||
CountedWriter {
|
CountedWriter {
|
||||||
writer: writer,
|
writer: writer,
|
||||||
@ -603,7 +603,7 @@ impl<'a, W: 'a + io::Write> io::Write for CountedWriter<'a, W> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Helper struct to write series of `T` preceded by the length of the sequence
|
/// Helper struct to write series of `T` preceded by the length of the sequence
|
||||||
/// serialized as VarUint32
|
/// serialized as VarUint32.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CountedListWriter<I: Serialize<Error=::elements::Error>, T: IntoIterator<Item=I>>(pub usize, pub T);
|
pub struct CountedListWriter<I: Serialize<Error=::elements::Error>, T: IntoIterator<Item=I>>(pub usize, pub T);
|
||||||
|
|
||||||
|
@ -35,34 +35,34 @@ const ENTRIES_BUFFER_LENGTH: usize = 16384;
|
|||||||
pub enum Section {
|
pub enum Section {
|
||||||
/// Section is unparsed.
|
/// Section is unparsed.
|
||||||
Unparsed {
|
Unparsed {
|
||||||
/// id of the unparsed section
|
/// id of the unparsed section.
|
||||||
id: u8,
|
id: u8,
|
||||||
/// raw bytes of the unparsed section
|
/// raw bytes of the unparsed section.
|
||||||
payload: Vec<u8>,
|
payload: Vec<u8>,
|
||||||
},
|
},
|
||||||
/// Custom section (`id=0`)
|
/// Custom section (`id=0`).
|
||||||
Custom(CustomSection),
|
Custom(CustomSection),
|
||||||
/// Types section
|
/// Types section.
|
||||||
Type(TypeSection),
|
Type(TypeSection),
|
||||||
/// Import section
|
/// Import section.
|
||||||
Import(ImportSection),
|
Import(ImportSection),
|
||||||
/// Function signatures section
|
/// Function signatures section.
|
||||||
Function(FunctionSection),
|
Function(FunctionSection),
|
||||||
/// Table definition section
|
/// Table definition section.
|
||||||
Table(TableSection),
|
Table(TableSection),
|
||||||
/// Memory definition section
|
/// Memory definition section.
|
||||||
Memory(MemorySection),
|
Memory(MemorySection),
|
||||||
/// Global entries section
|
/// Global entries section.
|
||||||
Global(GlobalSection),
|
Global(GlobalSection),
|
||||||
/// Export definitions
|
/// Export definitions.
|
||||||
Export(ExportSection),
|
Export(ExportSection),
|
||||||
/// Entry reference of the module
|
/// Entry reference of the module.
|
||||||
Start(u32),
|
Start(u32),
|
||||||
/// Elements section
|
/// Elements section.
|
||||||
Element(ElementSection),
|
Element(ElementSection),
|
||||||
/// Function bodies section
|
/// Function bodies section.
|
||||||
Code(CodeSection),
|
Code(CodeSection),
|
||||||
/// Data definition section
|
/// Data definition section.
|
||||||
Data(DataSection),
|
Data(DataSection),
|
||||||
/// Name section.
|
/// Name section.
|
||||||
///
|
///
|
||||||
@ -72,7 +72,7 @@ pub enum Section {
|
|||||||
///
|
///
|
||||||
/// Note that initially it is not parsed until `parse_reloc` is called explicitly.
|
/// Note that initially it is not parsed until `parse_reloc` is called explicitly.
|
||||||
/// Also note that currently there are serialization (but not de-serialization)
|
/// Also note that currently there are serialization (but not de-serialization)
|
||||||
/// issues with this section (#198)
|
/// issues with this section (#198).
|
||||||
Reloc(RelocSection),
|
Reloc(RelocSection),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ fn read_entries<R: io::Read, T: Deserialize<Error=::elements::Error>>(reader: &m
|
|||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Custom section
|
/// Custom section.
|
||||||
#[derive(Debug, Default, Clone, PartialEq)]
|
#[derive(Debug, Default, Clone, PartialEq)]
|
||||||
pub struct CustomSection {
|
pub struct CustomSection {
|
||||||
name: String,
|
name: String,
|
||||||
@ -287,27 +287,27 @@ pub struct CustomSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CustomSection {
|
impl CustomSection {
|
||||||
/// Creates a new custom section with the given name and payload
|
/// Creates a new custom section with the given name and payload.
|
||||||
pub fn new(name: String, payload: Vec<u8>) -> CustomSection {
|
pub fn new(name: String, payload: Vec<u8>) -> CustomSection {
|
||||||
CustomSection { name, payload }
|
CustomSection { name, payload }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Name of the custom section
|
/// Name of the custom section.
|
||||||
pub fn name(&self) -> &str {
|
pub fn name(&self) -> &str {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Payload of the custom secion
|
/// Payload of the custom secion.
|
||||||
pub fn payload(&self) -> &[u8] {
|
pub fn payload(&self) -> &[u8] {
|
||||||
&self.payload
|
&self.payload
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Name of the custom section (mutable)
|
/// Name of the custom section (mutable).
|
||||||
pub fn name_mut(&mut self) -> &mut String {
|
pub fn name_mut(&mut self) -> &mut String {
|
||||||
&mut self.name
|
&mut self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Payload of the custom section (mutable)
|
/// Payload of the custom section (mutable).
|
||||||
pub fn payload_mut(&mut self) -> &mut Vec<u8> {
|
pub fn payload_mut(&mut self) -> &mut Vec<u8> {
|
||||||
&mut self.payload
|
&mut self.payload
|
||||||
}
|
}
|
||||||
@ -340,22 +340,22 @@ impl Serialize for CustomSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Section with type declarations
|
/// Section with type declarations.
|
||||||
#[derive(Debug, Default, Clone, PartialEq)]
|
#[derive(Debug, Default, Clone, PartialEq)]
|
||||||
pub struct TypeSection(Vec<Type>);
|
pub struct TypeSection(Vec<Type>);
|
||||||
|
|
||||||
impl TypeSection {
|
impl TypeSection {
|
||||||
/// New type section with provided types
|
/// New type section with provided types.
|
||||||
pub fn with_types(types: Vec<Type>) -> Self {
|
pub fn with_types(types: Vec<Type>) -> Self {
|
||||||
TypeSection(types)
|
TypeSection(types)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of type declarations
|
/// List of type declarations.
|
||||||
pub fn types(&self) -> &[Type] {
|
pub fn types(&self) -> &[Type] {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of type declarations (mutable)
|
/// List of type declarations (mutable).
|
||||||
pub fn types_mut(&mut self) -> &mut Vec<Type> {
|
pub fn types_mut(&mut self) -> &mut Vec<Type> {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
@ -390,7 +390,7 @@ impl Serialize for TypeSection {
|
|||||||
pub struct ImportSection(Vec<ImportEntry>);
|
pub struct ImportSection(Vec<ImportEntry>);
|
||||||
|
|
||||||
impl ImportSection {
|
impl ImportSection {
|
||||||
/// New import section with provided types
|
/// New import section with provided types.
|
||||||
pub fn with_entries(entries: Vec<ImportEntry>) -> Self {
|
pub fn with_entries(entries: Vec<ImportEntry>) -> Self {
|
||||||
ImportSection(entries)
|
ImportSection(entries)
|
||||||
}
|
}
|
||||||
@ -405,7 +405,7 @@ impl ImportSection {
|
|||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns number of functions
|
/// Returns number of functions.
|
||||||
pub fn functions(&self) -> usize {
|
pub fn functions(&self) -> usize {
|
||||||
self.0.iter()
|
self.0.iter()
|
||||||
.filter(|entry| match entry.external() { &External::Function(_) => true, _ => false })
|
.filter(|entry| match entry.external() { &External::Function(_) => true, _ => false })
|
||||||
@ -449,17 +449,17 @@ impl Serialize for ImportSection {
|
|||||||
pub struct FunctionSection(Vec<Func>);
|
pub struct FunctionSection(Vec<Func>);
|
||||||
|
|
||||||
impl FunctionSection {
|
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 {
|
||||||
FunctionSection(entries)
|
FunctionSection(entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of all functions in the section, mutable
|
/// List of all functions in the section, mutable.
|
||||||
pub fn entries_mut(&mut self) -> &mut Vec<Func> {
|
pub fn entries_mut(&mut self) -> &mut Vec<Func> {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of all functions in the section
|
/// List of all functions in the section.
|
||||||
pub fn entries(&self) -> &[Func] {
|
pub fn entries(&self) -> &[Func] {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
@ -499,7 +499,7 @@ impl TableSection {
|
|||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New table section with provided table entries
|
/// New table section with provided table entries.
|
||||||
pub fn with_entries(entries: Vec<TableType>) -> Self {
|
pub fn with_entries(entries: Vec<TableType>) -> Self {
|
||||||
TableSection(entries)
|
TableSection(entries)
|
||||||
}
|
}
|
||||||
@ -544,12 +544,12 @@ impl MemorySection {
|
|||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New memory section with memory types
|
/// New memory section with memory types.
|
||||||
pub fn with_entries(entries: Vec<MemoryType>) -> Self {
|
pub fn with_entries(entries: Vec<MemoryType>) -> Self {
|
||||||
MemorySection(entries)
|
MemorySection(entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mutable list of all memory entries in the section
|
/// Mutable list of all memory entries in the section.
|
||||||
pub fn entries_mut(&mut self) -> &mut Vec<MemoryType> {
|
pub fn entries_mut(&mut self) -> &mut Vec<MemoryType> {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
@ -584,17 +584,17 @@ impl Serialize for MemorySection {
|
|||||||
pub struct GlobalSection(Vec<GlobalEntry>);
|
pub struct GlobalSection(Vec<GlobalEntry>);
|
||||||
|
|
||||||
impl GlobalSection {
|
impl GlobalSection {
|
||||||
/// List of all global entries in the section
|
/// List of all global entries in the section.
|
||||||
pub fn entries(&self) -> &[GlobalEntry] {
|
pub fn entries(&self) -> &[GlobalEntry] {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New global section from list of global entries
|
/// New global section from list of global entries.
|
||||||
pub fn with_entries(entries: Vec<GlobalEntry>) -> Self {
|
pub fn with_entries(entries: Vec<GlobalEntry>) -> Self {
|
||||||
GlobalSection(entries)
|
GlobalSection(entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of all global entries in the section (mutable)
|
/// List of all global entries in the section (mutable).
|
||||||
pub fn entries_mut(&mut self) -> &mut Vec<GlobalEntry> {
|
pub fn entries_mut(&mut self) -> &mut Vec<GlobalEntry> {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
@ -629,17 +629,17 @@ impl Serialize for GlobalSection {
|
|||||||
pub struct ExportSection(Vec<ExportEntry>);
|
pub struct ExportSection(Vec<ExportEntry>);
|
||||||
|
|
||||||
impl ExportSection {
|
impl ExportSection {
|
||||||
/// List of all export entries in the section
|
/// List of all export entries in the section.
|
||||||
pub fn entries(&self) -> &[ExportEntry] {
|
pub fn entries(&self) -> &[ExportEntry] {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New export section from list of export entries
|
/// New export section from list of export entries.
|
||||||
pub fn with_entries(entries: Vec<ExportEntry>) -> Self {
|
pub fn with_entries(entries: Vec<ExportEntry>) -> Self {
|
||||||
ExportSection(entries)
|
ExportSection(entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of all export entries in the section (mutable)
|
/// List of all export entries in the section (mutable).
|
||||||
pub fn entries_mut(&mut self) -> &mut Vec<ExportEntry> {
|
pub fn entries_mut(&mut self) -> &mut Vec<ExportEntry> {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
@ -674,7 +674,7 @@ impl Serialize for ExportSection {
|
|||||||
pub struct CodeSection(Vec<FuncBody>);
|
pub struct CodeSection(Vec<FuncBody>);
|
||||||
|
|
||||||
impl CodeSection {
|
impl CodeSection {
|
||||||
/// New code section with specified function bodies
|
/// New code section with specified function bodies.
|
||||||
pub fn with_bodies(bodies: Vec<FuncBody>) -> Self {
|
pub fn with_bodies(bodies: Vec<FuncBody>) -> Self {
|
||||||
CodeSection(bodies)
|
CodeSection(bodies)
|
||||||
}
|
}
|
||||||
@ -719,17 +719,17 @@ impl Serialize for CodeSection {
|
|||||||
pub struct ElementSection(Vec<ElementSegment>);
|
pub struct ElementSection(Vec<ElementSegment>);
|
||||||
|
|
||||||
impl ElementSection {
|
impl ElementSection {
|
||||||
/// New elements section
|
/// New elements section.
|
||||||
pub fn with_entries(entries: Vec<ElementSegment>) -> Self {
|
pub fn with_entries(entries: Vec<ElementSegment>) -> Self {
|
||||||
ElementSection(entries)
|
ElementSection(entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// New elements entries in the section
|
/// New elements entries in the section.
|
||||||
pub fn entries(&self) -> &[ElementSegment] {
|
pub fn entries(&self) -> &[ElementSegment] {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of all data entries in the section (mutable)
|
/// List of all data entries in the section (mutable).
|
||||||
pub fn entries_mut(&mut self) -> &mut Vec<ElementSegment> {
|
pub fn entries_mut(&mut self) -> &mut Vec<ElementSegment> {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
@ -764,17 +764,17 @@ impl Serialize for ElementSection {
|
|||||||
pub struct DataSection(Vec<DataSegment>);
|
pub struct DataSection(Vec<DataSegment>);
|
||||||
|
|
||||||
impl DataSection {
|
impl DataSection {
|
||||||
/// New data section
|
/// New data section.
|
||||||
pub fn with_entries(entries: Vec<DataSegment>) -> Self {
|
pub fn with_entries(entries: Vec<DataSegment>) -> Self {
|
||||||
DataSection(entries)
|
DataSection(entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of all data entries in the section
|
/// List of all data entries in the section.
|
||||||
pub fn entries(&self) -> &[DataSegment] {
|
pub fn entries(&self) -> &[DataSegment] {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// List of all data entries in the section (mutable)
|
/// List of all data entries in the section (mutable).
|
||||||
pub fn entries_mut(&mut self) -> &mut Vec<DataSegment> {
|
pub fn entries_mut(&mut self) -> &mut Vec<DataSegment> {
|
||||||
&mut self.0
|
&mut self.0
|
||||||
}
|
}
|
||||||
|
@ -143,10 +143,10 @@ impl DataSegment {
|
|||||||
/// Initial value of the data segment (mutable).
|
/// Initial value of the data segment (mutable).
|
||||||
pub fn value_mut(&mut self) -> &mut Vec<u8> { &mut self.value }
|
pub fn value_mut(&mut self) -> &mut Vec<u8> { &mut self.value }
|
||||||
|
|
||||||
/// Whether or not this data segment is "passive"
|
/// Whether or not this data segment is "passive".
|
||||||
pub fn passive(&self) -> bool { self.passive }
|
pub fn passive(&self) -> bool { self.passive }
|
||||||
|
|
||||||
/// Whether or not this data segment is "passive" (mutable)
|
/// Whether or not this data segment is "passive" (mutable).
|
||||||
pub fn passive_mut(&mut self) -> &mut bool { &mut self.passive }
|
pub fn passive_mut(&mut self) -> &mut bool { &mut self.passive }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user