neo_solidity/ir/expressions/dispatch/
binary_ops.rs

1fn try_lower_expression_binary_ops(
2    expr: &Expression,
3    ctx: &mut LoweringContext,
4    instructions: &mut Vec<Instruction>,
5) -> Option<bool> {
6    match expr {
7        Expression::Add(_, left, right) => Some(lower_binary_expr(
8            left,
9            right,
10            ctx,
11            instructions,
12            BinaryOperator::Add,
13        )),
14        Expression::Subtract(_, left, right) => Some(lower_binary_expr(
15            left,
16            right,
17            ctx,
18            instructions,
19            BinaryOperator::Sub,
20        )),
21        Expression::Multiply(_, left, right) => Some(lower_binary_expr(
22            left,
23            right,
24            ctx,
25            instructions,
26            BinaryOperator::Mul,
27        )),
28        Expression::Divide(_, left, right) => Some(lower_binary_expr(
29            left,
30            right,
31            ctx,
32            instructions,
33            BinaryOperator::Div,
34        )),
35        Expression::Modulo(_, left, right) => Some(lower_binary_expr(
36            left,
37            right,
38            ctx,
39            instructions,
40            BinaryOperator::Mod,
41        )),
42        Expression::ShiftLeft(_, left, right) => Some(lower_binary_expr(
43            left,
44            right,
45            ctx,
46            instructions,
47            BinaryOperator::Shl,
48        )),
49        Expression::ShiftRight(_, left, right) => Some(lower_binary_expr(
50            left,
51            right,
52            ctx,
53            instructions,
54            BinaryOperator::Shr,
55        )),
56        Expression::BitwiseAnd(_, left, right) => Some(lower_binary_expr(
57            left,
58            right,
59            ctx,
60            instructions,
61            BinaryOperator::BitAnd,
62        )),
63        Expression::BitwiseOr(_, left, right) => Some(lower_binary_expr(
64            left,
65            right,
66            ctx,
67            instructions,
68            BinaryOperator::BitOr,
69        )),
70        Expression::BitwiseXor(_, left, right) => Some(lower_binary_expr(
71            left,
72            right,
73            ctx,
74            instructions,
75            BinaryOperator::BitXor,
76        )),
77        _ => None,
78    }
79}