Skip to main content

Statement

Enum Statement 

Source
pub enum Statement {
Show 15 variants Declaration(Box<VariableDecl>), Expression(Box<Expression>), If(IfStatement), Return(ReturnStatement), Goto(GotoStatement), Labeled(LabeledStatement), Compound(CompoundStatement), Switch(SwitchStatement), For(Box<ForStatement>), While(WhileStatement), DoWhile(DoWhileStatement), Break(BreakStatement), Continue(ContinueStatement), Preprocessor(PreprocessorDirective), Comment(Comment),
}

Variants§

Implementations§

Source§

impl Statement

Source

pub fn walk<'s, F>(&'s self, f: &mut F)
where F: FnMut(&'s Self),

Recursively visit all nested statements. The closure receives a &'s Statement tied to self’s lifetime, so references extracted inside the closure can be stored in an outer Vec<&'s T>.

Source

pub fn for_each_child_block<F>(&self, f: F)
where F: FnMut(&[Self]),

Call f with each immediate child block (a &[Statement] slice) of this statement. Covers all container variants exhaustively; leaf variants produce no calls. Use this instead of a manual match when you need to apply a slice-level operation (e.g. pair detection) to every nested body.

Source

pub fn visit_expressions<'s>(&'s self, f: &mut impl FnMut(&'s Expression))

Visit all direct expressions contained in this statement (non-recursive). Includes conditions, initialisers, and all other expressions that are immediate children of this statement node. Zero-allocation alternative to collecting into a Vec.

Source

pub fn location(&self) -> &SourceLocation

Source

pub fn walk_expressions<'s, F>(&'s self, f: &mut F)
where F: FnMut(&'s Expression),

Recursively walk all expressions in this statement tree. Visits the direct expression of each statement (not sub-expressions — call Expression::walk on the result if you need nested expressions).

Source

pub fn iter_switches<'s>( &'s self, ) -> impl Iterator<Item = &'s SwitchStatement> + 's

Iterator over all switch statements in this statement tree (recursive)

Source

pub fn iter_if_statements<'s>( &'s self, ) -> impl Iterator<Item = &'s IfStatement> + 's

Iterator over all if statements in this statement tree (recursive)

Source

pub fn iter_declarations<'s>( &'s self, ) -> impl Iterator<Item = &'s VariableDecl> + 's

Iterator over all variable declarations in this statement tree (recursive)

Source

pub fn iter_returns<'s>( &'s self, ) -> impl Iterator<Item = &'s ReturnStatement> + 's

Iterator over all return statements in this statement tree (recursive)

Source

pub fn iter_assignments<'s>( &'s self, ) -> impl Iterator<Item = &'s Assignment> + 's

Iterator over all top-level assignment statements in this statement tree (recursive). Only yields assignments that are the entire expression statement, not assignments nested inside other expressions.

Source

pub fn iter_calls<'s>(&'s self) -> impl Iterator<Item = &'s CallExpression> + 's

Iterator over all call expressions in this statement tree (recursive). Includes calls at all nesting levels within expressions (e.g. nested arguments).

Source

pub fn extract_call(&self) -> Option<&CallExpression>

Extract the call expression if this is an expression statement with a call

Source

pub fn is_assignment_to<F>(&self, target_var: &str, value_check: F) -> bool
where F: Fn(&Expression) -> bool,

Check if this statement assigns a value matching the predicate to the target variable

Source

pub fn extract_assignment(&self) -> Option<&Assignment>

Extract the assignment expression if this is an assignment statement

Source

pub fn is_null_assignment_to(&self, var_name: &str) -> bool

Check if this statement assigns NULL to the target variable

Source

pub fn for_each_pair<F>(statements: &[Self], f: F)
where F: FnMut(&Self, &Self),

Iterate over consecutive pairs of statements (skipping comments)

Source

pub fn for_each_triple<F>(statements: &[Self], f: F)
where F: FnMut(&Self, &Self, &Self),

Iterate over consecutive triples of statements (skipping comments)

Source

pub fn walk_pairs<F>(stmts: &[Self], f: &mut F)
where F: FnMut(&Self, &Self),

Recursively visit consecutive pairs of statements at every nesting level (if bodies, else bodies, compound blocks, loops, switch cases, labeled statements). Comments are skipped so they don’t break pair detection.

Source

pub fn walk_triples<F>(stmts: &[Self], f: &mut F)
where F: FnMut(&Self, &Self, &Self),

Recursively visit consecutive triples of statements at every nesting level. Comments are skipped so they don’t break triple detection.

Trait Implementations§

Source§

impl Clone for Statement

Source§

fn clone(&self) -> Self

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 Debug for Statement

Source§

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

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

impl Serialize for Statement

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

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more