@@ -325,8 +325,6 @@ main_function_resultt get_main_symbol(
325
325
message_handlert &message_handler,
326
326
bool allow_no_body)
327
327
{
328
- main_function_resultt res;
329
-
330
328
messaget message (message_handler);
331
329
332
330
// find main symbol
@@ -341,10 +339,9 @@ main_function_resultt get_main_symbol(
341
339
342
340
if (main_symbol_id==irep_idt ())
343
341
{
344
- message.error () << " main symbol resolution failed: "
345
- << error_message << messaget::eom;
346
- res.status =main_function_resultt::Error;
347
- return res;
342
+ message.error ()
343
+ << " main symbol resolution failed: " << error_message << messaget::eom;
344
+ return main_function_resultt::Error;
348
345
}
349
346
350
347
symbol_tablet::opt_const_symbol_reft symbol=
@@ -356,17 +353,12 @@ main_function_resultt get_main_symbol(
356
353
// check if it has a body
357
354
if (symbol->get ().value .is_nil () && !allow_no_body)
358
355
{
359
- message.error () << " main method `" << main_class
360
- << " ' has no body" << messaget::eom;
361
- res.main_function =*symbol;
362
- res.status =main_function_resultt::Error;
363
- return res;
356
+ message.error ()
357
+ << " main method `" << main_class << " ' has no body" << messaget::eom;
358
+ return main_function_resultt::Error;
364
359
}
365
360
366
- // Return found function
367
- res.main_function =*symbol;
368
- res.status =main_function_resultt::Success;
369
- return res;
361
+ return main_function_resultt (*symbol); // Return found function
370
362
}
371
363
else
372
364
{
@@ -375,43 +367,34 @@ main_function_resultt get_main_symbol(
375
367
376
368
// are we given a main class?
377
369
if (main_class.empty ())
378
- {
379
- res.status =main_function_resultt::NotFound;
380
- return res; // silently ignore
381
- }
370
+ return main_function_resultt::NotFound; // silently ignore
382
371
383
- std::string entry_method=
384
- id2string (main_class)+" .main" ;
372
+ std::string entry_method=id2string (main_class)+" .main" ;
385
373
386
374
std::string prefix=" java::" +entry_method+" :" ;
387
375
388
376
// look it up
389
377
std::set<const symbolt *> matches;
390
378
391
- for (symbol_tablet::symbolst::const_iterator
392
- s_it=symbol_table.symbols .begin ();
393
- s_it!=symbol_table.symbols .end ();
394
- s_it++)
379
+ for (const auto &named_symbol : symbol_table.symbols )
395
380
{
396
- if (s_it->second .type .id ()==ID_code &&
397
- has_prefix (id2string (s_it->first ), prefix))
398
- matches.insert (&s_it->second );
381
+ if (named_symbol.second .type .id ()==ID_code
382
+ && has_prefix (id2string (named_symbol.first ), prefix))
383
+ {
384
+ matches.insert (&named_symbol.second );
385
+ }
399
386
}
400
387
401
388
if (matches.empty ())
402
- {
403
389
// Not found, silently ignore
404
- res.status =main_function_resultt::NotFound;
405
- return res;
406
- }
390
+ return main_function_resultt::NotFound;
407
391
408
392
if (matches.size ()>1 )
409
393
{
410
- message.error () << " main method in `" << main_class
411
- << " ' is ambiguous" << messaget::eom;
412
- res.main_function =symbolt ();
413
- res.status =main_function_resultt::Error;
414
- return res; // give up with error, no main
394
+ message.error ()
395
+ << " main method in `" << main_class
396
+ << " ' is ambiguous" << messaget::eom;
397
+ return main_function_resultt::Error; // give up with error, no main
415
398
}
416
399
417
400
// function symbol
@@ -420,17 +403,12 @@ main_function_resultt get_main_symbol(
420
403
// check if it has a body
421
404
if (symbol.value .is_nil () && !allow_no_body)
422
405
{
423
- message.error () << " main method `" << main_class
424
- << " ' has no body" << messaget::eom;
425
- res.main_function =symbol;
426
- res.status =main_function_resultt::Error;
427
- return res; // give up with error
406
+ message.error ()
407
+ << " main method `" << main_class << " ' has no body" << messaget::eom;
408
+ return main_function_resultt::Error; // give up with error
428
409
}
429
410
430
- // Return found function
431
- res.main_function =symbol;
432
- res.status =main_function_resultt::Success;
433
- return res;
411
+ return symbol; // Return found function
434
412
}
435
413
}
436
414
0 commit comments