Skip to main content

AstNode

Enum AstNode 

Source
pub enum AstNode<S = ()> {
Show 15 variants Assignment { lhs: Ident, size: Option<usize>, rhs: Expression<S>, }, LoadAssignment { lhs: Load<S>, size: Option<usize>, rhs: Expression<S>, }, RangeAssignment { lhs: Range<S>, size: Option<usize>, rhs: Expression<S>, }, Build(TableId), DelaySlot(DelaySlotArg), DeferredBuild(Box<str>), Label(Box<str>), Branch { target: LabelOrNode<S>, }, ConditionalBranch { condition: Expression<S>, target: LabelOrNode<S>, }, BranchIndirect { target: Expression<S>, }, Call { target: LabelOrNode<S>, }, CallIndirect { target: Expression<S>, }, Return { target: Expression<S>, }, Export(Expression<S>), Expression(Expression<S>),
}
Expand description

A single p-code statement node.

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

Variants§

§

Assignment

x = rhs; — write to a register, a bit-range field or a temporary.

Fields

§lhs: Ident

What is written.

§size: Option<usize>

Width in bytes from an explicit :n on the destination, or None to take it from the destination itself.

§rhs: Expression<S>

The value written.

§

LoadAssignment

*[space]:n ptr = rhs; — a memory write.

Fields

§lhs: Load<S>

The destination address, space and width.

§size: Option<usize>

Width from a :n on the statement rather than on the store; almost always None, since the store carries its own.

§rhs: Expression<S>

The value written.

§

RangeAssignment

x[start, size] = rhs; — write to a bit range of a varnode, leaving the surrounding bits alone.

Fields

§lhs: Range<S>

The destination range.

§size: Option<usize>

Explicit statement width, usually None.

§rhs: Expression<S>

The value written.

§

Build(TableId)

build X; — splice in the p-code of the sub-table operand X.

Expanded before a consumer sees the AST; one surviving is a bug in this crate.

§

DelaySlot(DelaySlotArg)

delayslot(n); — splice in the p-code of the instruction(s) that follow.

§

DeferredBuild(Box<str>)

A build X where X was not in the symbol table during Phase 2 parsing. Resolved to Build(TableId) by the Phase 3 resolve pass.

§

Label(Box<str>)

<name> — a branch destination within this instruction’s own p-code.

§

Branch

goto dest; — an unconditional branch.

Fields

§target: LabelOrNode<S>

Where to.

§

ConditionalBranch

if cond goto dest; — branch when cond is non-zero. Falls through to the next statement otherwise.

Fields

§condition: Expression<S>

The condition, read as false when zero.

§target: LabelOrNode<S>

Where to when it holds.

§

BranchIndirect

goto [expr]; — branch to a computed address.

Fields

§target: Expression<S>

The address to branch to.

§

Call

call dest; — a call, which a consumer may treat as a branch that is expected to return.

Fields

§target: LabelOrNode<S>

Where to.

§

CallIndirect

call [expr]; — a call to a computed address.

Fields

§target: Expression<S>

The address to call.

§

Return

return [expr]; — return to a computed address.

Fields

§target: Expression<S>

The address returned to.

§

Export(Expression<S>)

export x; — the value a sub-table constructor hands to its parent.

Consumed while the parent’s body is expanded, so a consumer does not see this statement.

§

Expression(Expression<S>)

An expression evaluated for its effect — in practice a call to a define pcodeop, whose result is discarded.

Implementations§

Source§

impl AstNode

Source

pub fn pretty_print(&self, spec: &impl PcodeResolver) -> String

Renders this statement in a SLEIGH-like syntax, resolving identifiers against spec. For diagnostics and tests; not a stable format.

Source§

impl<S> AstNode<S>

Source

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

Discards source spans.

Trait Implementations§

Source§

impl<S: Clone> Clone for AstNode<S>

Source§

fn clone(&self) -> AstNode<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 AstNode<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 AstNode<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 AstNode<S>

Source§

impl From<AstNode> for Ast

Source§

fn from(ty: AstNode) -> Self

Converts to this type from the input type.
Source§

impl<S: PartialEq> PartialEq for AstNode<S>

Source§

fn eq(&self, other: &AstNode<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 AstNode<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 AstNode<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.