Skip to content

Commit b846798

Browse files
Extract convert_putstatic function
1 parent 27af4a2 commit b846798

File tree

2 files changed

+39
-24
lines changed

2 files changed

+39
-24
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+33-24
Original file line numberDiff line numberDiff line change
@@ -1808,30 +1808,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
18081808
symbol_table.has_symbol(symbol_expr.get_identifier()),
18091809
"putstatic symbol should have been created before method conversion");
18101810

1811-
if(needed_lazy_methods && arg0.type().id() == ID_symbol)
1812-
{
1813-
needed_lazy_methods->add_needed_class(
1814-
to_symbol_type(arg0.type()).get_identifier());
1815-
}
1816-
1817-
code_blockt block;
1818-
block.add_source_location()=i_it->source_location;
1819-
1820-
// Note this initializer call deliberately inits the class used to make
1821-
// the reference, which may be a child of the class that actually defines
1822-
// the field.
1823-
codet clinit_call=get_clinit_call(arg0.get_string(ID_class));
1824-
if(clinit_call.get_statement()!=ID_skip)
1825-
block.move_to_operands(clinit_call);
1826-
1827-
save_stack_entries(
1828-
"stack_static_field",
1829-
symbol_expr.type(),
1830-
block,
1831-
bytecode_write_typet::STATIC_FIELD,
1832-
symbol_expr.get_identifier());
1833-
block.copy_to_operands(code_assignt(symbol_expr, op[0]));
1834-
c=block;
1811+
c = convert_putstatic(i_it->source_location, arg0, op, symbol_expr);
18351812
}
18361813
else if(statement==patternt("?2?")) // i2c etc.
18371814
{
@@ -2425,6 +2402,38 @@ codet java_bytecode_convert_methodt::convert_instructions(
24252402
return code;
24262403
}
24272404

2405+
codet java_bytecode_convert_methodt::convert_putstatic(
2406+
const source_locationt &location,
2407+
const exprt &arg0,
2408+
const exprt::operandst &op,
2409+
const symbol_exprt &symbol_expr)
2410+
{
2411+
if(needed_lazy_methods && arg0.type().id() == ID_symbol)
2412+
{
2413+
needed_lazy_methods->add_needed_class(
2414+
to_symbol_type(arg0.type()).get_identifier());
2415+
}
2416+
2417+
code_blockt block;
2418+
block.add_source_location() = location;
2419+
2420+
// Note this initializer call deliberately inits the class used to make
2421+
// the reference, which may be a child of the class that actually defines
2422+
// the field.
2423+
codet clinit_call = get_clinit_call(arg0.get_string(ID_class));
2424+
if(clinit_call.get_statement() != ID_skip)
2425+
block.move_to_operands(clinit_call);
2426+
2427+
save_stack_entries(
2428+
"stack_static_field",
2429+
symbol_expr.type(),
2430+
block,
2431+
bytecode_write_typet::STATIC_FIELD,
2432+
symbol_expr.get_identifier());
2433+
block.copy_to_operands(code_assignt(symbol_expr, op[0]));
2434+
return block;
2435+
}
2436+
24282437
codet java_bytecode_convert_methodt::convert_putfield(
24292438
const exprt &arg0,
24302439
const exprt::operandst &op)

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+6
Original file line numberDiff line numberDiff line change
@@ -389,5 +389,11 @@ class java_bytecode_convert_methodt:public messaget
389389
exprt::operandst &results);
390390

391391
codet convert_putfield(const exprt &arg0, const exprt::operandst &op);
392+
393+
codet convert_putstatic(
394+
const source_locationt &location,
395+
const exprt &arg0,
396+
const exprt::operandst &op,
397+
const symbol_exprt &symbol_expr);
392398
};
393399
#endif

0 commit comments

Comments
 (0)