Skip to content

Commit 3f789a5

Browse files
Extract convert_dup2 function
1 parent d10ab05 commit 3f789a5

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,14 +1487,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
14871487
else if(statement=="dup2")
14881488
{
14891489
PRECONDITION(!stack.empty() && results.empty());
1490-
1491-
if(get_bytecode_type_width(stack.back().type())==32)
1492-
op=pop(2);
1493-
else
1494-
op=pop(1);
1495-
1496-
results.insert(results.end(), op.begin(), op.end());
1497-
results.insert(results.end(), op.begin(), op.end());
1490+
convert_dup2(op, results);
14981491
}
14991492
else if(statement=="dup2_x1")
15001493
{
@@ -1956,6 +1949,19 @@ codet java_bytecode_convert_methodt::convert_instructions(
19561949
return code;
19571950
}
19581951

1952+
void java_bytecode_convert_methodt::convert_dup2(
1953+
exprt::operandst &op,
1954+
exprt::operandst &results)
1955+
{
1956+
if(get_bytecode_type_width(stack.back().type()) == 32)
1957+
op = pop(2);
1958+
else
1959+
op = pop(1);
1960+
1961+
results.insert(results.end(), op.begin(), op.end());
1962+
results.insert(results.end(), op.begin(), op.end());
1963+
}
1964+
19591965
exprt::operandst &java_bytecode_convert_methodt::convert_const(
19601966
const irep_idt &statement,
19611967
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
@@ -456,5 +456,7 @@ class java_bytecode_convert_methodt:public messaget
456456
const irep_idt &statement,
457457
exprt &arg0,
458458
exprt::operandst &results) const;
459+
460+
void convert_dup2(exprt::operandst &op, exprt::operandst &results);
459461
};
460462
#endif

0 commit comments

Comments
 (0)