Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions src/java_bytecode/expr2java.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,15 @@ std::string expr2javat::convert_constant(
const constant_exprt &src,
unsigned &precedence)
{
if(src.type().id()==ID_bool)
if(src.type().id()==ID_c_bool)
{
if(!src.is_zero())
return "true";
else
return "false";
}
else if(src.type().id()==ID_bool)
{
// Java has built-in Boolean constants, in contrast to C
if(src.is_true())
return "true";
else if(src.is_false())
Expand Down Expand Up @@ -482,7 +488,6 @@ std::string expr2javat::convert(
const exprt &src,
unsigned &precedence)
{
const typet &type=ns.follow(src.type());
if(src.id()=="java-this")
return convert_java_this(src, precedence=15);
if(src.id()==ID_java_instanceof)
Expand All @@ -494,8 +499,6 @@ std::string expr2javat::convert(
else if(src.id()==ID_side_effect &&
src.get(ID_statement)==ID_throw)
return convert_function(src, "throw", precedence=16);
else if(src.is_constant() && to_constant_expr(src).get_value()==ID_nullptr)
return "nullptr";
else if(src.id()==ID_unassigned)
return "?";
else if(src.id()=="pod_constructor")
Expand All @@ -510,13 +513,8 @@ std::string expr2javat::convert(
}
else if(src.id()==ID_java_string_literal)
return '"'+MetaString(src.get_string(ID_value))+'"';
else if(src.id()==ID_constant && (type.id()==ID_bool || type.id()==ID_c_bool))
{
if(src.is_true())
return "true";
else
return "false";
}
else if(src.id()==ID_constant)
return convert_constant(to_constant_expr(src), precedence=16);
else
return expr2ct::convert(src, precedence);
}
Expand Down