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