pub struct Variable { /* private fields */ }Expand description
Represents a variable declaration.
Implementations§
Source§impl Variable
impl Variable
Sourcepub fn new_with_initializer(
name: String,
var_type: Type,
initializer: Expression,
) -> Self
pub fn new_with_initializer( name: String, var_type: Type, initializer: Expression, ) -> Self
Create a new variable with an initializer.
Sourcepub fn is_function_pointer(&self) -> bool
pub fn is_function_pointer(&self) -> bool
Check if this variable is a function pointer.
Sourcepub fn function_pointer_param_count(&self) -> usize
pub fn function_pointer_param_count(&self) -> usize
Get the number of parameters if this is a function pointer.
Sourcepub fn function_pointer_has_void_return(&self) -> bool
pub fn function_pointer_has_void_return(&self) -> bool
Check if this function pointer has a void return type.
Sourcepub fn is_string_literal(&self) -> bool
pub fn is_string_literal(&self) -> bool
Check if this variable is a string literal (char* with literal initializer).
Detects patterns like: const char* msg = "Hello";
§Implementation
Checks if:
- Type is a pointer to char (
char*) - Has an initializer that is a
StringLiteralexpression
Note: Const qualifier detection not yet implemented - checks all char* pointers.
Sourcepub fn is_string_buffer(&self) -> bool
pub fn is_string_buffer(&self) -> bool
Check if this variable is a string buffer (char* allocated with malloc).
Detects patterns like: char* buffer = malloc(100);
§Implementation
Checks if:
- Type is a pointer to char (
char*) - Has an initializer that is a malloc/calloc function call
Sourcepub fn initializer(&self) -> Option<&Expression>
pub fn initializer(&self) -> Option<&Expression>
Get the initializer expression for this variable.
Returns Some(&Expression) if the variable has an initializer, None otherwise.
Trait Implementations§
impl StructuralPartialEq for Variable
Auto Trait Implementations§
impl Freeze for Variable
impl RefUnwindSafe for Variable
impl Send for Variable
impl Sync for Variable
impl Unpin for Variable
impl UnwindSafe for Variable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more