Skip to content

Commit 9bcd5f0

Browse files
Extract convert_pop function
1 parent 096e83e commit 9bcd5f0

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/java_bytecode/java_bytecode_convert_method.cpp

+17-10
Original file line numberDiff line numberDiff line change
@@ -1592,16 +1592,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
15921592
}
15931593
else if(statement=="pop" || statement=="pop2")
15941594
{
1595-
// these are skips
1596-
c=code_skipt();
1597-
1598-
// pop2 removes two single-word items from the stack (e.g. two
1599-
// integers, or an integer and an object reference) or one
1600-
// two-word item (i.e. a double or a long).
1601-
// http://cs.au.dk/~mis/dOvs/jvmspec/ref-pop2.html
1602-
if(statement=="pop2" &&
1603-
get_bytecode_type_width(op[0].type())==32)
1604-
pop(1);
1595+
c = convert_pop(statement, op);
16051596
}
16061597
else if(statement=="instanceof")
16071598
{
@@ -1871,6 +1862,22 @@ codet java_bytecode_convert_methodt::convert_instructions(
18711862
return code;
18721863
}
18731864

1865+
codet java_bytecode_convert_methodt::convert_pop(
1866+
const irep_idt &statement,
1867+
const exprt::operandst &op)
1868+
{
1869+
// these are skips
1870+
codet c = code_skipt();
1871+
1872+
// pop2 removes two single-word items from the stack (e.g. two
1873+
// integers, or an integer and an object reference) or one
1874+
// two-word item (i.e. a double or a long).
1875+
// http://cs.au.dk/~mis/dOvs/jvmspec/ref-pop2.html
1876+
if(statement == "pop2" && get_bytecode_type_width(op[0].type()) == 32)
1877+
pop(1);
1878+
return c;
1879+
}
1880+
18741881
codet java_bytecode_convert_methodt::convert_switch(
18751882
java_bytecode_convert_methodt::address_mapt &address_map,
18761883
const std::vector<java_bytecode_parse_treet::instructiont>::const_iterator

src/java_bytecode/java_bytecode_convert_method_class.h

+2
Original file line numberDiff line numberDiff line change
@@ -466,5 +466,7 @@ class java_bytecode_convert_methodt:public messaget
466466
const std::vector<java_bytecode_parse_treet::instructiont>::const_iterator
467467
&i_it,
468468
const exprt::operandst &op);
469+
470+
codet convert_pop(const irep_idt &statement, const exprt::operandst &op);
469471
};
470472
#endif

0 commit comments

Comments
 (0)