Skip to main content

ExpressionTy

Enum ExpressionTy 

Source
pub enum ExpressionTy<S = ()> {
    SizedInt {
        value: u64,
        size: Option<usize>,
    },
    SubPieceMsb {
        src: Box<Expression<S>>,
        count: usize,
    },
    SubPieceLsb {
        src: Box<Expression<S>>,
        count: usize,
    },
    Load(Load<S>),
    Range(Range<S>),
    FunctionCall {
        builtin: Builtin,
        args: Vec<Expression<S>>,
    },
    PcodeOp {
        id: PCodeOpId,
        args: Vec<Expression<S>>,
    },
    MacroCall {
        id: PMacroId,
        args: Vec<Expression<S>>,
    },
    DeferredCall {
        name: Box<str>,
        args: Vec<Expression<S>>,
    },
    Ident(Ident),
    Unop(Unop<S>),
    Binop(Binop<S>),
}
Expand description

The shape of a p-code expression node.

S is the span type: (usize, usize) at parse time, () in the stored/runtime form.

Variants§

§

SizedInt

An integer literal.

Fields

§value: u64

The value, zero-extended into a u64.

§size: Option<usize>

Explicit width in bytes from a :n suffix, or None when the literal takes its width from the context it appears in.

§

SubPieceMsb

x(n) — drop the low n bytes of x, keeping the high end.

Fields

§src: Box<Expression<S>>

The value being truncated.

§count: usize

How many bytes to drop from the bottom.

§

SubPieceLsb

x:n — keep the low n bytes of x.

Fields

§src: Box<Expression<S>>

The value being truncated.

§count: usize

How many low bytes to keep.

§

Load(Load<S>)

*[space]:n ptr — a memory read.

§

Range(Range<S>)

x[start, size] — a bit range of a value.

§

FunctionCall

A call to one of SLEIGH’s built-in functions.

Fields

§builtin: Builtin

Which builtin.

§args: Vec<Expression<S>>

Its arguments, in source order.

§

PcodeOp

A call to a define pcodeop — an operation the specification declares but does not define, so a consumer must give it meaning. The name is the id-th entry of the producer’s user-defined operation table.

Fields

§id: PCodeOpId

Index into the specification’s user-defined operation list.

§args: Vec<Expression<S>>

Its arguments, in source order.

§

MacroCall

A call to a macro. Expanded away before a consumer sees the AST; one surviving is a bug in this crate.

Fields

§id: PMacroId

The macro being called.

§args: Vec<Expression<S>>

Its arguments, in source order.

§

DeferredCall

A call to a name the symbol table did not hold — necessarily a macro parameter, substituted when the macro is inlined. A consumer does not see this variant.

Fields

§name: Box<str>

The name being called.

§args: Vec<Expression<S>>

Its arguments, in source order.

§

Ident(Ident)

A reference to a named thing.

§

Unop(Unop<S>)

A prefix operator applied to one operand.

§

Binop(Binop<S>)

An infix operator applied to two operands.

Implementations§

Source§

impl ExpressionTy

Source

pub fn with_size(self, size: usize) -> Expression

Wraps this node in an expression with a known byte width.

Source§

impl<S> ExpressionTy<S>

Source

pub fn strip_span(self) -> ExpressionTy<()>

Discards source spans.

Trait Implementations§

Source§

impl<S: Clone> Clone for ExpressionTy<S>

Source§

fn clone(&self) -> ExpressionTy<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug> Debug for ExpressionTy<S>

Source§

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

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

impl<'de, S> Deserialize<'de> for ExpressionTy<S>
where S: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<S: Eq> Eq for ExpressionTy<S>

Source§

impl From<ExpressionTy> for Expression

Source§

fn from(ty: ExpressionTy) -> Self

Converts to this type from the input type.
Source§

impl<S: PartialEq> PartialEq for ExpressionTy<S>

Source§

fn eq(&self, other: &ExpressionTy<S>) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<S> Serialize for ExpressionTy<S>
where S: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<S: PartialEq> StructuralPartialEq for ExpressionTy<S>

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.