@@ -1329,32 +1329,28 @@ inline void validate_expr(const notequal_exprt &value)
1329
1329
1330
1330
/* ! \brief array index operator
1331
1331
*/
1332
- class index_exprt :public exprt
1332
+ class index_exprt :public binary_exprt
1333
1333
{
1334
1334
public:
1335
- index_exprt ():exprt (ID_index)
1335
+ index_exprt ():binary_exprt (ID_index)
1336
1336
{
1337
- operands ().resize (2 );
1338
1337
}
1339
1338
1340
- explicit index_exprt (const typet &_type):exprt (ID_index, _type)
1339
+ explicit index_exprt (const typet &_type):binary_exprt (ID_index, _type)
1341
1340
{
1342
- operands ().resize (2 );
1343
1341
}
1344
1342
1345
1343
index_exprt (const exprt &_array, const exprt &_index):
1346
- exprt ( ID_index, _array.type().subtype())
1344
+ binary_exprt (_array, ID_index, _index , _array.type().subtype())
1347
1345
{
1348
- copy_to_operands (_array, _index);
1349
1346
}
1350
1347
1351
1348
index_exprt (
1352
1349
const exprt &_array,
1353
1350
const exprt &_index,
1354
1351
const typet &_type):
1355
- exprt ( ID_index, _type)
1352
+ binary_exprt (_array, ID_index, _index , _type)
1356
1353
{
1357
- copy_to_operands (_array, _index);
1358
1354
}
1359
1355
1360
1356
exprt &array ()
@@ -1795,12 +1791,11 @@ class namespacet;
1795
1791
1796
1792
/* ! \brief split an expression into a base object and a (byte) offset
1797
1793
*/
1798
- class object_descriptor_exprt :public exprt
1794
+ class object_descriptor_exprt :public binary_exprt
1799
1795
{
1800
1796
public:
1801
- object_descriptor_exprt ():exprt (ID_object_descriptor)
1797
+ object_descriptor_exprt ():binary_exprt (ID_object_descriptor)
1802
1798
{
1803
- operands ().resize (2 );
1804
1799
op0 ().id (ID_unknown);
1805
1800
op1 ().id (ID_unknown);
1806
1801
}
@@ -1886,20 +1881,18 @@ inline void validate_expr(const object_descriptor_exprt &value)
1886
1881
1887
1882
/* ! \brief TO_BE_DOCUMENTED
1888
1883
*/
1889
- class dynamic_object_exprt :public exprt
1884
+ class dynamic_object_exprt :public binary_exprt
1890
1885
{
1891
1886
public:
1892
- dynamic_object_exprt ():exprt (ID_dynamic_object)
1887
+ dynamic_object_exprt ():binary_exprt (ID_dynamic_object)
1893
1888
{
1894
- operands ().resize (2 );
1895
1889
op0 ().id (ID_unknown);
1896
1890
op1 ().id (ID_unknown);
1897
1891
}
1898
1892
1899
1893
explicit dynamic_object_exprt (const typet &type):
1900
- exprt (ID_dynamic_object, type)
1894
+ binary_exprt (ID_dynamic_object, type)
1901
1895
{
1902
- operands ().resize (2 );
1903
1896
op0 ().id (ID_unknown);
1904
1897
op1 ().id (ID_unknown);
1905
1898
}
@@ -1955,6 +1948,7 @@ template<> inline bool can_cast_expr<dynamic_object_exprt>(const exprt &base)
1955
1948
{
1956
1949
return base.id ()==ID_dynamic_object;
1957
1950
}
1951
+
1958
1952
inline void validate_expr (const dynamic_object_exprt &value)
1959
1953
{
1960
1954
validate_operands (value, 2 , " Dynamic object must have two operands" );
@@ -1963,18 +1957,16 @@ inline void validate_expr(const dynamic_object_exprt &value)
1963
1957
1964
1958
/* ! \brief semantic type conversion
1965
1959
*/
1966
- class typecast_exprt :public exprt
1960
+ class typecast_exprt :public unary_exprt
1967
1961
{
1968
1962
public:
1969
- explicit typecast_exprt (const typet &_type):exprt (ID_typecast, _type)
1963
+ explicit typecast_exprt (const typet &_type):unary_exprt (ID_typecast, _type)
1970
1964
{
1971
- operands ().resize (1 );
1972
1965
}
1973
1966
1974
1967
typecast_exprt (const exprt &op, const typet &_type):
1975
- exprt (ID_typecast, _type)
1968
+ unary_exprt (ID_typecast, op , _type)
1976
1969
{
1977
- copy_to_operands (op);
1978
1970
}
1979
1971
1980
1972
exprt &op ()
@@ -3031,17 +3023,17 @@ inline void validate_expr(const address_of_exprt &value)
3031
3023
3032
3024
/* ! \brief Boolean negation
3033
3025
*/
3034
- class not_exprt :public exprt
3026
+ class not_exprt :public unary_exprt
3035
3027
{
3036
3028
public:
3037
- explicit not_exprt (const exprt &op):exprt(ID_not, bool_typet())
3029
+ explicit not_exprt (const exprt &op):
3030
+ unary_exprt(ID_not, op) // type from op.type()
3038
3031
{
3039
- copy_to_operands (op);
3032
+ PRECONDITION (op. type (). id ()==ID_bool );
3040
3033
}
3041
3034
3042
- not_exprt ():exprt (ID_not, bool_typet())
3035
+ not_exprt ():unary_exprt (ID_not, bool_typet())
3043
3036
{
3044
- operands ().resize (1 );
3045
3037
}
3046
3038
3047
3039
exprt &op ()
@@ -3086,6 +3078,7 @@ template<> inline bool can_cast_expr<not_exprt>(const exprt &base)
3086
3078
{
3087
3079
return base.id ()==ID_not;
3088
3080
}
3081
+
3089
3082
inline void validate_expr (const not_exprt &value)
3090
3083
{
3091
3084
validate_operands (value, 1 , " Not must have one operand" );
@@ -3094,30 +3087,27 @@ inline void validate_expr(const not_exprt &value)
3094
3087
3095
3088
/* ! \brief Operator to dereference a pointer
3096
3089
*/
3097
- class dereference_exprt :public exprt
3090
+ class dereference_exprt :public unary_exprt
3098
3091
{
3099
3092
public:
3100
- explicit dereference_exprt (const typet &type):
3101
- exprt(ID_dereference, type)
3093
+ dereference_exprt ():unary_exprt(ID_dereference)
3102
3094
{
3103
- operands ().resize (1 );
3104
3095
}
3105
3096
3106
- explicit dereference_exprt (const exprt &op ):
3107
- exprt (ID_dereference)
3097
+ explicit dereference_exprt (const typet &type ):
3098
+ unary_exprt (ID_dereference, type )
3108
3099
{
3109
- copy_to_operands (op);
3110
3100
}
3111
3101
3112
- dereference_exprt (const exprt &op, const typet &type ):
3113
- exprt (ID_dereference, type)
3102
+ explicit dereference_exprt (const exprt &op):
3103
+ unary_exprt (ID_dereference, op, op. type().subtype() )
3114
3104
{
3115
- copy_to_operands (op);
3105
+ PRECONDITION (op. type (). id ()==ID_pointer );
3116
3106
}
3117
3107
3118
- dereference_exprt ():exprt(ID_dereference)
3108
+ dereference_exprt (const exprt &op, const typet &type):
3109
+ unary_exprt (ID_dereference, op, type)
3119
3110
{
3120
- operands ().resize (1 );
3121
3111
}
3122
3112
3123
3113
exprt &pointer ()
@@ -3684,39 +3674,33 @@ inline void validate_expr(const array_update_exprt &value)
3684
3674
3685
3675
/* ! \brief Extract member of struct or union
3686
3676
*/
3687
- class member_exprt :public exprt
3677
+ class member_exprt :public unary_exprt
3688
3678
{
3689
3679
public:
3690
- explicit member_exprt (const exprt &op):exprt(ID_member)
3680
+ // deprecated, and will go away -- use either of the two below
3681
+ explicit member_exprt (const typet &_type):unary_exprt(ID_member, _type)
3691
3682
{
3692
- copy_to_operands (op);
3693
3683
}
3694
3684
3695
- explicit member_exprt (const typet &_type):exprt(ID_member, _type)
3696
- {
3697
- operands ().resize (1 );
3698
- }
3699
-
3700
- member_exprt (const exprt &op, const irep_idt &component_name):
3701
- exprt (ID_member)
3685
+ member_exprt (
3686
+ const exprt &op,
3687
+ const irep_idt &component_name,
3688
+ const typet &_type):
3689
+ unary_exprt (ID_member, op, _type)
3702
3690
{
3703
- copy_to_operands (op);
3704
3691
set_component_name (component_name);
3705
3692
}
3706
3693
3707
3694
member_exprt (
3708
3695
const exprt &op,
3709
- const irep_idt &component_name,
3710
- const typet &_type):
3711
- exprt (ID_member, _type)
3696
+ const struct_typet::componentt &c):
3697
+ unary_exprt (ID_member, op, c.type())
3712
3698
{
3713
- copy_to_operands (op);
3714
- set_component_name (component_name);
3699
+ set_component_name (c.get_name ());
3715
3700
}
3716
3701
3717
- member_exprt ():exprt (ID_member)
3702
+ member_exprt ():unary_exprt (ID_member)
3718
3703
{
3719
- operands ().resize (1 );
3720
3704
}
3721
3705
3722
3706
irep_idt get_component_name () const
@@ -3734,11 +3718,6 @@ class member_exprt:public exprt
3734
3718
return get_size_t (ID_component_number);
3735
3719
}
3736
3720
3737
- void set_component_number (std::size_t component_number)
3738
- {
3739
- set (ID_component_number, component_number);
3740
- }
3741
-
3742
3721
// will go away, use compound()
3743
3722
const exprt &struct_op () const
3744
3723
{
@@ -3769,6 +3748,7 @@ class member_exprt:public exprt
3769
3748
{
3770
3749
return static_cast <const member_exprt &>(op).symbol ();
3771
3750
}
3751
+
3772
3752
return to_symbol_expr (op);
3773
3753
}
3774
3754
};
@@ -4359,18 +4339,18 @@ class null_pointer_exprt:public constant_exprt
4359
4339
4360
4340
/* ! \brief application of (mathematical) function
4361
4341
*/
4362
- class function_application_exprt :public exprt
4342
+ class function_application_exprt :public binary_exprt
4363
4343
{
4364
4344
public:
4365
- function_application_exprt ():exprt (ID_function_application)
4345
+ function_application_exprt ():binary_exprt (ID_function_application)
4366
4346
{
4367
- operands (). resize ( 2 );
4347
+ op0 ()= symbol_exprt ( );
4368
4348
}
4369
4349
4370
4350
explicit function_application_exprt (const typet &_type):
4371
- exprt (ID_function_application, _type)
4351
+ binary_exprt (ID_function_application, _type)
4372
4352
{
4373
- operands (). resize ( 2 );
4353
+ op0 ()= symbol_exprt ( );
4374
4354
}
4375
4355
4376
4356
function_application_exprt (
@@ -4380,14 +4360,14 @@ class function_application_exprt:public exprt
4380
4360
function ()=_function;
4381
4361
}
4382
4362
4383
- exprt &function ()
4363
+ symbol_exprt &function ()
4384
4364
{
4385
- return op0 ();
4365
+ return static_cast <symbol_exprt &>( op0 () );
4386
4366
}
4387
4367
4388
- const exprt &function () const
4368
+ const symbol_exprt &function () const
4389
4369
{
4390
- return op0 ();
4370
+ return static_cast < const symbol_exprt &>( op0 () );
4391
4371
}
4392
4372
4393
4373
typedef exprt::operandst argumentst;
@@ -4612,12 +4592,11 @@ inline void validate_expr(const let_exprt &value)
4612
4592
4613
4593
/* ! \brief A forall expression
4614
4594
*/
4615
- class forall_exprt :public exprt
4595
+ class forall_exprt :public binary_exprt
4616
4596
{
4617
4597
public:
4618
- forall_exprt ():exprt (ID_forall)
4598
+ forall_exprt ():binary_exprt (ID_forall)
4619
4599
{
4620
- operands ().resize (2 );
4621
4600
op0 ()=symbol_exprt ();
4622
4601
}
4623
4602
@@ -4644,12 +4623,11 @@ class forall_exprt:public exprt
4644
4623
4645
4624
/* ! \brief An exists expression
4646
4625
*/
4647
- class exists_exprt :public exprt
4626
+ class exists_exprt :public binary_exprt
4648
4627
{
4649
4628
public:
4650
- exists_exprt ():exprt (ID_exists)
4629
+ exists_exprt ():binary_exprt (ID_exists)
4651
4630
{
4652
- operands ().resize (2 );
4653
4631
op0 ()=symbol_exprt ();
4654
4632
}
4655
4633
0 commit comments