@@ -195,9 +195,15 @@ std::string expr2javat::convert_constant(
195
195
const constant_exprt &src,
196
196
unsigned &precedence)
197
197
{
198
- if (src.type ().id ()==ID_bool)
198
+ if (src.type ().id ()==ID_c_bool)
199
+ {
200
+ if (!src.is_zero ())
201
+ return " true" ;
202
+ else
203
+ return " false" ;
204
+ }
205
+ else if (src.type ().id ()==ID_bool)
199
206
{
200
- // Java has built-in Boolean constants, in contrast to C
201
207
if (src.is_true ())
202
208
return " true" ;
203
209
else if (src.is_false ())
@@ -482,7 +488,6 @@ std::string expr2javat::convert(
482
488
const exprt &src,
483
489
unsigned &precedence)
484
490
{
485
- const typet &type=ns.follow (src.type ());
486
491
if (src.id ()==" java-this" )
487
492
return convert_java_this (src, precedence=15 );
488
493
if (src.id ()==ID_java_instanceof)
@@ -494,8 +499,6 @@ std::string expr2javat::convert(
494
499
else if (src.id ()==ID_side_effect &&
495
500
src.get (ID_statement)==ID_throw)
496
501
return convert_function (src, " throw" , precedence=16 );
497
- else if (src.is_constant () && to_constant_expr (src).get_value ()==ID_nullptr)
498
- return " nullptr" ;
499
502
else if (src.id ()==ID_unassigned)
500
503
return " ?" ;
501
504
else if (src.id ()==" pod_constructor" )
@@ -510,13 +513,8 @@ std::string expr2javat::convert(
510
513
}
511
514
else if (src.id ()==ID_java_string_literal)
512
515
return ' "' +MetaString (src.get_string (ID_value))+' "' ;
513
- else if (src.id ()==ID_constant && (type.id ()==ID_bool || type.id ()==ID_c_bool))
514
- {
515
- if (src.is_true ())
516
- return " true" ;
517
- else
518
- return " false" ;
519
- }
516
+ else if (src.id ()==ID_constant)
517
+ return convert_constant (to_constant_expr (src), precedence=16 );
520
518
else
521
519
return expr2ct::convert (src, precedence);
522
520
}
0 commit comments