Skip to content

Commit 55580d2

Browse files
Extract convert_pop function
1 parent db3345f commit 55580d2

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -1601,16 +1601,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
16011601
}
16021602
else if(statement=="pop" || statement=="pop2")
16031603
{
1604-
// these are skips
1605-
c=code_skipt();
1606-
1607-
// pop2 removes two single-word items from the stack (e.g. two
1608-
// integers, or an integer and an object reference) or one
1609-
// two-word item (i.e. a double or a long).
1610-
// http://cs.au.dk/~mis/dOvs/jvmspec/ref-pop2.html
1611-
if(statement=="pop2" &&
1612-
get_bytecode_type_width(op[0].type())==32)
1613-
pop(1);
1604+
c = convert_pop(statement, op);
16141605
}
16151606
else if(statement=="instanceof")
16161607
{
@@ -1880,6 +1871,22 @@ codet java_bytecode_convert_methodt::convert_instructions(
18801871
return code;
18811872
}
18821873

1874+
codet java_bytecode_convert_methodt::convert_pop(
1875+
const irep_idt &statement,
1876+
const exprt::operandst &op)
1877+
{
1878+
// these are skips
1879+
codet c = code_skipt();
1880+
1881+
// pop2 removes two single-word items from the stack (e.g. two
1882+
// integers, or an integer and an object reference) or one
1883+
// two-word item (i.e. a double or a long).
1884+
// http://cs.au.dk/~mis/dOvs/jvmspec/ref-pop2.html
1885+
if(statement == "pop2" && get_bytecode_type_width(op[0].type()) == 32)
1886+
pop(1);
1887+
return c;
1888+
}
1889+
18831890
codet java_bytecode_convert_methodt::convert_switch(
18841891
java_bytecode_convert_methodt::address_mapt &address_map,
18851892
const std::vector<java_bytecode_parse_treet::instructiont>::const_iterator

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+2
Original file line numberDiff line numberDiff line change
@@ -481,5 +481,7 @@ class java_bytecode_convert_methodt:public messaget
481481
const std::vector<java_bytecode_parse_treet::instructiont>::const_iterator
482482
&i_it,
483483
const exprt::operandst &op);
484+
485+
codet convert_pop(const irep_idt &statement, const exprt::operandst &op);
484486
};
485487
#endif

0 commit comments

Comments
 (0)