Trait BasicExprBuilder

Source
pub trait BasicExprBuilder {
    // Required methods
    fn push(&mut self, _: Stmt);
    fn emit_error_at(&mut self, _: ErrorSpan, _: Arguments<'_>);
    fn bit_or(&mut self, _: Expr, _: Value) -> Option<Expr>;
    fn bit_and(&mut self, _: Expr, _: Value) -> Option<Expr>;
    fn bit_xor(&mut self, _: Expr, _: Value) -> Option<Expr>;
    fn add(&mut self, _: Expr, _: Value) -> Option<Expr>;
    fn mul(&mut self, _: Expr, _: Value) -> Option<Expr>;
    fn neg(&mut self, _: Expr) -> Option<Expr>;
    fn log2(&mut self, _: Expr) -> Option<Expr>;
    fn mask_shift(&mut self, val: Expr, mask: u64, shift: i8) -> Option<Expr>;
}
Expand description

An environment that can dynamically build expressions from values.

These are used to integrate dynamic user expression into assembled code where values appear only in a modified form.

Required Methods§

Source

fn push(&mut self, _: Stmt)

Append a new statement.

Source

fn emit_error_at(&mut self, _: ErrorSpan, _: Arguments<'_>)

Emit an error message. When any error is generated then the instruction compilation is expected to fail.

Source

fn bit_or(&mut self, _: Expr, _: Value) -> Option<Expr>

a | b

Source

fn bit_and(&mut self, _: Expr, _: Value) -> Option<Expr>

a & b

Source

fn bit_xor(&mut self, _: Expr, _: Value) -> Option<Expr>

a ^ b

Source

fn add(&mut self, _: Expr, _: Value) -> Option<Expr>

a + b

Source

fn mul(&mut self, _: Expr, _: Value) -> Option<Expr>

a * b

Source

fn neg(&mut self, _: Expr) -> Option<Expr>

!a

Source

fn log2(&mut self, _: Expr) -> Option<Expr>

Log2, mostly used to encode scalings.

Source

fn mask_shift(&mut self, val: Expr, mask: u64, shift: i8) -> Option<Expr>

(val & mask) << shift

Implementors§

Source§

impl BasicExprBuilder for State<'_>

A simple implementation of a BasicExprBuilder.

It can not combine any expressions, pushes statements into a Vec and emits errors onto standard error directly.