Struct State

Source
pub struct State<'a> {
    pub stmts: &'a mut Vec<Stmt>,
    pub target: &'a str,
    pub file_data: &'a mut DynasmData,
}
Expand description

This struct contains all non-parsing state that dynasm! requires while parsing and compiling

Fields§

§stmts: &'a mut Vec<Stmt>§target: &'a str§file_data: &'a mut DynasmData

Trait Implementations§

Source§

impl AssembleX64 for State<'_>

Source§

fn compile_instruction( &mut self, arch: &Archx64, instruction: InstructionX64, ) -> Result<(), Error>

Turn an expression into binary format. May error when dynamic data is present at bad locations such as memory address scaling.
Source§

fn build_instruction( &mut self, _: &Archx64, _: InstructionX64, ) -> Result<(), Error>
where Self: BasicExprBuilder,

Create an instruction composed from dynamic data. Only available when the type is also capable of building new composite expressions.
Source§

impl AssembleX86 for State<'_>

Source§

fn compile_instruction( &mut self, arch: &Archx86, instruction: InstructionX86, ) -> Result<(), Error>

Turn an expression into binary format. May error when dynamic data is present at bad locations such as memory address scaling.
Source§

fn build_instruction( &mut self, _: &Archx86, _: InstructionX86, ) -> Result<(), Error>
where Self: BasicExprBuilder,

Create an instruction composed from dynamic data. Only available when the type is also capable of building new composite expressions.
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.

Source§

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

Emits the error message on stderr.

Source§

fn push(&mut self, stmt: Stmt)

Append a new statement.
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, _: Expr, _: u64, _: i8) -> Option<Expr>

(val & mask) << shift

Auto Trait Implementations§

§

impl<'a> Freeze for State<'a>

§

impl<'a> !RefUnwindSafe for State<'a>

§

impl<'a> Send for State<'a>

§

impl<'a> !Sync for State<'a>

§

impl<'a> Unpin for State<'a>

§

impl<'a> !UnwindSafe for State<'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> BasicExprBuilderExt for T
where T: BasicExprBuilder + ?Sized,

Source§

fn bit_or_else_err(&mut self, a: Expr, b: Value) -> Result<Expr, Error>

Source§

fn bit_and_else_err(&mut self, a: Expr, b: Value) -> Result<Expr, Error>

Source§

fn bit_xor_else_err(&mut self, a: Expr, b: Value) -> Result<Expr, Error>

Source§

fn neg_else_err(&mut self, a: Expr) -> Result<Expr, Error>

Source§

fn add_else_err(&mut self, a: Expr, b: Value) -> Result<Expr, Error>

Source§

fn mul_else_err(&mut self, a: Expr, b: Value) -> Result<Expr, Error>

Source§

fn add_many(&mut self, iter: impl IntoIterator<Item = Expr>) -> Option<Value>

Source§

fn add_many_else_err( &mut self, iter: impl IntoIterator<Item = Expr>, ) -> Result<Value, Error>

Source§

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

reg | ((val & mask) << shift) val is not a Value since then the lib could already constant fold until |.
Source§

fn mask_shift_or_else_err( &mut self, reg: Value, val: Expr, mask: u64, shift: i8, ) -> Result<Expr, Error>

reg | ((val & mask) << shift)
Source§

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

reg & !((val & mask) << shift) val is not a Value since then the lib could already constant fold until |.
Source§

fn mask_shift_inverted_and_else_err( &mut self, reg: Value, val: Expr, mask: u64, shift: i8, ) -> Result<Expr, Error>

reg | ((val & mask) << shift)
Source§

fn log2_else_err(&mut self, a: Expr) -> Result<Expr, Error>

Source§

fn dynscale(&mut self, _: Expr, _: Value) -> Result<(Expr, Expr), Error>

Source§

fn mask_shift_else_err( &mut self, val: Expr, mask: u64, shift: i8, ) -> Result<Expr, Error>

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.