Struct Expression

Source
pub struct Expression<'a> {
    pub instrs: Box<[Instruction<'a>]>,
    pub branch_hints: Box<[BranchHint]>,
    pub instr_spans: Option<Box<[Span]>>,
}
Expand description

An expression, or a list of instructions, in the WebAssembly text format.

This expression type will parse s-expression-folded instructions into a flat list of instructions for emission later on. The implicit end instruction at the end of an expression is not included in the instrs field.

Fields§

§instrs: Box<[Instruction<'a>]>

Instructions in this expression.

§branch_hints: Box<[BranchHint]>

Branch hints, if any, found while parsing instructions.

§instr_spans: Option<Box<[Span]>>

Optionally parsed spans of all instructions in instrs.

This value is None as it’s disabled by default. This can be enabled through the ParseBuffer::track_instr_spans function.

This is not tracked by default due to the memory overhead and limited use of this field.

Implementations§

Source§

impl<'a> Expression<'a>

Source

pub fn one(instr: Instruction<'a>) -> Expression<'a>

Creates an expression from the single instr specified.

Source

pub fn parse_folded_instruction(parser: Parser<'a>) -> Result<Self>

Parse an expression formed from a single folded instruction.

Attempts to parse an expression formed from a single folded instruction.

This method will mutate the state of parser after attempting to parse the expression. If an error happens then it is likely fatal and there is no guarantee of how many tokens have been consumed from parser.

§Errors

This function will return an error if the expression could not be parsed. Note that creating an crate::Error is not exactly a cheap operation, so crate::Error is typically fatal and propagated all the way back to the top parse call site.

Trait Implementations§

Source§

impl<'a> Debug for Expression<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Parse<'a> for Expression<'a>

Source§

fn parse(parser: Parser<'a>) -> Result<Self>

Attempts to parse Self from parser, returning an error if it could not be parsed. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Expression<'a>

§

impl<'a> RefUnwindSafe for Expression<'a>

§

impl<'a> Send for Expression<'a>

§

impl<'a> Sync for Expression<'a>

§

impl<'a> Unpin for Expression<'a>

§

impl<'a> UnwindSafe for Expression<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.