@@ -333,14 +333,40 @@ std::vector<typet> parse_list_types(
333
333
const std::string class_name_prefix,
334
334
const char opening_bracket,
335
335
const char closing_bracket)
336
+ {
337
+ // Loop over the types in the given string, parsing each one in turn
338
+ // and adding to the type_list
339
+ std::vector<typet> type_list;
340
+ for (const std::string &raw_type :
341
+ parse_raw_list_types (src, opening_bracket, closing_bracket))
342
+ {
343
+ const typet new_type = java_type_from_string (raw_type, class_name_prefix);
344
+ INVARIANT (new_type != nil_typet (), " Failed to parse type" );
345
+ type_list.push_back (new_type);
346
+ }
347
+ return type_list;
348
+ }
349
+
350
+ // / Given a substring of a descriptor or signature that contains one or more
351
+ // / types parse out the individual type strings.
352
+ // / \param src: The input string that is wrapped in either ( ) or < >
353
+ // / \param opening_bracket: For checking string is passed in as expected, the
354
+ // / opening bracket (i.e. '(' or '<').
355
+ // / \param closing_bracket: For checking string is passed in as expected, the
356
+ // / closing bracket (i.e. ')' or '>').
357
+ // / \return A vector of strings that represent the bytecode type.
358
+ std::vector<std::string> parse_raw_list_types (
359
+ const std::string src,
360
+ const char opening_bracket,
361
+ const char closing_bracket)
336
362
{
337
363
PRECONDITION (src.size () >= 2 );
338
364
PRECONDITION (src[0 ] == opening_bracket);
339
365
PRECONDITION (src[src.size () - 1 ] == closing_bracket);
340
366
341
367
// Loop over the types in the given string, parsing each one in turn
342
368
// and adding to the type_list
343
- std::vector<typet > type_list;
369
+ std::vector<std::string > type_list;
344
370
for (std::size_t i = 1 ; i < src.size () - 1 ; i++)
345
371
{
346
372
size_t start = i;
@@ -369,10 +395,7 @@ std::vector<typet> parse_list_types(
369
395
}
370
396
371
397
std::string sub_str = src.substr (start, i - start + 1 );
372
- const typet &new_type = java_type_from_string (sub_str, class_name_prefix);
373
- INVARIANT (new_type != nil_typet (), " Failed to parse type" );
374
-
375
- type_list.push_back (new_type);
398
+ type_list.emplace_back (sub_str);
376
399
}
377
400
return type_list;
378
401
}
0 commit comments