@@ -125,7 +125,7 @@ class java_bytecode_parsert:public parsert
125
125
void rRuntimeAnnotation_attribute (annotationst &);
126
126
void rRuntimeAnnotation (annotationt &);
127
127
void relement_value_pairs (annotationt::element_value_pairst &);
128
- void relement_value_pair (annotationt::element_value_pairt & );
128
+ exprt get_relement_value ( );
129
129
void rmethod_attribute (methodt &method);
130
130
void rfield_attribute (fieldt &);
131
131
void rcode_attribute (methodt &method);
@@ -1507,16 +1507,17 @@ void java_bytecode_parsert::relement_value_pairs(
1507
1507
{
1508
1508
u2 element_name_index=read_u2 ();
1509
1509
element_value_pair.element_name =pool_entry (element_name_index).s ;
1510
-
1511
- relement_value_pair (element_value_pair);
1510
+ element_value_pair.value = get_relement_value ();
1512
1511
}
1513
1512
}
1514
1513
1515
1514
// / Corresponds to the element_value structure
1516
1515
// / Described in Java 8 specification 4.7.16.1
1517
1516
// / https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.16.1
1518
- void java_bytecode_parsert::relement_value_pair (
1519
- annotationt::element_value_pairt &element_value_pair)
1517
+ // / \returns An exprt that represents the particular value of annotations field.
1518
+ // / This is usually one of: a byte, number of some sort, string, character,
1519
+ // / enum, Class type, array or another annotation.
1520
+ exprt java_bytecode_parsert::get_relement_value ()
1520
1521
{
1521
1522
u1 tag=read_u1 ();
1522
1523
@@ -1527,50 +1528,47 @@ void java_bytecode_parsert::relement_value_pair(
1527
1528
UNUSED_u2 (type_name_index);
1528
1529
UNUSED_u2 (const_name_index);
1529
1530
// todo: enum
1531
+ return exprt ();
1530
1532
}
1531
- break ;
1532
1533
1533
1534
case ' c' :
1534
1535
{
1535
1536
u2 class_info_index = read_u2 ();
1536
- element_value_pair. value = symbol_exprt (pool_entry (class_info_index).s );
1537
+ return symbol_exprt (pool_entry (class_info_index).s );
1537
1538
}
1538
- break ;
1539
1539
1540
1540
case ' @' :
1541
1541
{
1542
+ // TODO: return this wrapped in an exprt
1542
1543
// another annotation, recursively
1543
1544
annotationt annotation;
1544
1545
rRuntimeAnnotation (annotation);
1546
+ return exprt ();
1545
1547
}
1546
- break ;
1547
1548
1548
1549
case ' [' :
1549
1550
{
1551
+ array_exprt values;
1550
1552
u2 num_values=read_u2 ();
1551
1553
for (std::size_t i=0 ; i<num_values; i++)
1552
1554
{
1553
- annotationt::element_value_pairt element_value;
1554
- relement_value_pair (element_value); // recursive call
1555
+ values.operands ().push_back (get_relement_value ());
1555
1556
}
1557
+ return values;
1556
1558
}
1557
- break ;
1558
1559
1559
1560
case ' s' :
1560
1561
{
1561
1562
u2 const_value_index=read_u2 ();
1562
- element_value_pair.value =string_constantt (
1563
- pool_entry (const_value_index).s );
1563
+ return string_constantt (pool_entry (const_value_index).s );
1564
1564
}
1565
- break ;
1566
1565
1567
1566
default :
1568
1567
{
1569
1568
u2 const_value_index=read_u2 ();
1570
- element_value_pair.value =constant (const_value_index);
1571
- }
1572
1569
1573
- break ;
1570
+ return constant (const_value_index);
1571
+ }
1574
1572
}
1575
1573
}
1576
1574
0 commit comments