Skip to content

Commit fcfca08

Browse files
Extract replace_calls_to_cprover_assume function
1 parent 0a521a4 commit fcfca08

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+16-11
Original file line numberDiff line numberDiff line change
@@ -1234,24 +1234,14 @@ codet java_bytecode_convert_methodt::convert_instructions(
12341234
results[0] = *res;
12351235
}
12361236
}
1237-
// replace calls to CProver.assume
12381237
else if(statement=="invokestatic" &&
12391238
id2string(arg0.get(ID_identifier))==
12401239
"java::org.cprover.CProver.assume:(Z)V")
12411240
{
12421241
const code_typet &code_type=to_code_type(arg0.type());
12431242
INVARIANT(code_type.parameters().size()==1,
12441243
"function expected to have exactly one parameter");
1245-
1246-
exprt operand = pop(1)[0];
1247-
// we may need to adjust the type of the argument
1248-
if(operand.type()!=bool_typet())
1249-
operand.make_typecast(bool_typet());
1250-
1251-
c=code_assumet(operand);
1252-
source_locationt loc=i_it->source_location;
1253-
loc.set_function(method_id);
1254-
c.add_source_location()=loc;
1244+
c = replace_call_to_cprover_assume(i_it->source_location, c);
12551245
}
12561246
else if(statement=="invokeinterface" ||
12571247
statement=="invokespecial" ||
@@ -2176,6 +2166,21 @@ codet java_bytecode_convert_methodt::convert_instructions(
21762166
return code;
21772167
}
21782168

2169+
codet &java_bytecode_convert_methodt::replace_call_to_cprover_assume(
2170+
source_locationt location,
2171+
codet &c)
2172+
{
2173+
exprt operand = pop(1)[0];
2174+
// we may need to adjust the type of the argument
2175+
if(operand.type() != bool_typet())
2176+
operand.make_typecast(bool_typet());
2177+
2178+
c = code_assumet(operand);
2179+
location.set_function(method_id);
2180+
c.add_source_location() = location;
2181+
return c;
2182+
}
2183+
21792184
void java_bytecode_convert_methodt::convert_checkcast(
21802185
const exprt &arg0,
21812186
const exprt::operandst &op,

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+2
Original file line numberDiff line numberDiff line change
@@ -442,5 +442,7 @@ class java_bytecode_convert_methodt:public messaget
442442
const exprt::operandst &op,
443443
codet &c,
444444
exprt::operandst &results) const;
445+
446+
codet &replace_call_to_cprover_assume(source_locationt location, codet &c);
445447
};
446448
#endif

0 commit comments

Comments
 (0)