Skip to content

Commit f8d00f6

Browse files
Extract convert_new function
1 parent b846798 commit f8d00f6

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+28-19
Original file line numberDiff line numberDiff line change
@@ -1822,25 +1822,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
18221822
{
18231823
// use temporary since the stack symbol might get duplicated
18241824
PRECONDITION(op.empty() && results.size() == 1);
1825-
const reference_typet ref_type=java_reference_type(arg0.type());
1826-
side_effect_exprt java_new_expr(ID_java_new, ref_type);
1827-
1828-
if(!i_it->source_location.get_line().empty())
1829-
java_new_expr.add_source_location()=i_it->source_location;
1830-
1831-
const exprt tmp=tmp_variable("new", ref_type);
1832-
c=code_assignt(tmp, java_new_expr);
1833-
c.add_source_location()=i_it->source_location;
1834-
codet clinit_call=
1835-
get_clinit_call(to_symbol_type(arg0.type()).get_identifier());
1836-
if(clinit_call.get_statement()!=ID_skip)
1837-
{
1838-
code_blockt ret_block;
1839-
ret_block.move_to_operands(clinit_call);
1840-
ret_block.move_to_operands(c);
1841-
c=std::move(ret_block);
1842-
}
1843-
results[0]=tmp;
1825+
convert_new(i_it, arg0, c, results);
18441826
}
18451827
else if(statement=="newarray" ||
18461828
statement=="anewarray")
@@ -2402,6 +2384,33 @@ codet java_bytecode_convert_methodt::convert_instructions(
24022384
return code;
24032385
}
24042386

2387+
void java_bytecode_convert_methodt::convert_new(
2388+
const source_locationt &location,
2389+
const exprt &arg0,
2390+
codet &c,
2391+
exprt::operandst &results)
2392+
{
2393+
const reference_typet ref_type = java_reference_type(arg0.type());
2394+
side_effect_exprt java_new_expr(ID_java_new, ref_type);
2395+
2396+
if(!location.get_line().empty())
2397+
java_new_expr.add_source_location() = location;
2398+
2399+
const exprt tmp = tmp_variable("new", ref_type);
2400+
c = code_assignt(tmp, java_new_expr);
2401+
c.add_source_location() = location;
2402+
codet clinit_call =
2403+
get_clinit_call(to_symbol_type(arg0.type()).get_identifier());
2404+
if(clinit_call.get_statement() != ID_skip)
2405+
{
2406+
code_blockt ret_block;
2407+
ret_block.move_to_operands(clinit_call);
2408+
ret_block.move_to_operands(c);
2409+
c = std::move(ret_block);
2410+
}
2411+
results[0] = tmp;
2412+
}
2413+
24052414
codet java_bytecode_convert_methodt::convert_putstatic(
24062415
const source_locationt &location,
24072416
const exprt &arg0,

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+6
Original file line numberDiff line numberDiff line change
@@ -395,5 +395,11 @@ class java_bytecode_convert_methodt:public messaget
395395
const exprt &arg0,
396396
const exprt::operandst &op,
397397
const symbol_exprt &symbol_expr);
398+
399+
void convert_new(
400+
const source_locationt &location,
401+
const exprt &arg0,
402+
codet &c,
403+
exprt::operandst &results);
398404
};
399405
#endif

0 commit comments

Comments
 (0)