pub enum Stmt {
Show 20 variants
Error,
Empty,
Expr(ExprId),
Decl(DeclId),
Compound(StmtList),
If {
cond: ExprId,
then: StmtId,
otherwise: Option<StmtId>,
},
Switch {
scrutinee: ExprId,
body: StmtId,
},
While {
cond: ExprId,
body: StmtId,
},
DoWhile {
body: StmtId,
cond: ExprId,
},
For {
init: ForInit,
cond: Option<ExprId>,
step: Option<ExprId>,
body: StmtId,
},
Goto(Symbol),
GotoExpr(ExprId),
Continue,
Break,
Return(Option<ExprId>),
Label {
name: Symbol,
body: Option<StmtId>,
attrs: AttrList,
},
Case {
lo: ExprId,
hi: Option<ExprId>,
body: Option<StmtId>,
},
Default {
body: Option<StmtId>,
},
LocalLabels(SymbolList),
Asm(AsmId),
}Expand description
One statement node.
Twenty bytes, set by Stmt::For, which is the only variant with four operands and which
gets away with it because ForInit has spare tag values for the statement’s own tag to
live in. Splitting the loop’s clauses into a side table would buy four bytes a statement and
cost an indirection on the most common loop in C, so they stay inline.
Variants§
Error
A parse that did not work out. Poisoned, as Expr::Error is.
Empty
;.
Expr(ExprId)
An expression evaluated for its effect.
Decl(DeclId)
A declaration at block scope, with all of its declarators.
Compound(StmtList)
{ ... }, which is also a scope.
If
if (cond) then else otherwise.
Fields
Switch
switch (scrutinee) body.
Fields
While
while (cond) body.
DoWhile
do body while (cond);.
Fields
For
for (init; cond; step) body.
Fields
Goto(Symbol)
goto name;.
GotoExpr(ExprId)
goto *expr;, GNU’s computed goto, which Postgres and the kernel both use.
Continue
continue;.
Break
break;.
Return(Option<ExprId>)
return expr;, or return;.
Label
name: body.
Fields
Case
case lo: body, or GNU’s case lo ... hi: body.
Fields
Default
default: body.
LocalLabels(SymbolList)
__label__ a, b;, GNU’s block-local labels, which a macro needs so that two expansions
in one function do not collide.
Asm(AsmId)
An asm statement.