(&self, target_type: ExpressionType)
| 700 | } |
| 701 | |
| 702 | fn cast(&self, target_type: ExpressionType) -> Rc<SymbolicValue> { |
| 703 | match &self.expression { |
| 704 | Expression::CompileTimeConstant(v1) => { |
| 705 | let result = v1.cast(&target_type); |
| 706 | if result != ConstantValue::Bottom { |
| 707 | return Rc::new(result.into()); |
| 708 | } else { |
| 709 | self.clone() |
| 710 | } |
| 711 | } |
| 712 | Expression::Bottom => self.clone(), |
| 713 | Expression::Join { left, right } => { |
| 714 | left.cast(target_type.clone()).join(right.cast(target_type)) |
| 715 | } |
| 716 | _ => { |
| 717 | match &self.expression { |
| 718 | // [(x as t1) as target_type] -> x as target_type if t1.max_value() >= target_type.max_value() |
| 719 | Expression::Cast { |
| 720 | operand, |
| 721 | target_type: t1, |
| 722 | } => { |
| 723 | if t1.is_integer() |
| 724 | && target_type.is_unsigned_integer() |
| 725 | && t1 |
| 726 | .max_value() |
| 727 | .greater_or_equal(&target_type.max_value()) |
| 728 | .as_bool_if_known() |
| 729 | .unwrap_or(false) |
| 730 | { |
| 731 | return operand.cast(target_type); |
| 732 | } |
| 733 | } |
| 734 | _ => (), |
| 735 | } |
| 736 | if self.expression.infer_type() != target_type { |
| 737 | SymbolicValue::make_typed_unary( |
| 738 | self.clone(), |
| 739 | target_type, |
| 740 | |operand, target_type| Expression::Cast { |
| 741 | operand, |
| 742 | target_type, |
| 743 | }, |
| 744 | ) |
| 745 | } else { |
| 746 | self.clone() |
| 747 | } |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | /// Returns an element that is "*self". |
| 753 | fn dereference(&self, target_type: ExpressionType) -> Rc<SymbolicValue> { |
no test coverage detected