@@ -1003,15 +1003,13 @@ inline bool can_cast_type<code_typet>(const typet &type)
1003
1003
inline const code_typet &to_code_type (const typet &type)
1004
1004
{
1005
1005
PRECONDITION (can_cast_type<code_typet>(type));
1006
- validate_type (type);
1007
1006
return static_cast <const code_typet &>(type);
1008
1007
}
1009
1008
1010
1009
// / \copydoc to_code_type(const typet &)
1011
1010
inline code_typet &to_code_type (typet &type)
1012
1011
{
1013
1012
PRECONDITION (can_cast_type<code_typet>(type));
1014
- validate_type (type);
1015
1013
return static_cast <code_typet &>(type);
1016
1014
}
1017
1015
@@ -1198,6 +1196,13 @@ class bv_typet:public bitvector_typet
1198
1196
{
1199
1197
set_width (width);
1200
1198
}
1199
+
1200
+ static void check (
1201
+ const typet &type,
1202
+ const validation_modet vm = validation_modet::INVARIANT)
1203
+ {
1204
+ DATA_CHECK (!type.get (ID_width).empty (), " bitvector type must have width" );
1205
+ }
1201
1206
};
1202
1207
1203
1208
// / Check whether a reference to a typet is a \ref bv_typet.
@@ -1209,11 +1214,6 @@ inline bool can_cast_type<bv_typet>(const typet &type)
1209
1214
return type.id () == ID_bv;
1210
1215
}
1211
1216
1212
- inline void validate_type (const bv_typet &type)
1213
- {
1214
- DATA_INVARIANT (!type.get (ID_width).empty (), " bitvector type must have width" );
1215
- }
1216
-
1217
1217
// / \brief Cast a typet to a \ref bv_typet
1218
1218
// /
1219
1219
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1225,18 +1225,16 @@ inline void validate_type(const bv_typet &type)
1225
1225
inline const bv_typet &to_bv_type (const typet &type)
1226
1226
{
1227
1227
PRECONDITION (can_cast_type<bv_typet>(type));
1228
- const bv_typet &ret = static_cast <const bv_typet &>(type);
1229
- validate_type (ret);
1230
- return ret;
1228
+ bv_typet::check (type);
1229
+ return static_cast <const bv_typet &>(type);
1231
1230
}
1232
1231
1233
1232
// / \copydoc to_bv_type(const typet &)
1234
1233
inline bv_typet &to_bv_type (typet &type)
1235
1234
{
1236
1235
PRECONDITION (can_cast_type<bv_typet>(type));
1237
- bv_typet &ret = static_cast <bv_typet &>(type);
1238
- validate_type (ret);
1239
- return ret;
1236
+ bv_typet::check (type);
1237
+ return static_cast <bv_typet &>(type);
1240
1238
}
1241
1239
1242
1240
// / Fixed-width bit-vector with unsigned binary interpretation
@@ -1308,6 +1306,14 @@ class signedbv_typet:public bitvector_typet
1308
1306
constant_exprt smallest_expr () const ;
1309
1307
constant_exprt zero_expr () const ;
1310
1308
constant_exprt largest_expr () const ;
1309
+
1310
+ static void check (
1311
+ const typet &type,
1312
+ const validation_modet vm = validation_modet::INVARIANT)
1313
+ {
1314
+ DATA_CHECK (
1315
+ !type.get (ID_width).empty (), " signed bitvector type must have width" );
1316
+ }
1311
1317
};
1312
1318
1313
1319
// / Check whether a reference to a typet is a \ref signedbv_typet.
@@ -1319,12 +1325,6 @@ inline bool can_cast_type<signedbv_typet>(const typet &type)
1319
1325
return type.id () == ID_signedbv;
1320
1326
}
1321
1327
1322
- inline void validate_type (const signedbv_typet &type)
1323
- {
1324
- DATA_INVARIANT (
1325
- !type.get (ID_width).empty (), " signed bitvector type must have width" );
1326
- }
1327
-
1328
1328
// / \brief Cast a typet to a \ref signedbv_typet
1329
1329
// /
1330
1330
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1336,18 +1336,16 @@ inline void validate_type(const signedbv_typet &type)
1336
1336
inline const signedbv_typet &to_signedbv_type (const typet &type)
1337
1337
{
1338
1338
PRECONDITION (can_cast_type<signedbv_typet>(type));
1339
- const signedbv_typet &ret = static_cast <const signedbv_typet &>(type);
1340
- validate_type (ret);
1341
- return ret;
1339
+ signedbv_typet::check (type);
1340
+ return static_cast <const signedbv_typet &>(type);
1342
1341
}
1343
1342
1344
1343
// / \copydoc to_signedbv_type(const typet &)
1345
1344
inline signedbv_typet &to_signedbv_type (typet &type)
1346
1345
{
1347
1346
PRECONDITION (can_cast_type<signedbv_typet>(type));
1348
- signedbv_typet &ret = static_cast <signedbv_typet &>(type);
1349
- validate_type (ret);
1350
- return ret;
1347
+ signedbv_typet::check (type);
1348
+ return static_cast <signedbv_typet &>(type);
1351
1349
}
1352
1350
1353
1351
// / Fixed-width bit-vector with signed fixed-point interpretation
@@ -1372,6 +1370,14 @@ class fixedbv_typet:public bitvector_typet
1372
1370
{
1373
1371
set (ID_integer_bits, b);
1374
1372
}
1373
+
1374
+ static void check (
1375
+ const typet &type,
1376
+ const validation_modet vm = validation_modet::INVARIANT)
1377
+ {
1378
+ DATA_CHECK (
1379
+ !type.get (ID_width).empty (), " fixed bitvector type must have width" );
1380
+ }
1375
1381
};
1376
1382
1377
1383
// / Check whether a reference to a typet is a \ref fixedbv_typet.
@@ -1383,12 +1389,6 @@ inline bool can_cast_type<fixedbv_typet>(const typet &type)
1383
1389
return type.id () == ID_fixedbv;
1384
1390
}
1385
1391
1386
- inline void validate_type (const fixedbv_typet &type)
1387
- {
1388
- DATA_INVARIANT (
1389
- !type.get (ID_width).empty (), " fixed bitvector type must have width" );
1390
- }
1391
-
1392
1392
// / \brief Cast a typet to a \ref fixedbv_typet
1393
1393
// /
1394
1394
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1400,18 +1400,16 @@ inline void validate_type(const fixedbv_typet &type)
1400
1400
inline const fixedbv_typet &to_fixedbv_type (const typet &type)
1401
1401
{
1402
1402
PRECONDITION (can_cast_type<fixedbv_typet>(type));
1403
- const fixedbv_typet &ret = static_cast <const fixedbv_typet &>(type);
1404
- validate_type (ret);
1405
- return ret;
1403
+ fixedbv_typet::check (type);
1404
+ return static_cast <const fixedbv_typet &>(type);
1406
1405
}
1407
1406
1408
1407
// / \copydoc to_fixedbv_type(const typet &)
1409
1408
inline fixedbv_typet &to_fixedbv_type (typet &type)
1410
1409
{
1411
1410
PRECONDITION (can_cast_type<fixedbv_typet>(type));
1412
- fixedbv_typet &ret = static_cast <fixedbv_typet &>(type);
1413
- validate_type (ret);
1414
- return ret;
1411
+ fixedbv_typet::check (type);
1412
+ return static_cast <fixedbv_typet &>(type);
1415
1413
}
1416
1414
1417
1415
// / Fixed-width bit-vector with IEEE floating-point interpretation
@@ -1434,6 +1432,14 @@ class floatbv_typet:public bitvector_typet
1434
1432
{
1435
1433
set (ID_f, b);
1436
1434
}
1435
+
1436
+ static void check (
1437
+ const typet &type,
1438
+ const validation_modet vm = validation_modet::INVARIANT)
1439
+ {
1440
+ DATA_CHECK (
1441
+ !type.get (ID_width).empty (), " float bitvector type must have width" );
1442
+ }
1437
1443
};
1438
1444
1439
1445
// / Check whether a reference to a typet is a \ref floatbv_typet.
@@ -1445,12 +1451,6 @@ inline bool can_cast_type<floatbv_typet>(const typet &type)
1445
1451
return type.id () == ID_floatbv;
1446
1452
}
1447
1453
1448
- inline void validate_type (const floatbv_typet &type)
1449
- {
1450
- DATA_INVARIANT (
1451
- !type.get (ID_width).empty (), " float bitvector type must have width" );
1452
- }
1453
-
1454
1454
// / \brief Cast a typet to a \ref floatbv_typet
1455
1455
// /
1456
1456
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1462,18 +1462,16 @@ inline void validate_type(const floatbv_typet &type)
1462
1462
inline const floatbv_typet &to_floatbv_type (const typet &type)
1463
1463
{
1464
1464
PRECONDITION (can_cast_type<floatbv_typet>(type));
1465
- const floatbv_typet &ret = static_cast <const floatbv_typet &>(type);
1466
- validate_type (ret);
1467
- return ret;
1465
+ floatbv_typet::check (type);
1466
+ return static_cast <const floatbv_typet &>(type);
1468
1467
}
1469
1468
1470
1469
// / \copydoc to_floatbv_type(const typet &)
1471
1470
inline floatbv_typet &to_floatbv_type (typet &type)
1472
1471
{
1473
1472
PRECONDITION (can_cast_type<floatbv_typet>(type));
1474
- floatbv_typet &ret = static_cast <floatbv_typet &>(type);
1475
- validate_type (ret);
1476
- return ret;
1473
+ floatbv_typet::check (type);
1474
+ return static_cast <floatbv_typet &>(type);
1477
1475
}
1478
1476
1479
1477
// / Type for C bit fields
@@ -1537,6 +1535,13 @@ class pointer_typet:public bitvector_typet
1537
1535
{
1538
1536
return signedbv_typet (get_width ());
1539
1537
}
1538
+
1539
+ static void check (
1540
+ const typet &type,
1541
+ const validation_modet vm = validation_modet::INVARIANT)
1542
+ {
1543
+ DATA_CHECK (!type.get (ID_width).empty (), " pointer must have width" );
1544
+ }
1540
1545
};
1541
1546
1542
1547
// / Check whether a reference to a typet is a \ref pointer_typet.
@@ -1548,11 +1553,6 @@ inline bool can_cast_type<pointer_typet>(const typet &type)
1548
1553
return type.id () == ID_pointer;
1549
1554
}
1550
1555
1551
- inline void validate_type (const pointer_typet &type)
1552
- {
1553
- DATA_INVARIANT (!type.get (ID_width).empty (), " pointer must have width" );
1554
- }
1555
-
1556
1556
// / \brief Cast a typet to a \ref pointer_typet
1557
1557
// /
1558
1558
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1564,18 +1564,16 @@ inline void validate_type(const pointer_typet &type)
1564
1564
inline const pointer_typet &to_pointer_type (const typet &type)
1565
1565
{
1566
1566
PRECONDITION (can_cast_type<pointer_typet>(type));
1567
- const pointer_typet &ret = static_cast <const pointer_typet &>(type);
1568
- validate_type (ret);
1569
- return ret;
1567
+ pointer_typet::check (type);
1568
+ return static_cast <const pointer_typet &>(type);
1570
1569
}
1571
1570
1572
1571
// / \copydoc to_pointer_type(const typet &)
1573
1572
inline pointer_typet &to_pointer_type (typet &type)
1574
1573
{
1575
1574
PRECONDITION (can_cast_type<pointer_typet>(type));
1576
- pointer_typet &ret = static_cast <pointer_typet &>(type);
1577
- validate_type (ret);
1578
- return ret;
1575
+ pointer_typet::check (type);
1576
+ return static_cast <pointer_typet &>(type);
1579
1577
}
1580
1578
1581
1579
// / The reference type
@@ -1635,6 +1633,13 @@ class c_bool_typet:public bitvector_typet
1635
1633
bitvector_typet(ID_c_bool, width)
1636
1634
{
1637
1635
}
1636
+
1637
+ static void check (
1638
+ const typet &type,
1639
+ const validation_modet vm = validation_modet::INVARIANT)
1640
+ {
1641
+ DATA_CHECK (!type.get (ID_width).empty (), " C bool type must have width" );
1642
+ }
1638
1643
};
1639
1644
1640
1645
// / Check whether a reference to a typet is a \ref c_bool_typet.
@@ -1646,11 +1651,6 @@ inline bool can_cast_type<c_bool_typet>(const typet &type)
1646
1651
return type.id () == ID_c_bool;
1647
1652
}
1648
1653
1649
- inline void validate_type (const c_bool_typet &type)
1650
- {
1651
- DATA_INVARIANT (!type.get (ID_width).empty (), " C bool type must have width" );
1652
- }
1653
-
1654
1654
// / \brief Cast a typet to a \ref c_bool_typet
1655
1655
// /
1656
1656
// / This is an unchecked conversion. \a type must be known to be \ref
@@ -1662,18 +1662,16 @@ inline void validate_type(const c_bool_typet &type)
1662
1662
inline const c_bool_typet &to_c_bool_type (const typet &type)
1663
1663
{
1664
1664
PRECONDITION (can_cast_type<c_bool_typet>(type));
1665
- const c_bool_typet &ret = static_cast <const c_bool_typet &>(type);
1666
- validate_type (ret);
1667
- return ret;
1665
+ c_bool_typet::check (type);
1666
+ return static_cast <const c_bool_typet &>(type);
1668
1667
}
1669
1668
1670
1669
// / \copydoc to_c_bool_type(const typet &)
1671
1670
inline c_bool_typet &to_c_bool_type (typet &type)
1672
1671
{
1673
1672
PRECONDITION (can_cast_type<c_bool_typet>(type));
1674
- c_bool_typet &ret = static_cast <c_bool_typet &>(type);
1675
- validate_type (ret);
1676
- return ret;
1673
+ c_bool_typet::check (type);
1674
+ return static_cast <c_bool_typet &>(type);
1677
1675
}
1678
1676
1679
1677
// / String type
0 commit comments