pub enum Expression {
Show 15 variants
IntLiteral(i32),
StringLiteral(String),
Variable(String),
BinaryOp {
op: BinaryOperator,
left: Box<Expression>,
right: Box<Expression>,
},
FunctionCall {
function: String,
arguments: Vec<Expression>,
},
Dereference(Box<Expression>),
UnaryOp {
op: UnaryOperator,
operand: Box<Expression>,
},
ArrayIndex {
array: Box<Expression>,
index: Box<Expression>,
},
FieldAccess {
object: Box<Expression>,
field: String,
},
PointerFieldAccess {
pointer: Box<Expression>,
field: String,
},
PostIncrement {
operand: Box<Expression>,
},
PreIncrement {
operand: Box<Expression>,
},
PostDecrement {
operand: Box<Expression>,
},
PreDecrement {
operand: Box<Expression>,
},
Sizeof {
type_name: String,
},
}Expand description
Represents a C expression.
Variants§
IntLiteral(i32)
Integer literal: 42
StringLiteral(String)
String literal: "hello"
Variable(String)
Variable reference: x
BinaryOp
Binary operation: a + b
Fields
op: BinaryOperatorOperator
left: Box<Expression>Left operand
right: Box<Expression>Right operand
FunctionCall
Function call: malloc(4)
Dereference(Box<Expression>)
Pointer dereference: *ptr
UnaryOp
Unary operation: -x, !x
ArrayIndex
Array indexing: arr[i]
FieldAccess
Struct field access: obj.field
PointerFieldAccess
Pointer field access: ptr->field
PostIncrement
Post-increment expression: ptr++
Fields
operand: Box<Expression>Operand expression
PreIncrement
Pre-increment expression: ++ptr
Fields
operand: Box<Expression>Operand expression
PostDecrement
Post-decrement expression: ptr--
Fields
operand: Box<Expression>Operand expression
PreDecrement
Pre-decrement expression: --ptr
Fields
operand: Box<Expression>Operand expression
Sizeof
Sizeof expression: sizeof(int) or sizeof(struct Data)
Implementations§
Source§impl Expression
impl Expression
Sourcepub fn is_string_function_call(&self) -> bool
pub fn is_string_function_call(&self) -> bool
Check if this expression is a string function call (strlen, strcmp, strcpy, strdup).
Sourcepub fn string_function_name(&self) -> Option<&str>
pub fn string_function_name(&self) -> Option<&str>
Get the string function name if this is a string function call.
Sourcepub fn has_string_literal_argument(&self) -> bool
pub fn has_string_literal_argument(&self) -> bool
Check if this expression has a string literal argument.
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more