Returns an element that is "!self" where self is a bool.
(&self)
| 1045 | |
| 1046 | /// Returns an element that is "!self" where self is a bool. |
| 1047 | fn logical_not(&self) -> Rc<SymbolicValue> { |
| 1048 | if let Expression::CompileTimeConstant(v1) = &self.expression { |
| 1049 | let result = v1.logical_not(); |
| 1050 | if result != ConstantValue::Bottom { |
| 1051 | return Rc::new(result.into()); |
| 1052 | } |
| 1053 | }; |
| 1054 | match &self.expression { |
| 1055 | Expression::Bottom => self.clone(), |
| 1056 | Expression::Equals { left: x, right: y } if x.expression.infer_type().is_integer() => { |
| 1057 | // [!(x == y)] -> x != y |
| 1058 | x.not_equals(y.clone()) |
| 1059 | } |
| 1060 | Expression::GreaterThan { left: x, right: y } |
| 1061 | if x.expression.infer_type().is_integer() => |
| 1062 | { |
| 1063 | // [!(x > y)] -> x <= y |
| 1064 | x.less_or_equal(y.clone()) |
| 1065 | } |
| 1066 | Expression::GreaterOrEqual { left: x, right: y } |
| 1067 | if x.expression.infer_type().is_integer() => |
| 1068 | { |
| 1069 | // [!(x >= y)] -> x < y |
| 1070 | x.less_than(y.clone()) |
| 1071 | } |
| 1072 | Expression::LessThan { left: x, right: y } |
| 1073 | if x.expression.infer_type().is_integer() => |
| 1074 | { |
| 1075 | // [!(x < y)] -> x >= y |
| 1076 | x.greater_or_equal(y.clone()) |
| 1077 | } |
| 1078 | Expression::LessOrEqual { left: x, right: y } |
| 1079 | if x.expression.infer_type().is_integer() => |
| 1080 | { |
| 1081 | // [!(x <= y)] -> x > y |
| 1082 | x.greater_than(y.clone()) |
| 1083 | } |
| 1084 | Expression::LogicalNot { operand } => { |
| 1085 | // [!!x] -> x |
| 1086 | operand.clone() |
| 1087 | } |
| 1088 | Expression::Ne { left: x, right: y } if x.expression.infer_type().is_integer() => { |
| 1089 | // [!(x != y)] -> x == y |
| 1090 | x.equals(y.clone()) |
| 1091 | } |
| 1092 | _ => SymbolicValue::make_unary(self.clone(), |operand| Expression::LogicalNot { |
| 1093 | operand, |
| 1094 | }), |
| 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | /// Returns an element that is "self != other". |
| 1099 | fn not_equals(&self, other: Rc<SymbolicValue>) -> Rc<SymbolicValue> { |
no test coverage detected