pub enum CNode {
Show 31 variants
TranslationUnit(Vec<CNode>),
FuncDef {
return_type: CType,
name: String,
params: Vec<(CType, String)>,
body: Vec<CNode>,
},
VarDecl {
var_type: CType,
name: String,
init: Option<Box<CNode>>,
},
Assign {
lhs: Box<CNode>,
rhs: Box<CNode>,
},
BinOp {
left: Box<CNode>,
op: CBinaryOp,
right: Box<CNode>,
},
UnaryOp {
op: CUnaryOp,
operand: Box<CNode>,
},
IntLit(i64),
FloatLit(f64),
CharLit(char),
StrLit(String),
Ident(String),
If {
cond: Box<CNode>,
then_body: Vec<CNode>,
else_body: Vec<CNode>,
},
While {
cond: Box<CNode>,
body: Vec<CNode>,
},
For {
init: Option<Box<CNode>>,
cond: Option<Box<CNode>>,
incr: Option<Box<CNode>>,
body: Vec<CNode>,
},
Return(Option<Box<CNode>>),
Break,
Continue,
Call {
func: String,
args: Vec<CNode>,
},
ArrayAccess {
array: Box<CNode>,
index: Box<CNode>,
},
Compare {
left: Box<CNode>,
op: CCompareOp,
right: Box<CNode>,
},
ExprStmt(Box<CNode>),
Block(Vec<CNode>),
Ternary {
cond: Box<CNode>,
then_expr: Box<CNode>,
else_expr: Box<CNode>,
},
Sizeof(CType),
Cast {
target_type: CType,
expr: Box<CNode>,
},
Deref(Box<CNode>),
AddrOf(Box<CNode>),
StructAccess {
expr: Box<CNode>,
field: String,
},
PtrAccess {
expr: Box<CNode>,
field: String,
},
Increment {
operand: Box<CNode>,
pre: bool,
},
Decrement {
operand: Box<CNode>,
pre: bool,
},
}Expand description
C AST node types for generation
Variants§
TranslationUnit(Vec<CNode>)
Translation unit (root node)
FuncDef
Function definition
Fields
VarDecl
Variable declaration
Fields
Assign
Assignment: lhs = rhs
BinOp
Binary operation
UnaryOp
Unary operation
IntLit(i64)
Integer literal
FloatLit(f64)
Float literal
CharLit(char)
Character literal
StrLit(String)
String literal
Ident(String)
Variable reference
If
If statement
While
While loop
For
For loop
Fields
Return(Option<Box<CNode>>)
Return statement
Break
Break statement
Continue
Continue statement
Call
Function call
ArrayAccess
Array access
Compare
Comparison operation
ExprStmt(Box<CNode>)
Expression statement
Block(Vec<CNode>)
Compound statement (block)
Ternary
Ternary operator: cond ? then : else
Fields
Sizeof(CType)
Sizeof expression
Cast
Cast expression
Deref(Box<CNode>)
Pointer dereference
AddrOf(Box<CNode>)
Address-of
StructAccess
Struct access: expr.field
PtrAccess
Pointer struct access: expr->field
Increment
Increment: ++x or x++
Decrement
Decrement: --x or x--
Implementations§
Trait Implementations§
impl StructuralPartialEq for CNode
Auto Trait Implementations§
impl Freeze for CNode
impl RefUnwindSafe for CNode
impl Send for CNode
impl Sync for CNode
impl Unpin for CNode
impl UnsafeUnpin for CNode
impl UnwindSafe for CNode
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more