Skip to content

Commit f2acb00

Browse files
Extract convert_dup2_x2 function
1 parent 66cf709 commit f2acb00

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

+22-16
Original file line numberDiff line numberDiff line change
@@ -1514,22 +1514,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
15141514
else if(statement=="dup2_x2")
15151515
{
15161516
PRECONDITION(!stack.empty() && results.empty());
1517-
1518-
if(get_bytecode_type_width(stack.back().type())==32)
1519-
op=pop(2);
1520-
else
1521-
op=pop(1);
1522-
1523-
exprt::operandst op2;
1524-
1525-
if(get_bytecode_type_width(stack.back().type())==32)
1526-
op2=pop(2);
1527-
else
1528-
op2=pop(1);
1529-
1530-
results.insert(results.end(), op.begin(), op.end());
1531-
results.insert(results.end(), op2.begin(), op2.end());
1532-
results.insert(results.end(), op.begin(), op.end());
1517+
convert_dup2_x2(op, results);
15331518
}
15341519
else if(statement=="dconst")
15351520
{
@@ -1985,6 +1970,27 @@ void java_bytecode_convert_methodt::convert_dup2_x1(
19851970
results.insert(results.end(), op.begin(), op.end());
19861971
}
19871972

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

jbmc/src/java_bytecode/java_bytecode_convert_method_class.h

+2
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ class java_bytecode_convert_methodt:public messaget
457457
const exprt &arg0,
458458
exprt::operandst &results) const;
459459

460+
void convert_dup2_x2(exprt::operandst &op, exprt::operandst &results);
461+
460462
void convert_dup2_x1(exprt::operandst &op, exprt::operandst &results);
461463

462464
void convert_dup2(exprt::operandst &op, exprt::operandst &results);

0 commit comments

Comments
 (0)