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
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
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
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
impl AstNode
Sourcepub fn pretty_print(&self, spec: &impl PcodeResolver) -> String
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.