Skip to content

Commit 21e37a8

Browse files
Extract convert_monitorexit function
1 parent a7bbf53 commit 21e37a8

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+17-11
Original file line numberDiff line numberDiff line change
@@ -1933,17 +1933,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
19331933
}
19341934
else if(statement=="monitorexit")
19351935
{
1936-
// becomes a function call
1937-
code_typet type;
1938-
type.return_type()=void_typet();
1939-
type.parameters().resize(1);
1940-
type.parameters()[0].type()=java_reference_type(void_typet());
1941-
code_function_callt call;
1942-
call.function()=symbol_exprt("java::monitorexit", type);
1943-
call.lhs().make_nil();
1944-
call.arguments().push_back(op[0]);
1945-
call.add_source_location()=i_it->source_location;
1946-
c=call;
1936+
c = convert_monitorexit(i_it->source_location, op);
19471937
}
19481938
else if(statement=="swap")
19491939
{
@@ -2309,6 +2299,22 @@ codet &java_bytecode_convert_methodt::do_exception_handling(
23092299
return c;
23102300
}
23112301

2302+
codet java_bytecode_convert_methodt::convert_monitorexit(
2303+
const source_locationt &location,
2304+
const exprt::operandst &op) const
2305+
{
2306+
code_typet type;
2307+
type.return_type() = void_typet();
2308+
type.parameters().resize(1);
2309+
type.parameters()[0].type() = java_reference_type(void_typet());
2310+
code_function_callt call;
2311+
call.function() = symbol_exprt("java::monitorexit", type);
2312+
call.lhs().make_nil();
2313+
call.arguments().push_back(op[0]);
2314+
call.add_source_location() = location;
2315+
return call;
2316+
}
2317+
23122318
codet java_bytecode_convert_methodt::convert_monitorenter(
23132319
const source_locationt &location,
23142320
const exprt::operandst &op) const

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+4
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,10 @@ class java_bytecode_convert_methodt:public messaget
421421
const source_locationt &location,
422422
const exprt::operandst &op) const;
423423

424+
codet convert_monitorexit(
425+
const source_locationt &location,
426+
const exprt::operandst &op) const;
427+
424428
codet &do_exception_handling(
425429
const methodt &method,
426430
const std::set<unsigned int> &working_set,

0 commit comments

Comments
 (0)