Skip to content

Commit 0249464

Browse files
Extract convert_dup2_x2 function
1 parent ba6f552 commit 0249464

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/java_bytecode/java_bytecode_convert_method.cpp

+22-16
Original file line numberDiff line numberDiff line change
@@ -1484,22 +1484,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
14841484
else if(statement=="dup2_x2")
14851485
{
14861486
PRECONDITION(!stack.empty() && results.empty());
1487-
1488-
if(get_bytecode_type_width(stack.back().type())==32)
1489-
op=pop(2);
1490-
else
1491-
op=pop(1);
1492-
1493-
exprt::operandst op2;
1494-
1495-
if(get_bytecode_type_width(stack.back().type())==32)
1496-
op2=pop(2);
1497-
else
1498-
op2=pop(1);
1499-
1500-
results.insert(results.end(), op.begin(), op.end());
1501-
results.insert(results.end(), op2.begin(), op2.end());
1502-
results.insert(results.end(), op.begin(), op.end());
1487+
convert_dup2_x2(op, results);
15031488
}
15041489
else if(statement=="dconst")
15051490
{
@@ -1955,6 +1940,27 @@ void java_bytecode_convert_methodt::convert_dup2_x1(
19551940
results.insert(results.end(), op.begin(), op.end());
19561941
}
19571942

1943+
void java_bytecode_convert_methodt::convert_dup2_x2(
1944+
exprt::operandst &op,
1945+
exprt::operandst &results)
1946+
{
1947+
if(get_bytecode_type_width(stack.back().type()) == 32)
1948+
op = pop(2);
1949+
else
1950+
op = pop(1);
1951+
1952+
exprt::operandst op2;
1953+
1954+
if(get_bytecode_type_width(stack.back().type()) == 32)
1955+
op2 = pop(2);
1956+
else
1957+
op2 = pop(1);
1958+
1959+
results.insert(results.end(), op.begin(), op.end());
1960+
results.insert(results.end(), op2.begin(), op2.end());
1961+
results.insert(results.end(), op.begin(), op.end());
1962+
}
1963+
19581964
exprt::operandst &java_bytecode_convert_methodt::convert_const(
19591965
const irep_idt &statement,
19601966
exprt &arg0,

src/java_bytecode/java_bytecode_convert_method_class.h

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

458+
void convert_dup2_x2(exprt::operandst &op, exprt::operandst &results);
459+
458460
void convert_dup2_x1(exprt::operandst &op, exprt::operandst &results);
459461

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

0 commit comments

Comments
 (0)