File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,20 @@ template <>
45
45
struct numeric_castt <mp_integer> final
46
46
{
47
47
optionalt<mp_integer> operator ()(const exprt &expr) const
48
+ {
49
+ if (expr.id () != ID_constant)
50
+ return {};
51
+ else
52
+ return operator ()(to_constant_expr (expr));
53
+ }
54
+
55
+ optionalt<mp_integer> operator ()(const constant_exprt &expr) const
48
56
{
49
57
mp_integer out;
50
- if (expr. id () != ID_constant || to_integer (to_constant_expr ( expr) , out))
58
+ if (to_integer (expr, out))
51
59
return {};
52
- return out;
60
+ else
61
+ return out;
53
62
}
54
63
};
55
64
@@ -97,6 +106,15 @@ struct numeric_castt<T,
97
106
98
107
// Conversion from expression
99
108
optionalt<T> operator ()(const exprt &expr) const
109
+ {
110
+ if (expr.id () == ID_constant)
111
+ return numeric_castt<T>{}(to_constant_expr (expr));
112
+ else
113
+ return {};
114
+ }
115
+
116
+ // Conversion from expression
117
+ optionalt<T> operator ()(const constant_exprt &expr) const
100
118
{
101
119
if (auto mpi_opt = numeric_castt<mp_integer>{}(expr))
102
120
return numeric_castt<T>{}(*mpi_opt);
You can’t perform that action at this time.
0 commit comments