@@ -4327,48 +4327,112 @@ class binding_exprt : public binary_exprt
4327
4327
};
4328
4328
4329
4329
// / \brief A let expression
4330
- class let_exprt : public ternary_exprt
4330
+ class let_exprt : public binary_exprt
4331
4331
{
4332
4332
public:
4333
- let_exprt (symbol_exprt symbol, exprt value, const exprt &where)
4334
- : ternary_exprt(
4333
+ let_exprt (
4334
+ binding_exprt::variablest variables,
4335
+ operandst values,
4336
+ const exprt &where)
4337
+ : binary_exprt(
4338
+ binding_exprt (
4339
+ ID_let_binding,
4340
+ std::move (variables),
4341
+ where,
4342
+ where.type()),
4335
4343
ID_let,
4336
- std::move (symbol),
4337
- std::move(value),
4338
- where,
4344
+ multi_ary_exprt(irep_idt(), std::move(values), typet(ID_tuple)),
4339
4345
where.type())
4340
4346
{
4347
+ PRECONDITION (this ->variables ().size () == this ->values ().size ());
4348
+ }
4349
+
4350
+ // / convenience constructor for the case of a single binding
4351
+ let_exprt (symbol_exprt symbol, exprt value, const exprt &where)
4352
+ : let_exprt(
4353
+ binding_exprt::variablest{std::move (symbol)},
4354
+ operandst{std::move (value)},
4355
+ where)
4356
+ {
4357
+ }
4358
+
4359
+ binding_exprt &binding ()
4360
+ {
4361
+ return static_cast <binding_exprt &>(op0 ());
4362
+ }
4363
+
4364
+ const binding_exprt &binding () const
4365
+ {
4366
+ return static_cast <const binding_exprt &>(op0 ());
4341
4367
}
4342
4368
4369
+ // / convenience accessor for the symbol of a single binding
4343
4370
symbol_exprt &symbol ()
4344
4371
{
4345
- return static_cast <symbol_exprt &>(op0 ());
4372
+ auto &variables = binding ().variables ();
4373
+ PRECONDITION (variables.size () == 1 );
4374
+ return variables.front ();
4346
4375
}
4347
4376
4377
+ // / convenience accessor for the symbol of a single binding
4348
4378
const symbol_exprt &symbol () const
4349
4379
{
4350
- return static_cast <const symbol_exprt &>(op0 ());
4380
+ const auto &variables = binding ().variables ();
4381
+ PRECONDITION (variables.size () == 1 );
4382
+ return variables.front ();
4351
4383
}
4352
4384
4385
+ // / convenience accessor for the value of a single binding
4353
4386
exprt &value ()
4354
4387
{
4355
- return op1 ();
4388
+ auto &values = this ->values ();
4389
+ PRECONDITION (values.size () == 1 );
4390
+ return values.front ();
4356
4391
}
4357
4392
4393
+ // / convenience accessor for the value of a single binding
4358
4394
const exprt &value () const
4359
4395
{
4360
- return op1 ();
4396
+ const auto &values = this ->values ();
4397
+ PRECONDITION (values.size () == 1 );
4398
+ return values.front ();
4399
+ }
4400
+
4401
+ operandst &values ()
4402
+ {
4403
+ return static_cast <multi_ary_exprt &>(op1 ()).operands ();
4404
+ }
4405
+
4406
+ const operandst &values () const
4407
+ {
4408
+ return static_cast <const multi_ary_exprt &>(op1 ()).operands ();
4409
+ }
4410
+
4411
+ // / convenience accessor for binding().variables()
4412
+ binding_exprt::variablest &variables ()
4413
+ {
4414
+ return binding ().variables ();
4415
+ }
4416
+
4417
+ // / convenience accessor for binding().variables()
4418
+ const binding_exprt::variablest &variables () const
4419
+ {
4420
+ return binding ().variables ();
4361
4421
}
4362
4422
4423
+ // / convenience accessor for binding().where()
4363
4424
exprt &where ()
4364
4425
{
4365
- return op2 ();
4426
+ return binding (). where ();
4366
4427
}
4367
4428
4429
+ // / convenience accessor for binding().where()
4368
4430
const exprt &where () const
4369
4431
{
4370
- return op2 ();
4432
+ return binding (). where ();
4371
4433
}
4434
+
4435
+ static void validate (const exprt &, validation_modet);
4372
4436
};
4373
4437
4374
4438
template <>
@@ -4377,9 +4441,9 @@ inline bool can_cast_expr<let_exprt>(const exprt &base)
4377
4441
return base.id () == ID_let;
4378
4442
}
4379
4443
4380
- inline void validate_expr (const let_exprt &value )
4444
+ inline void validate_expr (const let_exprt &let_expr )
4381
4445
{
4382
- validate_operands (value, 3 , " Let must have three operands" );
4446
+ validate_operands (let_expr, 2 , " Let must have two operands" );
4383
4447
}
4384
4448
4385
4449
// / \brief Cast an exprt to a \ref let_exprt
0 commit comments