@@ -33,12 +33,13 @@ class state_encodingt
33
33
}
34
34
35
35
void operator ()(
36
- const goto_functiont & ,
36
+ const goto_functionst::function_mapt::const_iterator ,
37
37
encoding_targett &);
38
38
39
39
void encode (
40
40
const goto_functiont &,
41
41
const std::string &state_prefix,
42
+ const std::string &annotation,
42
43
const symbol_exprt &entry_state,
43
44
const exprt &return_lhs,
44
45
encoding_targett &);
@@ -73,6 +74,7 @@ class state_encodingt
73
74
encoding_targett &);
74
75
75
76
std::string state_prefix;
77
+ std::string annotation;
76
78
loct first_loc;
77
79
symbol_exprt entry_state = symbol_exprt(irep_idt(), typet());
78
80
exprt return_lhs = nil_exprt();
@@ -378,6 +380,9 @@ void state_encodingt::function_call_symbol(
378
380
const auto &type = to_code_type (function.type ());
379
381
auto identifier = function.get_identifier ();
380
382
383
+ auto new_annotation = annotation + u8" \u2192 " + id2string (identifier);
384
+ dest.annotation (new_annotation);
385
+
381
386
// malloc is special-cased
382
387
if (identifier == " malloc" )
383
388
{
@@ -436,54 +441,12 @@ void state_encodingt::function_call_symbol(
436
441
auto new_state_prefix =
437
442
state_prefix + std::to_string (loc->location_number ) + " ." ;
438
443
body_state_encoding.encode (
439
- f->second , new_state_prefix, function_entry_state, nil_exprt (), dest);
440
-
441
- // Function return state (suffix PostReturn).
442
- // This is the state after exiting the function but prior to
443
- // assigning the LHS of the function call.
444
- // auto return_state = state_expr_with_suffix(loc, "PostReturn");
445
-
446
- /*
447
- constraints.push_back(
448
- multi_ary_exprt(
449
- ID_goto_contract,
450
- {loc->call_function(), in_state, return_state, arguments_evaluated},
451
- bool_typet()));
452
- */
453
-
454
- // assign the return value, if any
455
- if (loc->call_lhs ().is_not_nil ())
456
- {
457
- // exprt equality_rhs = return_state;
458
-
459
- /*
460
- auto &return_type = loc->call_lhs().type();
461
- auto rhs_evaluated =
462
- evaluate_expr(
463
- loc,
464
- return_state,
465
- symbol_exprt("return_value", return_type));
466
-
467
- multi_ary_exprt designator(ID_designator, { loc->call_lhs() }, typet());
468
-
469
- auto lhs = out_state_expr(source);
470
-
471
- auto rhs = update_exprt(
472
- return_state,
473
- designator,
474
- rhs_evaluated);
475
-
476
- // 'out state' equality
477
- constraints.push_back(equal_exprt(lhs, rhs));
478
- */
479
- }
480
- /*
481
- else
482
- {
483
- // 'out state' equality
484
- dest << equal_exprt(out_state_expr(loc), return_state);
485
- }
486
- */
444
+ f->second ,
445
+ new_state_prefix,
446
+ new_annotation,
447
+ function_entry_state,
448
+ nil_exprt (),
449
+ dest);
487
450
}
488
451
489
452
void state_encodingt::function_call (
@@ -510,9 +473,11 @@ void state_encodingt::function_call(
510
473
}
511
474
512
475
void state_encodingt::operator ()(
513
- const goto_functiont &goto_function ,
476
+ goto_functionst::function_mapt::const_iterator f_entry ,
514
477
encoding_targett &dest)
515
478
{
479
+ const auto &goto_function = f_entry->second ;
480
+
516
481
if (goto_function.body .instructions .empty ())
517
482
return ;
518
483
@@ -524,18 +489,22 @@ void state_encodingt::operator()(
524
489
implies_exprt (
525
490
true_exprt (), function_application_exprt (in_state, {state_expr ()})));
526
491
527
- encode (goto_function, " S" , in_state, nil_exprt (), dest);
492
+ auto annotation = id2string (f_entry->first );
493
+
494
+ encode (goto_function, " S" , annotation, in_state, nil_exprt (), dest);
528
495
}
529
496
530
497
void state_encodingt::encode (
531
498
const goto_functiont &goto_function,
532
499
const std::string &state_prefix,
500
+ const std::string &annotation,
533
501
const symbol_exprt &entry_state,
534
502
const exprt &return_lhs,
535
503
encoding_targett &dest)
536
504
{
537
505
first_loc = goto_function.body .instructions .begin ();
538
506
this ->state_prefix = state_prefix;
507
+ this ->annotation = annotation;
539
508
this ->entry_state = entry_state;
540
509
this ->return_lhs = return_lhs;
541
510
@@ -673,30 +642,15 @@ void state_encoding(
673
642
bool program_is_inlined,
674
643
encoding_targett &dest)
675
644
{
676
- if (program_is_inlined)
677
- {
678
- auto f_entry = goto_model.goto_functions .function_map .find (
679
- goto_functionst::entry_point ());
645
+ auto f_entry =
646
+ goto_model.goto_functions .function_map .find (goto_functionst::entry_point ());
680
647
681
- if (f_entry == goto_model.goto_functions .function_map .end ())
682
- throw incorrect_goto_program_exceptiont (" The program has no entry point" );
648
+ if (f_entry == goto_model.goto_functions .function_map .end ())
649
+ throw incorrect_goto_program_exceptiont (" The program has no entry point" );
683
650
684
- state_encodingt{goto_model.goto_functions }(f_entry->second , dest);
685
- }
686
- else
687
- {
688
- // output alphabetically
689
- const auto sorted = goto_model.goto_functions .sorted ();
651
+ dest.annotation (" function " + id2string (f_entry->first ));
690
652
691
- for (const auto &f : sorted)
692
- {
693
- if (f->second .body_available ())
694
- {
695
- dest.annotation (" function " + id2string (f->first ));
696
- state_encodingt{goto_model.goto_functions }(f->second , dest);
697
- }
698
- }
699
- }
653
+ state_encodingt{goto_model.goto_functions }(f_entry, dest);
700
654
}
701
655
702
656
void format_hooks ();
0 commit comments