Skip to content

Commit f53351d

Browse files
author
kroening
committed
added forall_exprt, exists_exprt, let_exprt; union_exprt is now a unary_exprt
git-svn-id: svn+ssh://svn.cprover.org/srv/svn/cbmc/trunk@3249 6afb6bc1-c8e4-404c-8f48-9ae832c5b171
1 parent 989dca8 commit f53351d

File tree

1 file changed

+192
-16
lines changed

1 file changed

+192
-16
lines changed

src/util/std_expr.h

Lines changed: 192 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class unary_exprt:public exprt
151151
operands().resize(1);
152152
}
153153

154-
inline explicit unary_exprt(const irep_idt &id):exprt(id)
154+
inline explicit unary_exprt(const irep_idt &_id):exprt(_id)
155155
{
156156
operands().resize(1);
157157
}
@@ -164,6 +164,13 @@ class unary_exprt:public exprt
164164
copy_to_operands(_op);
165165
}
166166

167+
inline unary_exprt(
168+
const irep_idt &_id,
169+
const typet &_type):exprt(_id, _type)
170+
{
171+
operands().resize(1);
172+
}
173+
167174
inline unary_exprt(
168175
const irep_idt &_id,
169176
const exprt &_op,
@@ -172,6 +179,16 @@ class unary_exprt:public exprt
172179
{
173180
copy_to_operands(_op);
174181
}
182+
183+
inline const exprt &op() const
184+
{
185+
return op0();
186+
}
187+
188+
inline exprt &op()
189+
{
190+
return op0();
191+
}
175192
};
176193

177194
/*! \brief absolute value
@@ -977,18 +994,16 @@ vector_exprt &to_vector_expr(exprt &expr);
977994

978995
/*! \brief union constructor from single element
979996
*/
980-
class union_exprt:public exprt
997+
class union_exprt:public unary_exprt
981998
{
982999
public:
983-
inline union_exprt():exprt(ID_union)
1000+
inline union_exprt():unary_exprt(ID_union)
9841001
{
985-
operands().resize(1);
9861002
}
9871003

9881004
explicit inline union_exprt(const typet &_type):
989-
exprt(ID_union, _type)
1005+
unary_exprt(ID_union, _type)
9901006
{
991-
operands().resize(1);
9921007
}
9931008

9941009
friend inline const union_exprt &to_union_expr(const exprt &expr)
@@ -1022,16 +1037,6 @@ class union_exprt:public exprt
10221037
{
10231038
set(ID_component_number, component_number);
10241039
}
1025-
1026-
inline const exprt &op() const
1027-
{
1028-
return op0();
1029-
}
1030-
1031-
inline exprt &op()
1032-
{
1033-
return op0();
1034-
}
10351040
};
10361041

10371042
/*! \brief Cast a generic exprt to a \ref union_exprt
@@ -2561,6 +2566,71 @@ class ieee_float_equal_exprt:public binary_relation_exprt
25612566
}
25622567
};
25632568

2569+
/*! \brief Cast a generic exprt to an \ref ieee_float_equal_exprt
2570+
*
2571+
* This is an unchecked conversion. \a expr must be known to be \ref
2572+
* ieee_float_equal_exprt.
2573+
*
2574+
* \param expr Source expression
2575+
* \return Object of type \ref ieee_float_equal_exprt
2576+
*
2577+
* \ingroup gr_std_expr
2578+
*/
2579+
extern inline const ieee_float_equal_exprt &to_ieee_float_equal_expr(const exprt &expr)
2580+
{
2581+
assert(expr.id()==ID_ieee_float_equal && expr.operands().size()==2);
2582+
return static_cast<const ieee_float_equal_exprt &>(expr);
2583+
}
2584+
2585+
/*! \copydoc to_ieee_float_equal_expr(const exprt &)
2586+
* \ingroup gr_std_expr
2587+
*/
2588+
extern inline ieee_float_equal_exprt &to_ieee_float_equal_expr(exprt &expr)
2589+
{
2590+
assert(expr.id()==ID_ieee_float_equal && expr.operands().size()==2);
2591+
return static_cast<ieee_float_equal_exprt &>(expr);
2592+
}
2593+
2594+
/*! \brief IEEE-floating-point disequality
2595+
*/
2596+
class ieee_float_notequal_exprt:public binary_relation_exprt
2597+
{
2598+
public:
2599+
inline ieee_float_notequal_exprt():binary_relation_exprt(ID_ieee_float_notequal)
2600+
{
2601+
}
2602+
2603+
inline ieee_float_notequal_exprt(const exprt &_lhs, const exprt &_rhs):
2604+
binary_relation_exprt(_lhs, ID_ieee_float_notequal, _rhs)
2605+
{
2606+
}
2607+
};
2608+
2609+
/*! \brief Cast a generic exprt to an \ref ieee_float_notequal_exprt
2610+
*
2611+
* This is an unchecked conversion. \a expr must be known to be \ref
2612+
* ieee_float_notequal_exprt.
2613+
*
2614+
* \param expr Source expression
2615+
* \return Object of type \ref ieee_float_notequal_exprt
2616+
*
2617+
* \ingroup gr_std_expr
2618+
*/
2619+
extern inline const ieee_float_notequal_exprt &to_ieee_float_notequal_expr(const exprt &expr)
2620+
{
2621+
assert(expr.id()==ID_ieee_float_notequal && expr.operands().size()==2);
2622+
return static_cast<const ieee_float_notequal_exprt &>(expr);
2623+
}
2624+
2625+
/*! \copydoc to_ieee_float_notequal_expr(const exprt &)
2626+
* \ingroup gr_std_expr
2627+
*/
2628+
extern inline ieee_float_notequal_exprt &to_ieee_float_notequal_expr(exprt &expr)
2629+
{
2630+
assert(expr.id()==ID_ieee_float_notequal && expr.operands().size()==2);
2631+
return static_cast<ieee_float_notequal_exprt &>(expr);
2632+
}
2633+
25642634
/*! \brief An expression denoting a type
25652635
*/
25662636
class type_exprt:public exprt
@@ -2808,6 +2878,112 @@ class infinity_exprt:public exprt
28082878
}
28092879
};
28102880

2881+
/*! \brief A let expression
2882+
*/
2883+
class let_exprt:public exprt
2884+
{
2885+
public:
2886+
inline let_exprt():exprt(ID_let)
2887+
{
2888+
operands().resize(3);
2889+
op0()=symbol_exprt();
2890+
}
2891+
2892+
symbol_exprt &symbol()
2893+
{
2894+
return static_cast<symbol_exprt &>(op0());
2895+
}
2896+
2897+
const symbol_exprt &symbol() const
2898+
{
2899+
return static_cast<const symbol_exprt &>(op0());
2900+
}
2901+
2902+
exprt &value()
2903+
{
2904+
return op1();
2905+
}
2906+
2907+
const exprt &value() const
2908+
{
2909+
return op1();
2910+
}
2911+
2912+
exprt &where()
2913+
{
2914+
return op2();
2915+
}
2916+
2917+
const exprt &where() const
2918+
{
2919+
return op2();
2920+
}
2921+
};
2922+
2923+
/*! \brief A forall expression
2924+
*/
2925+
class forall_exprt:public exprt
2926+
{
2927+
public:
2928+
inline forall_exprt():exprt(ID_forall)
2929+
{
2930+
operands().resize(2);
2931+
op0()=symbol_exprt();
2932+
}
2933+
2934+
symbol_exprt &symbol()
2935+
{
2936+
return static_cast<symbol_exprt &>(op0());
2937+
}
2938+
2939+
const symbol_exprt &symbol() const
2940+
{
2941+
return static_cast<const symbol_exprt &>(op0());
2942+
}
2943+
2944+
exprt &where()
2945+
{
2946+
return op1();
2947+
}
2948+
2949+
const exprt &where() const
2950+
{
2951+
return op1();
2952+
}
2953+
};
2954+
2955+
/*! \brief An exists expression
2956+
*/
2957+
class exists_exprt:public exprt
2958+
{
2959+
public:
2960+
inline exists_exprt():exprt(ID_exists)
2961+
{
2962+
operands().resize(2);
2963+
op0()=symbol_exprt();
2964+
}
2965+
2966+
symbol_exprt &symbol()
2967+
{
2968+
return static_cast<symbol_exprt &>(op0());
2969+
}
2970+
2971+
const symbol_exprt &symbol() const
2972+
{
2973+
return static_cast<const symbol_exprt &>(op0());
2974+
}
2975+
2976+
exprt &where()
2977+
{
2978+
return op1();
2979+
}
2980+
2981+
const exprt &where() const
2982+
{
2983+
return op1();
2984+
}
2985+
};
2986+
28112987
/*! \brief Expression providing an SSA-renamed symbol of expressions
28122988
*/
28132989
class ssa_exprt:public symbol_exprt

0 commit comments

Comments
 (0)