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