neo_solidity/ir/statements/dispatch/
statement.rs

1fn lower_statement(
2    statement: &Statement,
3    ctx: &mut LoweringContext,
4    instructions: &mut Vec<Instruction>,
5) -> bool {
6    match statement {
7        // NeoVM uses BigInteger arithmetic — no overflow is possible — so
8        // `unchecked { }` blocks are semantically identical to normal blocks.
9        // The `..` pattern safely ignores the `unchecked: bool` field.
10        Statement::Block { statements, .. } => {
11            lower_block_statement(statements, ctx, instructions)
12        }
13        Statement::If(_, condition, then_stmt, else_stmt) => {
14            lower_if_statement(condition, then_stmt, else_stmt.as_deref(), ctx, instructions)
15        }
16        Statement::While(_, condition, body) => {
17            lower_while_statement(condition, body, ctx, instructions)
18        }
19        Statement::DoWhile(_, body, condition) => {
20            lower_do_while_statement(body, condition, ctx, instructions)
21        }
22        Statement::For(_, init, condition, post, body) => lower_for_statement(
23            init.as_deref(),
24            condition.as_deref(),
25            post.as_deref(),
26            body.as_deref(),
27            ctx,
28            instructions,
29        ),
30        Statement::Expression(_, expr) => lower_expression_statement(expr, ctx, instructions),
31        Statement::VariableDefinition(_, decl, init) => {
32            lower_variable_definition_statement(decl, init.as_ref(), ctx, instructions)
33        }
34        Statement::Emit(_, call) => lower_emit_statement(call, ctx, instructions),
35        Statement::Assembly { .. } => lower_assembly_statement(ctx, instructions),
36        Statement::Try(_, expr, handler, catches) => {
37            lower_try_statement(expr, handler, catches, ctx, instructions)
38        }
39        Statement::Break(_) => lower_break_statement(ctx, instructions),
40        Statement::Continue(_) => lower_continue_statement(ctx, instructions),
41        Statement::Return(_, expr) => lower_return_statement(expr.as_ref(), ctx, instructions),
42        Statement::Revert(_, ident, args) => {
43            lower_revert_statement(ident.as_ref(), args, ctx, instructions)
44        }
45        Statement::RevertNamedArgs(_, ident, args) => {
46            lower_revert_named_args(ident.as_ref(), args, ctx, instructions)
47        }
48        _ => {
49            ctx.record_error_with_suggestion(
50                format!("unsupported statement '{:?}'", statement),
51                "this Solidity statement type is not yet supported by the Neo N3 compiler",
52            );
53            false
54        }
55    }
56}