@@ -325,7 +325,6 @@ main_function_resultt get_main_symbol(
325
325
message_handlert &message_handler,
326
326
bool allow_no_body)
327
327
{
328
- symbolt symbol;
329
328
main_function_resultt res;
330
329
331
330
messaget message (message_handler);
@@ -344,28 +343,30 @@ main_function_resultt get_main_symbol(
344
343
{
345
344
message.error () << " main symbol resolution failed: "
346
345
<< error_message << messaget::eom;
347
- res.main_function =symbol;
348
346
res.status =main_function_resultt::Error;
349
347
return res;
350
348
}
351
349
352
- symbol_tablet::symbolst::const_iterator s_it =
353
- symbol_table.symbols . find (main_symbol_id);
350
+ symbol_tablet::opt_const_symbol_reft symbol =
351
+ symbol_table.lookup (main_symbol_id);
354
352
INVARIANT (
355
- s_it!=symbol_table. symbols . end () ,
353
+ symbol ,
356
354
" resolve_friendly_method_name should return a symbol-table identifier" );
357
355
358
- symbol=s_it->second ;
359
-
360
356
// check if it has a body
361
- if (symbol.value .is_nil () && !allow_no_body)
357
+ if (symbol-> get () .value .is_nil () && !allow_no_body)
362
358
{
363
359
message.error () << " main method `" << main_class
364
360
<< " ' has no body" << messaget::eom;
365
- res.main_function =symbol;
361
+ res.main_function =* symbol;
366
362
res.status =main_function_resultt::Error;
367
363
return res;
368
364
}
365
+
366
+ // Return found function
367
+ res.main_function =*symbol;
368
+ res.status =main_function_resultt::Success;
369
+ return res;
369
370
}
370
371
else
371
372
{
@@ -375,7 +376,6 @@ main_function_resultt get_main_symbol(
375
376
// are we given a main class?
376
377
if (main_class.empty ())
377
378
{
378
- res.main_function =symbol;
379
379
res.status =main_function_resultt::NotFound;
380
380
return res; // silently ignore
381
381
}
@@ -386,7 +386,7 @@ main_function_resultt get_main_symbol(
386
386
std::string prefix=" java::" +entry_method+" :" ;
387
387
388
388
// look it up
389
- std::set<irep_idt > matches;
389
+ std::set<const symbolt * > matches;
390
390
391
391
for (symbol_tablet::symbolst::const_iterator
392
392
s_it=symbol_table.symbols .begin ();
@@ -395,18 +395,17 @@ main_function_resultt get_main_symbol(
395
395
{
396
396
if (s_it->second .type .id ()==ID_code &&
397
397
has_prefix (id2string (s_it->first ), prefix))
398
- matches.insert (s_it->first );
398
+ matches.insert (& s_it->second );
399
399
}
400
400
401
401
if (matches.empty ())
402
402
{
403
403
// Not found, silently ignore
404
- res.main_function =symbol;
405
404
res.status =main_function_resultt::NotFound;
406
405
return res;
407
406
}
408
407
409
- if (matches.size ()>= 2 )
408
+ if (matches.size ()>1 )
410
409
{
411
410
message.error () << " main method in `" << main_class
412
411
<< " ' is ambiguous" << messaget::eom;
@@ -416,7 +415,7 @@ main_function_resultt get_main_symbol(
416
415
}
417
416
418
417
// function symbol
419
- symbol=symbol_table. symbols . find (* matches.begin ())-> second ;
418
+ const symbolt & symbol=** matches.begin ();
420
419
421
420
// check if it has a body
422
421
if (symbol.value .is_nil () && !allow_no_body)
@@ -427,12 +426,12 @@ main_function_resultt get_main_symbol(
427
426
res.status =main_function_resultt::Error;
428
427
return res; // give up with error
429
428
}
430
- }
431
429
432
- // Return found function
433
- res.main_function =symbol;
434
- res.status =main_function_resultt::Success;
435
- return res;
430
+ // Return found function
431
+ res.main_function =symbol;
432
+ res.status =main_function_resultt::Success;
433
+ return res;
434
+ }
436
435
}
437
436
438
437
// / Given the \p symbol_table and the \p main_class to test, this function
0 commit comments