|
18 | 18 | #include "mathematical_types.h"
|
19 | 19 | #include "std_types.h"
|
20 | 20 |
|
| 21 | +/// An expression without operands |
| 22 | +class nullary_exprt : public exprt |
| 23 | +{ |
| 24 | +public: |
| 25 | + // constructors |
| 26 | + DEPRECATED("use nullary_exprt(id, type) instead") |
| 27 | + explicit nullary_exprt(const irep_idt &_id) : exprt(_id) |
| 28 | + { |
| 29 | + } |
| 30 | + |
| 31 | + nullary_exprt(const irep_idt &_id, const typet &_type) : exprt(_id, _type) |
| 32 | + { |
| 33 | + } |
| 34 | + |
| 35 | + /// remove all operand methods |
| 36 | + operandst &operands() = delete; |
| 37 | + const operandst &operands() const = delete; |
| 38 | + |
| 39 | + const exprt &op0() const = delete; |
| 40 | + exprt &op0() = delete; |
| 41 | + const exprt &op1() const = delete; |
| 42 | + exprt &op1() = delete; |
| 43 | + const exprt &op2() const = delete; |
| 44 | + exprt &op2() = delete; |
| 45 | + const exprt &op3() const = delete; |
| 46 | + exprt &op3() = delete; |
| 47 | + |
| 48 | + void move_to_operands(exprt &) = delete; |
| 49 | + void move_to_operands(exprt &, exprt &) = delete; |
| 50 | + void move_to_operands(exprt &, exprt &, exprt &) = delete; |
| 51 | + |
| 52 | + void copy_to_operands(const exprt &expr) = delete; |
| 53 | + void copy_to_operands(const exprt &, const exprt &) = delete; |
| 54 | + void copy_to_operands(const exprt &, const exprt &, const exprt &) = delete; |
| 55 | +}; |
| 56 | + |
| 57 | +/// An expression with three operands |
| 58 | +class ternary_exprt : public exprt |
| 59 | +{ |
| 60 | +public: |
| 61 | + // constructors |
| 62 | + DEPRECATED("use ternary_exprt(id, op0, op1, op2, type) instead") |
| 63 | + explicit ternary_exprt(const irep_idt &_id) : exprt(_id) |
| 64 | + { |
| 65 | + operands().resize(3); |
| 66 | + } |
| 67 | + |
| 68 | + DEPRECATED("use ternary_exprt(id, op0, op1, op2, type) instead") |
| 69 | + explicit ternary_exprt(const irep_idt &_id, const typet &_type) |
| 70 | + : exprt(_id, _type) |
| 71 | + { |
| 72 | + operands().resize(3); |
| 73 | + } |
| 74 | + |
| 75 | + ternary_exprt( |
| 76 | + const irep_idt &_id, |
| 77 | + const exprt &_op0, |
| 78 | + const exprt &_op1, |
| 79 | + const exprt &_op2, |
| 80 | + const typet &_type) |
| 81 | + : exprt(_id, _type) |
| 82 | + { |
| 83 | + copy_to_operands(_op0, _op1, _op2); |
| 84 | + } |
| 85 | + |
| 86 | + const exprt &op3() const = delete; |
| 87 | + exprt &op3() = delete; |
| 88 | +}; |
| 89 | + |
21 | 90 | /// Transition system, consisting of state invariant, initial state predicate,
|
22 | 91 | /// and transition predicate.
|
23 |
| -class transt:public exprt |
| 92 | +class transt : public ternary_exprt |
24 | 93 | {
|
25 | 94 | public:
|
26 |
| - transt() |
| 95 | + transt() : ternary_exprt(ID_trans) |
27 | 96 | {
|
28 |
| - id(ID_trans); |
29 |
| - operands().resize(3); |
30 | 97 | }
|
31 | 98 |
|
32 | 99 | exprt &invar() { return op0(); }
|
@@ -72,31 +139,30 @@ inline void validate_expr(const transt &value)
|
72 | 139 |
|
73 | 140 |
|
74 | 141 | /// Expression to hold a symbol (variable)
|
75 |
| -class symbol_exprt:public exprt |
| 142 | +class symbol_exprt : public nullary_exprt |
76 | 143 | {
|
77 | 144 | public:
|
78 | 145 | DEPRECATED("use symbol_exprt(identifier, type) instead")
|
79 |
| - symbol_exprt():exprt(ID_symbol) |
| 146 | + symbol_exprt() : nullary_exprt(ID_symbol) |
80 | 147 | {
|
81 | 148 | }
|
82 | 149 |
|
83 | 150 | /// \param identifier: Name of symbol
|
84 | 151 | DEPRECATED("use symbol_exprt(identifier, type) instead")
|
85 |
| - explicit symbol_exprt(const irep_idt &identifier):exprt(ID_symbol) |
| 152 | + explicit symbol_exprt(const irep_idt &identifier) : nullary_exprt(ID_symbol) |
86 | 153 | {
|
87 | 154 | set_identifier(identifier);
|
88 | 155 | }
|
89 | 156 |
|
90 | 157 | /// \param type: Type of symbol
|
91 |
| - explicit symbol_exprt(const typet &type):exprt(ID_symbol, type) |
| 158 | + explicit symbol_exprt(const typet &type) : nullary_exprt(ID_symbol, type) |
92 | 159 | {
|
93 | 160 | }
|
94 | 161 |
|
95 | 162 | /// \param identifier: Name of symbol
|
96 | 163 | /// \param type: Type of symbol
|
97 |
| - symbol_exprt( |
98 |
| - const irep_idt &identifier, |
99 |
| - const typet &type):exprt(ID_symbol, type) |
| 164 | + symbol_exprt(const irep_idt &identifier, const typet &type) |
| 165 | + : nullary_exprt(ID_symbol, type) |
100 | 166 | {
|
101 | 167 | set_identifier(identifier);
|
102 | 168 | }
|
@@ -137,7 +203,7 @@ class decorated_symbol_exprt:public symbol_exprt
|
137 | 203 | }
|
138 | 204 |
|
139 | 205 | /// \param identifier: Name of symbol
|
140 |
| - /// \param : type Type of symbol |
| 206 | + /// \param type: Type of symbol |
141 | 207 | decorated_symbol_exprt(
|
142 | 208 | const irep_idt &identifier,
|
143 | 209 | const typet &type):symbol_exprt(identifier, type)
|
@@ -207,14 +273,13 @@ inline void validate_expr(const symbol_exprt &value)
|
207 | 273 |
|
208 | 274 |
|
209 | 275 | /// \brief Expression to hold a nondeterministic choice
|
210 |
| -class nondet_symbol_exprt:public exprt |
| 276 | +class nondet_symbol_exprt : public nullary_exprt |
211 | 277 | {
|
212 | 278 | public:
|
213 | 279 | /// \param identifier: Name of symbol
|
214 |
| - /// \param : type Type of symbol |
215 |
| - nondet_symbol_exprt( |
216 |
| - const irep_idt &identifier, |
217 |
| - const typet &type):exprt(ID_nondet_symbol, type) |
| 280 | + /// \param type: Type of symbol |
| 281 | + nondet_symbol_exprt(const irep_idt &identifier, const typet &type) |
| 282 | + : nullary_exprt(ID_nondet_symbol, type) |
218 | 283 | {
|
219 | 284 | set_identifier(identifier);
|
220 | 285 | }
|
@@ -310,6 +375,13 @@ class unary_exprt:public exprt
|
310 | 375 | {
|
311 | 376 | return op0();
|
312 | 377 | }
|
| 378 | + |
| 379 | + const exprt &op1() const = delete; |
| 380 | + exprt &op1() = delete; |
| 381 | + const exprt &op2() const = delete; |
| 382 | + exprt &op2() = delete; |
| 383 | + const exprt &op3() const = delete; |
| 384 | + exprt &op3() = delete; |
313 | 385 | };
|
314 | 386 |
|
315 | 387 | /// \brief Cast an exprt to a \ref unary_exprt
|
@@ -666,8 +738,10 @@ class binary_exprt:public exprt
|
666 | 738 | copy_to_operands(_lhs, _rhs);
|
667 | 739 | }
|
668 | 740 |
|
669 |
| -protected: |
670 |
| - using exprt::op2; // hide |
| 741 | + const exprt &op2() const = delete; |
| 742 | + exprt &op2() = delete; |
| 743 | + const exprt &op3() const = delete; |
| 744 | + exprt &op3() = delete; |
671 | 745 | };
|
672 | 746 |
|
673 | 747 | /// \brief Cast an exprt to a \ref binary_exprt
|
@@ -3186,29 +3260,22 @@ inline void validate_expr(const dereference_exprt &value)
|
3186 | 3260 |
|
3187 | 3261 |
|
3188 | 3262 | /// \brief The trinary if-then-else operator
|
3189 |
| -class if_exprt:public exprt |
| 3263 | +class if_exprt : public ternary_exprt |
3190 | 3264 | {
|
3191 | 3265 | public:
|
3192 |
| - if_exprt(const exprt &cond, const exprt &t, const exprt &f): |
3193 |
| - exprt(ID_if, t.type()) |
| 3266 | + if_exprt(const exprt &cond, const exprt &t, const exprt &f) |
| 3267 | + : ternary_exprt(ID_if, cond, t, f, t.type()) |
3194 | 3268 | {
|
3195 |
| - copy_to_operands(cond, t, f); |
3196 | 3269 | }
|
3197 | 3270 |
|
3198 |
| - if_exprt( |
3199 |
| - const exprt &cond, |
3200 |
| - const exprt &t, |
3201 |
| - const exprt &f, |
3202 |
| - const typet &type): |
3203 |
| - exprt(ID_if, type) |
| 3271 | + if_exprt(const exprt &cond, const exprt &t, const exprt &f, const typet &type) |
| 3272 | + : ternary_exprt(ID_if, cond, t, f, type) |
3204 | 3273 | {
|
3205 |
| - copy_to_operands(cond, t, f); |
3206 | 3274 | }
|
3207 | 3275 |
|
3208 | 3276 | DEPRECATED("use if_exprt(cond, t, f) instead")
|
3209 |
| - if_exprt():exprt(ID_if) |
| 3277 | + if_exprt() : ternary_exprt(ID_if) |
3210 | 3278 | {
|
3211 |
| - operands().resize(3); |
3212 | 3279 | }
|
3213 | 3280 |
|
3214 | 3281 | exprt &cond()
|
@@ -3473,29 +3540,25 @@ inline void validate_expr(const member_designatort &value)
|
3473 | 3540 |
|
3474 | 3541 |
|
3475 | 3542 | /// \brief Operator to update elements in structs and arrays
|
3476 |
| -class update_exprt:public exprt |
| 3543 | +class update_exprt : public ternary_exprt |
3477 | 3544 | {
|
3478 | 3545 | public:
|
3479 | 3546 | update_exprt(
|
3480 | 3547 | const exprt &_old,
|
3481 | 3548 | const exprt &_designator,
|
3482 |
| - const exprt &_new_value): |
3483 |
| - exprt(ID_update, _old.type()) |
| 3549 | + const exprt &_new_value) |
| 3550 | + : ternary_exprt(ID_update, _old, _designator, _new_value, _old.type()) |
3484 | 3551 | {
|
3485 |
| - copy_to_operands(_old, _designator, _new_value); |
3486 | 3552 | }
|
3487 | 3553 |
|
3488 | 3554 | DEPRECATED("use update_exprt(old, where, new_value) instead")
|
3489 |
| - explicit update_exprt(const typet &_type): |
3490 |
| - exprt(ID_update, _type) |
| 3555 | + explicit update_exprt(const typet &_type) : ternary_exprt(ID_update, _type) |
3491 | 3556 | {
|
3492 |
| - operands().resize(3); |
3493 | 3557 | }
|
3494 | 3558 |
|
3495 | 3559 | DEPRECATED("use update_exprt(old, where, new_value) instead")
|
3496 |
| - update_exprt():exprt(ID_update) |
| 3560 | + update_exprt() : ternary_exprt(ID_update) |
3497 | 3561 | {
|
3498 |
| - operands().resize(3); |
3499 | 3562 | op1().id(ID_designator);
|
3500 | 3563 | }
|
3501 | 3564 |
|
@@ -4132,15 +4195,15 @@ inline ieee_float_op_exprt &to_ieee_float_op_expr(exprt &expr)
|
4132 | 4195 |
|
4133 | 4196 |
|
4134 | 4197 | /// \brief An expression denoting a type
|
4135 |
| -class type_exprt:public exprt |
| 4198 | +class type_exprt : public nullary_exprt |
4136 | 4199 | {
|
4137 | 4200 | public:
|
4138 | 4201 | DEPRECATED("use type_exprt(type) instead")
|
4139 |
| - type_exprt():exprt(ID_type) |
| 4202 | + type_exprt() : nullary_exprt(ID_type) |
4140 | 4203 | {
|
4141 | 4204 | }
|
4142 | 4205 |
|
4143 |
| - explicit type_exprt(const typet &type):exprt(ID_type, type) |
| 4206 | + explicit type_exprt(const typet &type) : nullary_exprt(ID_type, type) |
4144 | 4207 | {
|
4145 | 4208 | }
|
4146 | 4209 | };
|
@@ -4223,10 +4286,11 @@ class false_exprt:public constant_exprt
|
4223 | 4286 | };
|
4224 | 4287 |
|
4225 | 4288 | /// \brief The NIL expression
|
4226 |
| -class nil_exprt:public exprt |
| 4289 | +class nil_exprt : public nullary_exprt |
4227 | 4290 | {
|
4228 | 4291 | public:
|
4229 |
| - nil_exprt():exprt(static_cast<const exprt &>(get_nil_irep())) |
| 4292 | + nil_exprt() |
| 4293 | + : nullary_exprt(static_cast<const nullary_exprt &>(get_nil_irep())) |
4230 | 4294 | {
|
4231 | 4295 | }
|
4232 | 4296 | };
|
@@ -4393,11 +4457,11 @@ template<> inline bool can_cast_expr<concatenation_exprt>(const exprt &base)
|
4393 | 4457 |
|
4394 | 4458 |
|
4395 | 4459 | /// \brief An expression denoting infinity
|
4396 |
| -class infinity_exprt:public exprt |
| 4460 | +class infinity_exprt : public nullary_exprt |
4397 | 4461 | {
|
4398 | 4462 | public:
|
4399 |
| - explicit infinity_exprt(const typet &_type): |
4400 |
| - exprt(ID_infinity, _type) |
| 4463 | + explicit infinity_exprt(const typet &_type) |
| 4464 | + : nullary_exprt(ID_infinity, _type) |
4401 | 4465 | {
|
4402 | 4466 | }
|
4403 | 4467 | };
|
|
0 commit comments