neo_solidity/ir/expressions/dispatch/
conditional.rs1fn try_lower_expression_conditional(
2 expr: &Expression,
3 ctx: &mut LoweringContext,
4 instructions: &mut Vec<Instruction>,
5) -> Option<bool> {
6 match expr {
7 Expression::ConditionalOperator(_, condition, then_expr, else_expr) => {
8 let else_label = ctx.next_label();
13 let end_label = ctx.next_label();
14
15 if !lower_expression(condition, ctx, instructions) {
17 return Some(false);
18 }
19
20 instructions.push(Instruction::JumpIf { target: else_label });
22
23 if !lower_expression(then_expr, ctx, instructions) {
25 return Some(false);
26 }
27 instructions.push(Instruction::Jump { target: end_label });
28
29 instructions.push(Instruction::Label(else_label));
31
32 if !lower_expression(else_expr, ctx, instructions) {
34 return Some(false);
35 }
36
37 instructions.push(Instruction::Label(end_label));
39
40 Some(true)
41 }
42 _ => None,
43 }
44}