Skip to content

Commit f1edff9

Browse files
Extract convert_getstatic function
1 parent 68bddf1 commit f1edff9

File tree

2 files changed

+52
-34
lines changed

2 files changed

+52
-34
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,40 +1788,8 @@ codet java_bytecode_convert_methodt::convert_instructions(
17881788
symbol_table.has_symbol(symbol_expr.get_identifier()),
17891789
"getstatic symbol should have been created before method conversion");
17901790

1791-
if(needed_lazy_methods)
1792-
{
1793-
if(arg0.type().id()==ID_symbol)
1794-
{
1795-
needed_lazy_methods->add_needed_class(
1796-
to_symbol_type(arg0.type()).get_identifier());
1797-
}
1798-
else if(arg0.type().id()==ID_pointer)
1799-
{
1800-
const auto &pointer_type=to_pointer_type(arg0.type());
1801-
if(pointer_type.subtype().id()==ID_symbol)
1802-
{
1803-
needed_lazy_methods->add_needed_class(
1804-
to_symbol_type(pointer_type.subtype()).get_identifier());
1805-
}
1806-
}
1807-
else if(is_assertions_disabled_field)
1808-
{
1809-
needed_lazy_methods->add_needed_class(arg0.get_string(ID_class));
1810-
}
1811-
}
1812-
results[0]=java_bytecode_promotion(symbol_expr);
1813-
1814-
// Note this initializer call deliberately inits the class used to make
1815-
// the reference, which may be a child of the class that actually defines
1816-
// the field.
1817-
codet clinit_call=get_clinit_call(arg0.get_string(ID_class));
1818-
if(clinit_call.get_statement()!=ID_skip)
1819-
c=clinit_call;
1820-
else if(is_assertions_disabled_field)
1821-
{
1822-
// set $assertionDisabled to false
1823-
c=code_assignt(symbol_expr, false_exprt());
1824-
}
1791+
convert_getstatic(
1792+
arg0, symbol_expr, is_assertions_disabled_field, c, results);
18251793
}
18261794
else if(statement=="putfield")
18271795
{
@@ -2465,6 +2433,49 @@ codet java_bytecode_convert_methodt::convert_instructions(
24652433
return code;
24662434
}
24672435

2436+
void java_bytecode_convert_methodt::convert_getstatic(
2437+
exprt &arg0,
2438+
const symbol_exprt &symbol_expr,
2439+
const bool is_assertions_disabled_field,
2440+
codet &c,
2441+
exprt::operandst &results)
2442+
{
2443+
if(needed_lazy_methods)
2444+
{
2445+
if(arg0.type().id() == ID_symbol)
2446+
{
2447+
needed_lazy_methods->add_needed_class(
2448+
to_symbol_type(arg0.type()).get_identifier());
2449+
}
2450+
else if(arg0.type().id() == ID_pointer)
2451+
{
2452+
const auto &pointer_type = to_pointer_type(arg0.type());
2453+
if(pointer_type.subtype().id() == ID_symbol)
2454+
{
2455+
needed_lazy_methods->add_needed_class(
2456+
to_symbol_type(pointer_type.subtype()).get_identifier());
2457+
}
2458+
}
2459+
else if(is_assertions_disabled_field)
2460+
{
2461+
needed_lazy_methods->add_needed_class(arg0.get_string(ID_class));
2462+
}
2463+
}
2464+
results[0] = java_bytecode_promotion(symbol_expr);
2465+
2466+
// Note this initializer call deliberately inits the class used to make
2467+
// the reference, which may be a child of the class that actually defines
2468+
// the field.
2469+
codet clinit_call = get_clinit_call(arg0.get_string(ID_class));
2470+
if(clinit_call.get_statement() != ID_skip)
2471+
c = clinit_call;
2472+
else if(is_assertions_disabled_field)
2473+
{
2474+
// set $assertionDisabled to false
2475+
c = code_assignt(symbol_expr, false_exprt());
2476+
}
2477+
}
2478+
24682479
exprt::operandst &java_bytecode_convert_methodt::convert_cmp2(
24692480
const irep_idt &statement,
24702481
const exprt::operandst &op,

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,5 +380,12 @@ class java_bytecode_convert_methodt:public messaget
380380
const irep_idt &statement,
381381
const exprt::operandst &op,
382382
exprt::operandst &results) const;
383+
384+
void convert_getstatic(
385+
const exprt &arg0,
386+
const symbol_exprt &symbol_expr,
387+
bool is_assertions_disabled_field,
388+
codet &c,
389+
exprt::operandst &results);
383390
};
384391
#endif

0 commit comments

Comments
 (0)