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