Skip to content

Commit 67081d5

Browse files
Extract convert_pop function
1 parent cd98a1f commit 67081d5

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
@@ -1622,16 +1622,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
16221622
}
16231623
else if(statement=="pop" || statement=="pop2")
16241624
{
1625-
// these are skips
1626-
c=code_skipt();
1627-
1628-
// pop2 removes two single-word items from the stack (e.g. two
1629-
// integers, or an integer and an object reference) or one
1630-
// two-word item (i.e. a double or a long).
1631-
// http://cs.au.dk/~mis/dOvs/jvmspec/ref-pop2.html
1632-
if(statement=="pop2" &&
1633-
get_bytecode_type_width(op[0].type())==32)
1634-
pop(1);
1625+
c = convert_pop(statement, op);
16351626
}
16361627
else if(statement=="instanceof")
16371628
{
@@ -1901,6 +1892,22 @@ codet java_bytecode_convert_methodt::convert_instructions(
19011892
return code;
19021893
}
19031894

1895+
codet java_bytecode_convert_methodt::convert_pop(
1896+
const irep_idt &statement,
1897+
const exprt::operandst &op)
1898+
{
1899+
// these are skips
1900+
codet c = code_skipt();
1901+
1902+
// pop2 removes two single-word items from the stack (e.g. two
1903+
// integers, or an integer and an object reference) or one
1904+
// two-word item (i.e. a double or a long).
1905+
// http://cs.au.dk/~mis/dOvs/jvmspec/ref-pop2.html
1906+
if(statement == "pop2" && get_bytecode_type_width(op[0].type()) == 32)
1907+
pop(1);
1908+
return c;
1909+
}
1910+
19041911
codet java_bytecode_convert_methodt::convert_switch(
19051912
java_bytecode_convert_methodt::address_mapt &address_map,
19061913
const exprt::operandst &op,

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+2
Original file line numberDiff line numberDiff line change
@@ -468,5 +468,7 @@ class java_bytecode_convert_methodt:public messaget
468468
const exprt::operandst &op,
469469
const java_bytecode_parse_treet::instructiont::argst &args,
470470
const source_locationt &location);
471+
472+
codet convert_pop(const irep_idt &statement, const exprt::operandst &op);
471473
};
472474
#endif

0 commit comments

Comments
 (0)