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>
impl<'a> Expression<'a>
Sourcepub fn one(instr: Instruction<'a>) -> Expression<'a>
pub fn one(instr: Instruction<'a>) -> Expression<'a>
Creates an expression from the single instr
specified.
Sourcepub fn parse_folded_instruction(parser: Parser<'a>) -> Result<Self>
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.