Skip to content

Commit fea38c0

Browse files
committed
constructors for multi-ary expressions with operand type
This adds a new constructor to the base class multi_ary_exprt and classes derived from that. The new constructor takes a non-empty sequence of operands, and takes the type of the expression from the type of the first operand.
1 parent ee19dd7 commit fea38c0

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/util/bitvector_expr.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ class bitor_exprt : public multi_ary_exprt
131131
{
132132
}
133133

134+
explicit bitor_exprt(exprt::operandst _operands)
135+
: multi_ary_exprt(ID_bitor, std::move(_operands))
136+
{
137+
}
138+
134139
bitor_exprt(exprt::operandst _operands, typet _type)
135140
: multi_ary_exprt(ID_bitor, std::move(_operands), std::move(_type))
136141
{
@@ -177,6 +182,11 @@ class bitnor_exprt : public multi_ary_exprt
177182
{
178183
}
179184

185+
explicit bitnor_exprt(exprt::operandst _operands)
186+
: multi_ary_exprt(ID_bitnor, std::move(_operands))
187+
{
188+
}
189+
180190
bitnor_exprt(exprt::operandst _operands, typet _type)
181191
: multi_ary_exprt(ID_bitnor, std::move(_operands), std::move(_type))
182192
{
@@ -219,6 +229,11 @@ class bitxor_exprt : public multi_ary_exprt
219229
{
220230
}
221231

232+
explicit bitxor_exprt(exprt::operandst _operands)
233+
: multi_ary_exprt(ID_bitxor, std::move(_operands))
234+
{
235+
}
236+
222237
bitxor_exprt(exprt::operandst _operands, typet _type)
223238
: multi_ary_exprt(ID_bitxor, std::move(_operands), std::move(_type))
224239
{
@@ -265,6 +280,11 @@ class bitxnor_exprt : public multi_ary_exprt
265280
{
266281
}
267282

283+
explicit bitxnor_exprt(exprt::operandst _operands)
284+
: multi_ary_exprt(ID_bitxnor, std::move(_operands))
285+
{
286+
}
287+
268288
bitxnor_exprt(exprt::operandst _operands, typet _type)
269289
: multi_ary_exprt(ID_bitxnor, std::move(_operands), std::move(_type))
270290
{
@@ -309,6 +329,11 @@ class bitand_exprt : public multi_ary_exprt
309329
{
310330
}
311331

332+
explicit bitand_exprt(exprt::operandst _operands)
333+
: multi_ary_exprt(ID_bitand, std::move(_operands))
334+
{
335+
}
336+
312337
bitand_exprt(exprt::operandst _operands, typet _type)
313338
: multi_ary_exprt(ID_bitand, std::move(_operands), std::move(_type))
314339
{
@@ -355,6 +380,11 @@ class bitnand_exprt : public multi_ary_exprt
355380
{
356381
}
357382

383+
explicit bitnand_exprt(exprt::operandst _operands)
384+
: multi_ary_exprt(ID_bitnand, std::move(_operands))
385+
{
386+
}
387+
358388
bitnand_exprt(exprt::operandst _operands, typet _type)
359389
: multi_ary_exprt(ID_bitnand, std::move(_operands), std::move(_type))
360390
{

src/util/std_expr.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,14 @@ class multi_ary_exprt : public expr_protectedt
917917
operands() = std::move(_operands);
918918
}
919919

920+
multi_ary_exprt(const irep_idt &_id, operandst _operands)
921+
: expr_protectedt(_id, typet{})
922+
{
923+
PRECONDITION(!_operands.empty());
924+
type() = _operands.front().type();
925+
operands() = std::move(_operands);
926+
}
927+
920928
multi_ary_exprt(const exprt &_lhs, const irep_idt &_id, exprt _rhs)
921929
: expr_protectedt(_id, _lhs.type(), {_lhs, std::move(_rhs)})
922930
{
@@ -1015,6 +1023,11 @@ class plus_exprt:public multi_ary_exprt
10151023
{
10161024
}
10171025

1026+
explicit plus_exprt(operandst _operands)
1027+
: multi_ary_exprt(ID_plus, std::move(_operands))
1028+
{
1029+
}
1030+
10181031
plus_exprt(operandst _operands, typet _type)
10191032
: multi_ary_exprt(ID_plus, std::move(_operands), std::move(_type))
10201033
{
@@ -1111,6 +1124,11 @@ class mult_exprt:public multi_ary_exprt
11111124
{
11121125
}
11131126

1127+
explicit mult_exprt(exprt::operandst factors)
1128+
: multi_ary_exprt(ID_mult, std::move(factors))
1129+
{
1130+
}
1131+
11141132
mult_exprt(exprt::operandst factors, typet type)
11151133
: multi_ary_exprt(ID_mult, std::move(factors), std::move(type))
11161134
{

0 commit comments

Comments
 (0)