File tree Expand file tree Collapse file tree 2 files changed +25
-10
lines changed Expand file tree Collapse file tree 2 files changed +25
-10
lines changed Original file line number Diff line number Diff line change @@ -2216,11 +2216,7 @@ std::string expr2ct::convert_constant(
2216
2216
}
2217
2217
else if (type.id ()==ID_bool)
2218
2218
{
2219
- // C doesn't really have these
2220
- if (src.is_true ())
2221
- dest=" TRUE" ;
2222
- else
2223
- dest=" FALSE" ;
2219
+ dest = convert_constant_bool (src.is_true ());
2224
2220
}
2225
2221
else if (type.id ()==ID_unsignedbv ||
2226
2222
type.id ()==ID_signedbv ||
@@ -2236,11 +2232,7 @@ std::string expr2ct::convert_constant(
2236
2232
2237
2233
if (type.id ()==ID_c_bool)
2238
2234
{
2239
- // C doesn't really have these
2240
- if (int_value!=0 )
2241
- dest=" TRUE" ;
2242
- else
2243
- dest=" FALSE" ;
2235
+ dest = convert_constant_bool (int_value != 0 );
2244
2236
}
2245
2237
else if (type==char_type () && type!=signed_int_type () && type!=unsigned_int_type ())
2246
2238
{
@@ -2393,6 +2385,28 @@ std::string expr2ct::convert_constant(
2393
2385
2394
2386
/* ******************************************************************\
2395
2387
2388
+ Function: expr2ct::convert_constant_bool
2389
+
2390
+ Inputs:
2391
+ boolean_value - The value of the constant bool expression
2392
+
2393
+ Outputs: Returns a C-like representation of the boolean value,
2394
+ e.g. TRUE or FALSE.
2395
+
2396
+ Purpose: To get the C-like representation of a given boolean value.
2397
+
2398
+ \*******************************************************************/
2399
+ std::string expr2ct::convert_constant_bool (bool boolean_value)
2400
+ {
2401
+ // C doesn't really have these
2402
+ if (boolean_value)
2403
+ return " TRUE" ;
2404
+ else
2405
+ return " FALSE" ;
2406
+ }
2407
+
2408
+ /* ******************************************************************\
2409
+
2396
2410
Function: expr2ct::convert_struct
2397
2411
2398
2412
Inputs:
Original file line number Diff line number Diff line change @@ -209,6 +209,7 @@ class expr2ct
209
209
std::string convert_object_descriptor (const exprt &src, unsigned &precedence);
210
210
std::string convert_literal (const exprt &src, unsigned &precedence);
211
211
virtual std::string convert_constant (const constant_exprt &src, unsigned &precedence);
212
+ virtual std::string convert_constant_bool (bool boolean_value);
212
213
213
214
std::string convert_norep (const exprt &src, unsigned &precedence);
214
215
You can’t perform that action at this time.
0 commit comments