Skip to content

Commit ea3399a

Browse files
Extract convert_dup2_x2 function
1 parent e996563 commit ea3399a

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
@@ -1497,22 +1497,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
14971497
else if(statement=="dup2_x2")
14981498
{
14991499
PRECONDITION(!stack.empty() && results.empty());
1500-
1501-
if(get_bytecode_type_width(stack.back().type())==32)
1502-
op=pop(2);
1503-
else
1504-
op=pop(1);
1505-
1506-
exprt::operandst op2;
1507-
1508-
if(get_bytecode_type_width(stack.back().type())==32)
1509-
op2=pop(2);
1510-
else
1511-
op2=pop(1);
1512-
1513-
results.insert(results.end(), op.begin(), op.end());
1514-
results.insert(results.end(), op2.begin(), op2.end());
1515-
results.insert(results.end(), op.begin(), op.end());
1500+
convert_dup2_x2(op, results);
15161501
}
15171502
else if(statement=="dconst")
15181503
{
@@ -1968,6 +1953,27 @@ void java_bytecode_convert_methodt::convert_dup2_x1(
19681953
results.insert(results.end(), op.begin(), op.end());
19691954
}
19701955

1956+
void java_bytecode_convert_methodt::convert_dup2_x2(
1957+
exprt::operandst &op,
1958+
exprt::operandst &results)
1959+
{
1960+
if(get_bytecode_type_width(stack.back().type()) == 32)
1961+
op = pop(2);
1962+
else
1963+
op = pop(1);
1964+
1965+
exprt::operandst op2;
1966+
1967+
if(get_bytecode_type_width(stack.back().type()) == 32)
1968+
op2 = pop(2);
1969+
else
1970+
op2 = pop(1);
1971+
1972+
results.insert(results.end(), op.begin(), op.end());
1973+
results.insert(results.end(), op2.begin(), op2.end());
1974+
results.insert(results.end(), op.begin(), op.end());
1975+
}
1976+
19711977
exprt::operandst &java_bytecode_convert_methodt::convert_const(
19721978
const irep_idt &statement,
19731979
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
@@ -457,6 +457,8 @@ class java_bytecode_convert_methodt:public messaget
457457
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)