Skip to content

Commit abfb887

Browse files
Extract convert_dup2_x2 function
1 parent c486bb0 commit abfb887

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,22 +1512,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
15121512
else if(statement=="dup2_x2")
15131513
{
15141514
PRECONDITION(!stack.empty() && results.empty());
1515-
1516-
if(get_bytecode_type_width(stack.back().type())==32)
1517-
op=pop(2);
1518-
else
1519-
op=pop(1);
1520-
1521-
exprt::operandst op2;
1522-
1523-
if(get_bytecode_type_width(stack.back().type())==32)
1524-
op2=pop(2);
1525-
else
1526-
op2=pop(1);
1527-
1528-
results.insert(results.end(), op.begin(), op.end());
1529-
results.insert(results.end(), op2.begin(), op2.end());
1530-
results.insert(results.end(), op.begin(), op.end());
1515+
convert_dup2_x2(op, results);
15311516
}
15321517
else if(statement=="dconst")
15331518
{
@@ -1983,6 +1968,27 @@ void java_bytecode_convert_methodt::convert_dup2_x1(
19831968
results.insert(results.end(), op.begin(), op.end());
19841969
}
19851970

1971+
void java_bytecode_convert_methodt::convert_dup2_x2(
1972+
exprt::operandst &op,
1973+
exprt::operandst &results)
1974+
{
1975+
if(get_bytecode_type_width(stack.back().type()) == 32)
1976+
op = pop(2);
1977+
else
1978+
op = pop(1);
1979+
1980+
exprt::operandst op2;
1981+
1982+
if(get_bytecode_type_width(stack.back().type()) == 32)
1983+
op2 = pop(2);
1984+
else
1985+
op2 = pop(1);
1986+
1987+
results.insert(results.end(), op.begin(), op.end());
1988+
results.insert(results.end(), op2.begin(), op2.end());
1989+
results.insert(results.end(), op.begin(), op.end());
1990+
}
1991+
19861992
exprt::operandst &java_bytecode_convert_methodt::convert_const(
19871993
const irep_idt &statement,
19881994
const exprt &arg0,

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ class java_bytecode_convert_methodt:public messaget
459459
const exprt &arg0,
460460
exprt::operandst &results) const;
461461

462+
void convert_dup2_x2(exprt::operandst &op, exprt::operandst &results);
463+
462464
void
463465
convert_dup2_x1(exprt::operandst &op, exprt::operandst &results);
464466

0 commit comments

Comments
 (0)