Struct wasmtime_environ::wasmparser::OperatorsReader
source · pub struct OperatorsReader<'a> { /* private fields */ }
Expand description
A reader for a core WebAssembly function’s operators.
Implementations§
source§impl<'a> OperatorsReader<'a>
impl<'a> OperatorsReader<'a>
sourcepub fn original_position(&self) -> usize
pub fn original_position(&self) -> usize
Gets the original position of the reader.
sourcepub fn allow_memarg64(&mut self, allow: bool)
pub fn allow_memarg64(&mut self, allow: bool)
Whether or not to allow 64-bit memory arguments in the the operators being read.
This is intended to be true
when support for the memory64
WebAssembly proposal is also enabled.
sourcepub fn ensure_end(&self) -> Result<(), BinaryReaderError>
pub fn ensure_end(&self) -> Result<(), BinaryReaderError>
Ensures the reader is at the end.
This function returns an error if there is extra data after the operators.
sourcepub fn read<'b>(&mut self) -> Result<Operator<'b>, BinaryReaderError>where
'a: 'b,
pub fn read<'b>(&mut self) -> Result<Operator<'b>, BinaryReaderError>where 'a: 'b,
Reads an operator from the reader.
sourcepub fn into_iter_with_offsets<'b>(self) -> OperatorsIteratorWithOffsets<'b> ⓘwhere
'a: 'b,
pub fn into_iter_with_offsets<'b>(self) -> OperatorsIteratorWithOffsets<'b> ⓘwhere 'a: 'b,
Converts to an iterator of operators paired with offsets.
sourcepub fn read_with_offset<'b>(
&mut self
) -> Result<(Operator<'b>, usize), BinaryReaderError>where
'a: 'b,
pub fn read_with_offset<'b>( &mut self ) -> Result<(Operator<'b>, usize), BinaryReaderError>where 'a: 'b,
Reads an operator with its offset.
sourcepub fn visit_with_offset<T>(
&mut self,
visitor: &mut T
) -> Result<<T as VisitOperator<'a>>::Output, BinaryReaderError>where
T: VisitOperator<'a>,
pub fn visit_with_offset<T>( &mut self, visitor: &mut T ) -> Result<<T as VisitOperator<'a>>::Output, BinaryReaderError>where T: VisitOperator<'a>,
Visits an operator with its offset.
sourcepub fn get_binary_reader(&self) -> BinaryReader<'a>
pub fn get_binary_reader(&self) -> BinaryReader<'a>
Gets a binary reader from this operators reader.
Trait Implementations§
source§impl<'a> Clone for OperatorsReader<'a>
impl<'a> Clone for OperatorsReader<'a>
source§fn clone(&self) -> OperatorsReader<'a>
fn clone(&self) -> OperatorsReader<'a>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<'a> IntoIterator for OperatorsReader<'a>
impl<'a> IntoIterator for OperatorsReader<'a>
source§fn into_iter(self) -> <OperatorsReader<'a> as IntoIterator>::IntoIter
fn into_iter(self) -> <OperatorsReader<'a> as IntoIterator>::IntoIter
Reads content of the code section.
Examples
use wasmparser::{Operator, CodeSectionReader, Result};
let mut code_reader = CodeSectionReader::new(data, 0).unwrap();
for _ in 0..code_reader.get_count() {
let body = code_reader.read().expect("function body");
let mut op_reader = body.get_operators_reader().expect("op reader");
let ops = op_reader.into_iter().collect::<Result<Vec<Operator>>>().expect("ops");
assert!(
if let [Operator::Nop, Operator::End] = ops.as_slice() { true } else { false },
"found {:?}",
ops
);
}
§type Item = Result<Operator<'a>, BinaryReaderError>
type Item = Result<Operator<'a>, BinaryReaderError>
The type of the elements being iterated over.
§type IntoIter = OperatorsIterator<'a>
type IntoIter = OperatorsIterator<'a>
Which kind of iterator are we turning this into?
Auto Trait Implementations§
impl<'a> RefUnwindSafe for OperatorsReader<'a>
impl<'a> Send for OperatorsReader<'a>
impl<'a> Sync for OperatorsReader<'a>
impl<'a> Unpin for OperatorsReader<'a>
impl<'a> UnwindSafe for OperatorsReader<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more