Skip to content

Commit 0aa1c8e

Browse files
Extract convert_monitorenter function
1 parent 48dd97f commit 0aa1c8e

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
@@ -1929,17 +1929,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
19291929
}
19301930
else if(statement=="monitorenter")
19311931
{
1932-
// becomes a function call
1933-
code_typet type;
1934-
type.return_type()=void_typet();
1935-
type.parameters().resize(1);
1936-
type.parameters()[0].type()=java_reference_type(void_typet());
1937-
code_function_callt call;
1938-
call.function()=symbol_exprt("java::monitorenter", type);
1939-
call.lhs().make_nil();
1940-
call.arguments().push_back(op[0]);
1941-
call.add_source_location()=i_it->source_location;
1942-
c=call;
1932+
c = convert_monitorenter(i_it->source_location, op);
19431933
}
19441934
else if(statement=="monitorexit")
19451935
{
@@ -2310,6 +2300,22 @@ codet java_bytecode_convert_methodt::convert_instructions(
23102300
return code;
23112301
}
23122302

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

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+4
Original file line numberDiff line numberDiff line change
@@ -416,5 +416,9 @@ class java_bytecode_convert_methodt:public messaget
416416
const exprt::operandst &op,
417417
codet &c,
418418
exprt::operandst &results);
419+
420+
codet convert_monitorenter(
421+
const source_locationt &location,
422+
const exprt::operandst &op) const;
419423
};
420424
#endif

0 commit comments

Comments
 (0)