@@ -1514,31 +1514,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
1514
1514
// and write something like:
1515
1515
// if(retaddr==5) goto 5; else if(retaddr==10) goto 10; ...
1516
1516
PRECONDITION (op.empty () && results.empty ());
1517
- c=code_blockt ();
1518
- auto retvar=variable (arg0, ' a' , i_it->address , NO_CAST);
1519
1517
assert (!jsr_ret_targets.empty ());
1520
- for (size_t idx=0 , idxlim=jsr_ret_targets.size (); idx!=idxlim; ++idx)
1521
- {
1522
- irep_idt number=std::to_string (jsr_ret_targets[idx]);
1523
- code_gotot g (label (number));
1524
- g.add_source_location ()=i_it->source_location ;
1525
- if (idx==idxlim-1 )
1526
- c.move_to_operands (g);
1527
- else
1528
- {
1529
- code_ifthenelset branch;
1530
- auto address_ptr=
1531
- from_integer (
1532
- jsr_ret_targets[idx],
1533
- unsignedbv_typet (64 ));
1534
- address_ptr.type ()=pointer_type (void_typet ());
1535
- branch.cond ()=equal_exprt (retvar, address_ptr);
1536
- branch.cond ().add_source_location ()=i_it->source_location ;
1537
- branch.then_case ()=g;
1538
- branch.add_source_location ()=i_it->source_location ;
1539
- c.move_to_operands (branch);
1540
- }
1541
- }
1518
+ c = convert_ret (
1519
+ jsr_ret_targets, arg0, i_it->source_location , i_it->address );
1542
1520
}
1543
1521
else if (statement==" iconst_m1" )
1544
1522
{
@@ -2615,6 +2593,37 @@ codet java_bytecode_convert_methodt::convert_instructions(
2615
2593
return code;
2616
2594
}
2617
2595
2596
+ code_blockt java_bytecode_convert_methodt::convert_ret (
2597
+ const std::vector<unsigned int > &jsr_ret_targets,
2598
+ const exprt &arg0,
2599
+ const source_locationt &location,
2600
+ const unsigned address)
2601
+ {
2602
+ code_blockt c;
2603
+ auto retvar = variable (arg0, ' a' , address, NO_CAST);
2604
+ for (size_t idx = 0 , idxlim = jsr_ret_targets.size (); idx != idxlim; ++idx)
2605
+ {
2606
+ irep_idt number = std::to_string (jsr_ret_targets[idx]);
2607
+ code_gotot g (label (number));
2608
+ g.add_source_location () = location;
2609
+ if (idx == idxlim - 1 )
2610
+ c.move_to_operands (g);
2611
+ else
2612
+ {
2613
+ code_ifthenelset branch;
2614
+ auto address_ptr =
2615
+ from_integer (jsr_ret_targets[idx], unsignedbv_typet (64 ));
2616
+ address_ptr.type () = pointer_type (void_typet ());
2617
+ branch.cond () = equal_exprt (retvar, address_ptr);
2618
+ branch.cond ().add_source_location () = location;
2619
+ branch.then_case () = g;
2620
+ branch.add_source_location () = location;
2621
+ c.move_to_operands (branch);
2622
+ }
2623
+ }
2624
+ return c;
2625
+ }
2626
+
2618
2627
exprt java_bytecode_convert_methodt::convert_aload (
2619
2628
const irep_idt &statement,
2620
2629
const exprt::operandst &op) const
0 commit comments