pub enum Expression {
Show 21 variants
Call(CallExpression),
AllocCall(AllocCallExpression),
Assignment(Assignment),
Binary(BinaryExpression),
Unary(UnaryExpression),
Identifier(IdentifierExpression),
FieldAccess(FieldAccessExpression),
StringLiteral(StringLiteralExpression),
NumberLiteral(NumberLiteralExpression),
Null(NullExpression),
Boolean(BooleanExpression),
Cast(CastExpression),
Conditional(ConditionalExpression),
Sizeof(SizeofExpression),
Subscript(SubscriptExpression),
InitializerList(InitializerListExpression),
CharLiteral(CharLiteralExpression),
Update(UpdateExpression),
Comment(CommentExpression),
OffsetOf(OffsetOfExpression),
Generic(GenericExpression),
}Variants§
Call(CallExpression)
AllocCall(AllocCallExpression)
Assignment(Assignment)
Binary(BinaryExpression)
Unary(UnaryExpression)
Identifier(IdentifierExpression)
FieldAccess(FieldAccessExpression)
StringLiteral(StringLiteralExpression)
NumberLiteral(NumberLiteralExpression)
Null(NullExpression)
Boolean(BooleanExpression)
Cast(CastExpression)
Conditional(ConditionalExpression)
Sizeof(SizeofExpression)
Subscript(SubscriptExpression)
InitializerList(InitializerListExpression)
CharLiteral(CharLiteralExpression)
Update(UpdateExpression)
Comment(CommentExpression)
OffsetOf(OffsetOfExpression)
Generic(GenericExpression)
Implementations§
Source§impl Expression
impl Expression
pub fn location(&self) -> &SourceLocation
pub fn is_falsy(&self) -> bool
pub fn is_truthy(&self) -> bool
Sourcepub fn walk<'s, F>(&'s self, f: &mut F)where
F: FnMut(&'s Self),
pub fn walk<'s, F>(&'s self, f: &mut F)where
F: FnMut(&'s Self),
Recursively walk all nested expressions. The closure receives a
&'s Expression tied to self’s lifetime, so references extracted
inside the closure can be stored in an outer Vec<&'s T>.
Sourcepub fn extract_variable_name(&self) -> Option<&str>
pub fn extract_variable_name(&self) -> Option<&str>
Extract variable name from simple expressions (Identifier or FieldAccess)
Sourcepub fn extract_identifier_name(&self) -> Option<&str>
pub fn extract_identifier_name(&self) -> Option<&str>
Extract the identifier name, unwrapping macro calls and casts.
G_OBJECT(self) → "self", (GSourceFunc) callback → "callback"
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Check if this expression is NULL Handles both Expression::Null and the identifier “NULL” (common in C code)
Sourcepub fn is_string_literal(&self) -> bool
pub fn is_string_literal(&self) -> bool
Check if this expression is a string literal
Sourcepub fn extract_string_value(&self) -> Option<String>
pub fn extract_string_value(&self) -> Option<String>
Extract string literal value, unwrapping macro calls like I_(“string”) Returns the string without quotes
Sourcepub fn resolve_string_value(
&self,
defines: &HashMap<String, DefineValue>,
) -> Option<String>
pub fn resolve_string_value( &self, defines: &HashMap<String, DefineValue>, ) -> Option<String>
Like extract_string_value, but also resolves identifiers through a
define map (e.g. MY_PROP_NAME → the string from #define MY_PROP_NAME "foo").
Sourcepub fn is_string_or_macro_string(&self) -> bool
pub fn is_string_or_macro_string(&self) -> bool
Check if this is a string literal or a macro wrapping a string literal
Sourcepub fn contains_identifier(&self, name: &str) -> bool
pub fn contains_identifier(&self, name: &str) -> bool
Check if this expression contains an identifier with the given name Recursively searches through the entire expression tree
Sourcepub fn collect_identifiers(&self) -> Vec<String>
pub fn collect_identifiers(&self) -> Vec<String>
Collect all identifiers in this expression Returns a list of all identifier names found in the expression tree
Sourcepub fn is_call_to(&self, function_name: &str) -> bool
pub fn is_call_to(&self, function_name: &str) -> bool
Check if this expression is a call to the specified function
Sourcepub fn is_call_to_any(&self, function_names: &[&str]) -> bool
pub fn is_call_to_any(&self, function_names: &[&str]) -> bool
Check if this expression is a call to any of the specified functions