neo_solidity/ir/expressions/dispatch/
unary.rs1fn try_lower_expression_unary(
2 expr: &Expression,
3 ctx: &mut LoweringContext,
4 instructions: &mut Vec<Instruction>,
5) -> Option<bool> {
6 match expr {
7 Expression::Not(_, inner) => Some(if lower_expression(inner, ctx, instructions) {
8 instructions.push(Instruction::LogicalNot);
9 true
10 } else {
11 false
12 }),
13 Expression::BitwiseNot(_, inner) => Some(if lower_expression(inner, ctx, instructions) {
14 instructions.push(Instruction::BitwiseNot);
15 true
16 } else {
17 false
18 }),
19 Expression::Power(_, left, right) => Some(lower_power_expression(
20 left.as_ref(),
21 right.as_ref(),
22 ctx,
23 instructions,
24 )),
25 Expression::UnaryPlus(_, inner) => Some(lower_expression(inner, ctx, instructions)),
26 Expression::Negate(_, inner) => Some(if lower_expression(inner, ctx, instructions) {
27 instructions.push(Instruction::PushLiteral(LiteralValue::Integer(
28 BigInt::from(-1),
29 )));
30 instructions.push(Instruction::BinaryOp(BinaryOperator::Mul));
31 true
32 } else {
33 false
34 }),
35 _ => None,
36 }
37}