pub enum Statement {
Declare {
type_: Type,
name: Ident,
value: Option<Expr>,
},
Expr(Expr),
Return(Option<Expr>),
If {
condition: Expr,
then: Block,
otherwise: Option<Block>,
},
For {
init: Box<Statement>,
condition: Expr,
step: Expr,
body: Block,
},
While {
condition: Expr,
body: Block,
},
Break,
ForEach {
binding: Ident,
range: Expr,
body: Block,
},
Switch {
value: Expr,
cases: Vec<SwitchCase>,
},
Throw(Expr),
Try {
body: Block,
handlers: Vec<CatchClause>,
},
Comment(Doc),
}Expand description
One statement.
Variants§
Declare
A declaration with an optional initialiser.
Expr(Expr)
An expression followed by ;.
Return(Option<Expr>)
return expr;
If
if (cond) { .. } else { .. }
For
for (init; cond; step) { .. }
Not Statement::ForEach. A generated codec walks a collection
by index because the index is what the wire needs — an element’s
position decides its alignment and, in a map written in
ascending key order, which entry is written at all.
Fields
While
while (cond) { .. }
Not a for with the two clauses left empty. A decoder walks a
@mutable aggregate’s headers until the delimiter is used up and
a PL_CDR1 list until its sentinel; neither has a counter.
Break
break;
ForEach
for (auto& name : range) { .. }
Switch
switch (value) { case ..: }
Throw(Expr)
throw expr;
The Java tree has had one from the start and this one had not,
which held for as long as the only C++ output was data
declarations. A CORBA skeleton’s default arm is
throw CORBA::BAD_OPERATION(); — §8.3 — and a call expression
spelled to look like one would compile and then fall through.
Try
try { .. } catch (T& name) { .. } catch (...) { .. }
A generated DDS-RPC service turns what an operation throws into the case of the reply union that carries it (DDS-RPC 1.0 §7.5.1.1.5) or into a remote exception code (§7.5.2); that needs a handler.
Comment(Doc)
A comment on its own line.