@@ -1452,88 +1452,19 @@ codet java_bytecode_convert_methodt::convert_instructions(
1452
1452
else if (statement==patternt (" ?astore" ))
1453
1453
{
1454
1454
assert (op.size ()==3 && results.empty ());
1455
-
1456
- char type_char=statement[0 ];
1457
-
1458
- const typecast_exprt pointer (op[0 ], java_array_type (type_char));
1459
-
1460
- dereference_exprt deref (pointer, pointer.type ().subtype ());
1461
- deref.set (ID_java_member_access, true );
1462
-
1463
- const member_exprt data_ptr (
1464
- deref,
1465
- " data" ,
1466
- pointer_type (java_type_from_char (type_char)));
1467
-
1468
- plus_exprt data_plus_offset (data_ptr, op[1 ], data_ptr.type ());
1469
- // tag it so it's easy to identify during instrumentation
1470
- data_plus_offset.set (ID_java_array_access, true );
1471
- typet element_type=data_ptr.type ().subtype ();
1472
- const dereference_exprt element (data_plus_offset, element_type);
1473
-
1474
- code_blockt block;
1475
- block.add_source_location ()=i_it->source_location ;
1476
-
1477
- save_stack_entries (
1478
- " stack_astore" ,
1479
- element_type,
1480
- block,
1481
- bytecode_write_typet::ARRAY_REF,
1482
- " " );
1483
-
1484
- code_assignt array_put (element, op[2 ]);
1485
- array_put.add_source_location ()=i_it->source_location ;
1486
- block.move_to_operands (array_put);
1487
- c=block;
1455
+ c = convert_astore (statement, op, i_it->source_location );
1488
1456
}
1489
1457
else if (statement==patternt (" ?store" ))
1490
1458
{
1491
1459
// store value into some local variable
1492
1460
PRECONDITION (op.size () == 1 && results.empty ());
1493
-
1494
- exprt var=
1495
- variable (arg0, statement[0 ], i_it->address , NO_CAST);
1496
- const irep_idt &var_name=to_symbol_expr (var).get_identifier ();
1497
-
1498
- exprt toassign=op[0 ];
1499
- if (' a' ==statement[0 ] && toassign.type ()!=var.type ())
1500
- toassign=typecast_exprt (toassign, var.type ());
1501
-
1502
- code_blockt block;
1503
-
1504
- save_stack_entries (
1505
- " stack_store" ,
1506
- toassign.type (),
1507
- block,
1508
- bytecode_write_typet::VARIABLE,
1509
- var_name);
1510
- code_assignt assign (var, toassign);
1511
- assign.add_source_location ()=i_it->source_location ;
1512
- block.copy_to_operands (assign);
1513
- c=block;
1461
+ c = convert_store (
1462
+ statement, arg0, op, i_it->address , i_it->source_location );
1514
1463
}
1515
1464
else if (statement==patternt (" ?aload" ))
1516
1465
{
1517
1466
PRECONDITION (op.size () == 2 && results.size () == 1 );
1518
-
1519
- char type_char=statement[0 ];
1520
-
1521
- const typecast_exprt pointer (op[0 ], java_array_type (type_char));
1522
-
1523
- dereference_exprt deref (pointer, pointer.type ().subtype ());
1524
- deref.set (ID_java_member_access, true );
1525
-
1526
- const member_exprt data_ptr (
1527
- deref,
1528
- " data" ,
1529
- pointer_type (java_type_from_char (type_char)));
1530
-
1531
- plus_exprt data_plus_offset (data_ptr, op[1 ], data_ptr.type ());
1532
- // tag it so it's easy to identify during instrumentation
1533
- data_plus_offset.set (ID_java_array_access, true );
1534
- typet element_type=data_ptr.type ().subtype ();
1535
- dereference_exprt element (data_plus_offset, element_type);
1536
- results[0 ]=java_bytecode_promotion (element);
1467
+ results[0 ] = convert_aload (statement, op);
1537
1468
}
1538
1469
else if (statement==patternt (" ?load" ))
1539
1470
{
@@ -2684,6 +2615,87 @@ codet java_bytecode_convert_methodt::convert_instructions(
2684
2615
return code;
2685
2616
}
2686
2617
2618
+ exprt java_bytecode_convert_methodt::convert_aload (
2619
+ const irep_idt &statement,
2620
+ const exprt::operandst &op) const
2621
+ {
2622
+ const char &type_char = statement[0 ];
2623
+ const typecast_exprt pointer (op[0 ], java_array_type (type_char));
2624
+
2625
+ dereference_exprt deref (pointer, pointer.type ().subtype ());
2626
+ deref.set (ID_java_member_access, true );
2627
+
2628
+ const member_exprt data_ptr (
2629
+ deref, " data" , pointer_type (java_type_from_char (type_char)));
2630
+
2631
+ plus_exprt data_plus_offset (data_ptr, op[1 ], data_ptr.type ());
2632
+ // tag it so it's easy to identify during instrumentation
2633
+ data_plus_offset.set (ID_java_array_access, true );
2634
+ const typet &element_type = data_ptr.type ().subtype ();
2635
+ const dereference_exprt element (data_plus_offset, element_type);
2636
+ return java_bytecode_promotion (element);
2637
+ }
2638
+
2639
+ codet java_bytecode_convert_methodt::convert_store (
2640
+ const irep_idt &statement,
2641
+ const exprt &arg0,
2642
+ const exprt::operandst &op,
2643
+ const unsigned address,
2644
+ const source_locationt &location)
2645
+ {
2646
+ const exprt var = variable (arg0, statement[0 ], address, NO_CAST);
2647
+ const irep_idt &var_name = to_symbol_expr (var).get_identifier ();
2648
+
2649
+ exprt toassign = op[0 ];
2650
+ if (' a' == statement[0 ] && toassign.type () != var.type ())
2651
+ toassign = typecast_exprt (toassign, var.type ());
2652
+
2653
+ code_blockt block;
2654
+
2655
+ save_stack_entries (
2656
+ " stack_store" ,
2657
+ toassign.type (),
2658
+ block,
2659
+ bytecode_write_typet::VARIABLE,
2660
+ var_name);
2661
+ code_assignt assign (var, toassign);
2662
+ assign.add_source_location () = location;
2663
+ block.move (assign);
2664
+ return block;
2665
+ }
2666
+
2667
+ codet java_bytecode_convert_methodt::convert_astore (
2668
+ const irep_idt &statement,
2669
+ const exprt::operandst &op,
2670
+ const source_locationt &location)
2671
+ {
2672
+ const char type_char = statement[0 ];
2673
+ const typecast_exprt pointer (op[0 ], java_array_type (type_char));
2674
+
2675
+ dereference_exprt deref (pointer, pointer.type ().subtype ());
2676
+ deref.set (ID_java_member_access, true );
2677
+
2678
+ const member_exprt data_ptr (
2679
+ deref, " data" , pointer_type (java_type_from_char (type_char)));
2680
+
2681
+ plus_exprt data_plus_offset (data_ptr, op[1 ], data_ptr.type ());
2682
+ // tag it so it's easy to identify during instrumentation
2683
+ data_plus_offset.set (ID_java_array_access, true );
2684
+ const typet &element_type = data_ptr.type ().subtype ();
2685
+ const dereference_exprt element (data_plus_offset, element_type);
2686
+
2687
+ code_blockt block;
2688
+ block.add_source_location () = location;
2689
+
2690
+ save_stack_entries (
2691
+ " stack_astore" , element_type, block, bytecode_write_typet::ARRAY_REF, " " );
2692
+
2693
+ code_assignt array_put (element, op[2 ]);
2694
+ array_put.add_source_location () = location;
2695
+ block.move (array_put);
2696
+ return block;
2697
+ }
2698
+
2687
2699
optionalt<exprt> java_bytecode_convert_methodt::convert_invoke_dynamic (
2688
2700
const java_class_typet::java_lambda_method_handlest &lambda_method_handles,
2689
2701
const source_locationt &location,
0 commit comments