@@ -1329,32 +1329,28 @@ inline void validate_expr(const notequal_exprt &value)
13291329
13301330/* ! \brief array index operator
13311331*/
1332- class index_exprt :public exprt
1332+ class index_exprt :public binary_exprt
13331333{
13341334public:
1335- index_exprt ():exprt (ID_index)
1335+ index_exprt ():binary_exprt (ID_index)
13361336 {
1337- operands ().resize (2 );
13381337 }
13391338
1340- explicit index_exprt (const typet &_type):exprt (ID_index, _type)
1339+ explicit index_exprt (const typet &_type):binary_exprt (ID_index, _type)
13411340 {
1342- operands ().resize (2 );
13431341 }
13441342
13451343 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())
13471345 {
1348- copy_to_operands (_array, _index);
13491346 }
13501347
13511348 index_exprt (
13521349 const exprt &_array,
13531350 const exprt &_index,
13541351 const typet &_type):
1355- exprt ( ID_index, _type)
1352+ binary_exprt (_array, ID_index, _index , _type)
13561353 {
1357- copy_to_operands (_array, _index);
13581354 }
13591355
13601356 exprt &array ()
@@ -1795,12 +1791,11 @@ class namespacet;
17951791
17961792/* ! \brief split an expression into a base object and a (byte) offset
17971793*/
1798- class object_descriptor_exprt :public exprt
1794+ class object_descriptor_exprt :public binary_exprt
17991795{
18001796public:
1801- object_descriptor_exprt ():exprt (ID_object_descriptor)
1797+ object_descriptor_exprt ():binary_exprt (ID_object_descriptor)
18021798 {
1803- operands ().resize (2 );
18041799 op0 ().id (ID_unknown);
18051800 op1 ().id (ID_unknown);
18061801 }
@@ -1886,20 +1881,18 @@ inline void validate_expr(const object_descriptor_exprt &value)
18861881
18871882/* ! \brief TO_BE_DOCUMENTED
18881883*/
1889- class dynamic_object_exprt :public exprt
1884+ class dynamic_object_exprt :public binary_exprt
18901885{
18911886public:
1892- dynamic_object_exprt ():exprt (ID_dynamic_object)
1887+ dynamic_object_exprt ():binary_exprt (ID_dynamic_object)
18931888 {
1894- operands ().resize (2 );
18951889 op0 ().id (ID_unknown);
18961890 op1 ().id (ID_unknown);
18971891 }
18981892
18991893 explicit dynamic_object_exprt (const typet &type):
1900- exprt (ID_dynamic_object, type)
1894+ binary_exprt (ID_dynamic_object, type)
19011895 {
1902- operands ().resize (2 );
19031896 op0 ().id (ID_unknown);
19041897 op1 ().id (ID_unknown);
19051898 }
@@ -1955,6 +1948,7 @@ template<> inline bool can_cast_expr<dynamic_object_exprt>(const exprt &base)
19551948{
19561949 return base.id ()==ID_dynamic_object;
19571950}
1951+
19581952inline void validate_expr (const dynamic_object_exprt &value)
19591953{
19601954 validate_operands (value, 2 , " Dynamic object must have two operands" );
@@ -1963,18 +1957,16 @@ inline void validate_expr(const dynamic_object_exprt &value)
19631957
19641958/* ! \brief semantic type conversion
19651959*/
1966- class typecast_exprt :public exprt
1960+ class typecast_exprt :public unary_exprt
19671961{
19681962public:
1969- explicit typecast_exprt (const typet &_type):exprt (ID_typecast, _type)
1963+ explicit typecast_exprt (const typet &_type):unary_exprt (ID_typecast, _type)
19701964 {
1971- operands ().resize (1 );
19721965 }
19731966
19741967 typecast_exprt (const exprt &op, const typet &_type):
1975- exprt (ID_typecast, _type)
1968+ unary_exprt (ID_typecast, op , _type)
19761969 {
1977- copy_to_operands (op);
19781970 }
19791971
19801972 exprt &op ()
@@ -3031,17 +3023,17 @@ inline void validate_expr(const address_of_exprt &value)
30313023
30323024/* ! \brief Boolean negation
30333025*/
3034- class not_exprt :public exprt
3026+ class not_exprt :public unary_exprt
30353027{
30363028public:
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()
30383031 {
3039- copy_to_operands (op);
3032+ PRECONDITION (op. type (). id ()==ID_bool );
30403033 }
30413034
3042- not_exprt ():exprt (ID_not, bool_typet())
3035+ not_exprt ():unary_exprt (ID_not, bool_typet())
30433036 {
3044- operands ().resize (1 );
30453037 }
30463038
30473039 exprt &op ()
@@ -3086,6 +3078,7 @@ template<> inline bool can_cast_expr<not_exprt>(const exprt &base)
30863078{
30873079 return base.id ()==ID_not;
30883080}
3081+
30893082inline void validate_expr (const not_exprt &value)
30903083{
30913084 validate_operands (value, 1 , " Not must have one operand" );
@@ -3094,30 +3087,27 @@ inline void validate_expr(const not_exprt &value)
30943087
30953088/* ! \brief Operator to dereference a pointer
30963089*/
3097- class dereference_exprt :public exprt
3090+ class dereference_exprt :public unary_exprt
30983091{
30993092public:
3100- explicit dereference_exprt (const typet &type):
3101- exprt(ID_dereference, type)
3093+ dereference_exprt ():unary_exprt(ID_dereference)
31023094 {
3103- operands ().resize (1 );
31043095 }
31053096
3106- explicit dereference_exprt (const exprt &op ):
3107- exprt (ID_dereference)
3097+ explicit dereference_exprt (const typet &type ):
3098+ unary_exprt (ID_dereference, type )
31083099 {
3109- copy_to_operands (op);
31103100 }
31113101
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() )
31143104 {
3115- copy_to_operands (op);
3105+ PRECONDITION (op. type (). id ()==ID_pointer );
31163106 }
31173107
3118- dereference_exprt ():exprt(ID_dereference)
3108+ dereference_exprt (const exprt &op, const typet &type):
3109+ unary_exprt (ID_dereference, op, type)
31193110 {
3120- operands ().resize (1 );
31213111 }
31223112
31233113 exprt &pointer ()
@@ -3684,39 +3674,33 @@ inline void validate_expr(const array_update_exprt &value)
36843674
36853675/* ! \brief Extract member of struct or union
36863676*/
3687- class member_exprt :public exprt
3677+ class member_exprt :public unary_exprt
36883678{
36893679public:
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)
36913682 {
3692- copy_to_operands (op);
36933683 }
36943684
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)
37023690 {
3703- copy_to_operands (op);
37043691 set_component_name (component_name);
37053692 }
37063693
37073694 member_exprt (
37083695 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())
37123698 {
3713- copy_to_operands (op);
3714- set_component_name (component_name);
3699+ set_component_name (c.get_name ());
37153700 }
37163701
3717- member_exprt ():exprt (ID_member)
3702+ member_exprt ():unary_exprt (ID_member)
37183703 {
3719- operands ().resize (1 );
37203704 }
37213705
37223706 irep_idt get_component_name () const
@@ -3734,11 +3718,6 @@ class member_exprt:public exprt
37343718 return get_size_t (ID_component_number);
37353719 }
37363720
3737- void set_component_number (std::size_t component_number)
3738- {
3739- set (ID_component_number, component_number);
3740- }
3741-
37423721 // will go away, use compound()
37433722 const exprt &struct_op () const
37443723 {
@@ -3769,6 +3748,7 @@ class member_exprt:public exprt
37693748 {
37703749 return static_cast <const member_exprt &>(op).symbol ();
37713750 }
3751+
37723752 return to_symbol_expr (op);
37733753 }
37743754};
@@ -4359,18 +4339,18 @@ class null_pointer_exprt:public constant_exprt
43594339
43604340/* ! \brief application of (mathematical) function
43614341*/
4362- class function_application_exprt :public exprt
4342+ class function_application_exprt :public binary_exprt
43634343{
43644344public:
4365- function_application_exprt ():exprt (ID_function_application)
4345+ function_application_exprt ():binary_exprt (ID_function_application)
43664346 {
4367- operands (). resize ( 2 );
4347+ op0 ()= symbol_exprt ( );
43684348 }
43694349
43704350 explicit function_application_exprt (const typet &_type):
4371- exprt (ID_function_application, _type)
4351+ binary_exprt (ID_function_application, _type)
43724352 {
4373- operands (). resize ( 2 );
4353+ op0 ()= symbol_exprt ( );
43744354 }
43754355
43764356 function_application_exprt (
@@ -4380,14 +4360,14 @@ class function_application_exprt:public exprt
43804360 function ()=_function;
43814361 }
43824362
4383- exprt &function ()
4363+ symbol_exprt &function ()
43844364 {
4385- return op0 ();
4365+ return static_cast <symbol_exprt &>( op0 () );
43864366 }
43874367
4388- const exprt &function () const
4368+ const symbol_exprt &function () const
43894369 {
4390- return op0 ();
4370+ return static_cast < const symbol_exprt &>( op0 () );
43914371 }
43924372
43934373 typedef exprt::operandst argumentst;
@@ -4612,12 +4592,11 @@ inline void validate_expr(const let_exprt &value)
46124592
46134593/* ! \brief A forall expression
46144594*/
4615- class forall_exprt :public exprt
4595+ class forall_exprt :public binary_exprt
46164596{
46174597public:
4618- forall_exprt ():exprt (ID_forall)
4598+ forall_exprt ():binary_exprt (ID_forall)
46194599 {
4620- operands ().resize (2 );
46214600 op0 ()=symbol_exprt ();
46224601 }
46234602
@@ -4644,12 +4623,11 @@ class forall_exprt:public exprt
46444623
46454624/* ! \brief An exists expression
46464625*/
4647- class exists_exprt :public exprt
4626+ class exists_exprt :public binary_exprt
46484627{
46494628public:
4650- exists_exprt ():exprt (ID_exists)
4629+ exists_exprt ():binary_exprt (ID_exists)
46514630 {
4652- operands ().resize (2 );
46534631 op0 ()=symbol_exprt ();
46544632 }
46554633
0 commit comments