Skip to content

Commit c59e846

Browse files
Document convert_digit_char and make precondition more precise
1 parent e525d5b commit c59e846

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/java_bytecode/character_refine_preprocess.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,19 +126,22 @@ codet character_refine_preprocesst::convert_compare(conversion_inputt &target)
126126

127127

128128
/// Converts function call to an assignment of an expression corresponding to
129-
/// the java method Character.digit:(CI)I
129+
/// the java method Character.digit:(CI)I. The function call has one character
130+
/// argument and an optional integer radix argument. If the radix is not given
131+
/// it is set to 36 by default.
130132
/// \param target: a position in a goto program
133+
/// \return code assigning the result of the Character.digit function to the
134+
/// left-hand-side of the given target
131135
codet character_refine_preprocesst::convert_digit_char(
132136
conversion_inputt &target)
133137
{
134138
const code_function_callt &function_call=target;
135-
PRECONDITION(function_call.arguments().size()>=1);
139+
const std::size_t nb_args=function_call.arguments().size();
140+
PRECONDITION(nb_args==1 || nb_args==2);
136141
const exprt &arg=function_call.arguments()[0];
137142
// If there is no radix argument we set it to 36 which is the maximum possible
138143
const exprt &radix=
139-
function_call.arguments().size()>1?
140-
function_call.arguments()[1]:
141-
from_integer(36, arg.type());
144+
nb_args>1?function_call.arguments()[1]:from_integer(36, arg.type());
142145
const exprt &result=function_call.lhs();
143146
const typet &type=result.type();
144147

0 commit comments

Comments
 (0)