@@ -53,6 +53,7 @@ class state_encodingt
53
53
using loct = goto_programt::const_targett;
54
54
55
55
symbol_exprt out_state_expr (loct) const ;
56
+ symbol_exprt state_expr_with_suffix (loct, const std::string &suffix) const ;
56
57
symbol_exprt out_state_expr (loct, bool taken) const ;
57
58
symbol_exprt in_state_expr (loct) const ;
58
59
exprt evaluate_expr (loct, const exprt &, const exprt &) const ;
@@ -72,16 +73,19 @@ class state_encodingt
72
73
73
74
symbol_exprt state_encodingt::out_state_expr (loct loc) const
74
75
{
75
- return symbol_exprt (
76
- " S" + std::to_string (loc->location_number ), state_predicate_type ());
76
+ return state_expr_with_suffix (loc, " " );
77
+ }
78
+
79
+ symbol_exprt state_encodingt::state_expr_with_suffix (loct loc, const std::string &suffix) const
80
+ {
81
+ irep_idt identifier =
82
+ std::string (" S" ) + std::to_string (loc->location_number ) + suffix;
83
+ return symbol_exprt (identifier, state_predicate_type ());
77
84
}
78
85
79
86
symbol_exprt state_encodingt::out_state_expr (loct loc, bool taken) const
80
87
{
81
- return symbol_exprt (
82
- std::string (" S" ) + std::to_string (loc->location_number ) +
83
- (taken ? " T" : " " ),
84
- state_predicate_type ());
88
+ return state_expr_with_suffix (loc, taken ? " T" : " " );
85
89
}
86
90
87
91
symbol_exprt state_encodingt::in_state_expr (loct loc) const
@@ -349,40 +353,43 @@ void state_encodingt::operator()(
349
353
}
350
354
else if (loc->is_function_call ())
351
355
{
352
- /*
353
- const sourcet source{loc->location_number};
354
-
355
- // Evaluate the arguments in the 'in state'
356
- const auto in_state = in_state_expr(source);
357
-
356
+ // Evaluate the arguments of the call in the 'in state'
358
357
multi_ary_exprt arguments_evaluated (ID_tuple, {}, typet (ID_tuple));
359
358
arguments_evaluated.reserve_operands (loc->call_arguments ().size ());
360
359
360
+ const auto in_state = in_state_expr (loc);
361
+
361
362
for (auto &argument : loc->call_arguments ())
362
- arguments_evaluated.add_to_operands(evaluate_exprt(in_state, argument));
363
+ arguments_evaluated.add_to_operands (evaluate_expr (loc, in_state, argument));
364
+
365
+ auto function_entry_state = state_expr_with_suffix (loc, " Entry" );
363
366
364
- // Function return state (suffix _R).
367
+ dest << forall_states_expr (loc,
368
+ function_application_exprt (function_entry_state, {state_expr ()}));
369
+
370
+ // Function return state (suffix PostReturn).
365
371
// This is the state after exiting the function but prior to
366
372
// assigning the LHS of the function call.
367
- auto return_state = suffix_state_expr(source.location, "_R");
368
-
369
- // Add the constraints for the callee -- if there is no
370
- // contract, this is the full body, possibly transitively.
373
+ auto return_state = state_expr_with_suffix (loc, " PostReturn" );
371
374
375
+ /*
372
376
constraints.push_back(
373
377
multi_ary_exprt(
374
378
ID_goto_contract,
375
379
{loc->call_function(), in_state, return_state, arguments_evaluated},
376
380
bool_typet()));
381
+ */
377
382
378
383
// assign the return value, if any
379
384
if (loc->call_lhs ().is_not_nil ())
380
385
{
381
386
exprt equality_rhs = return_state;
382
387
388
+ /*
383
389
auto &return_type = loc->call_lhs().type();
384
390
auto rhs_evaluated =
385
- evaluate_exprt(
391
+ evaluate_expr(
392
+ loc,
386
393
return_state,
387
394
symbol_exprt("return_value", return_type));
388
395
@@ -397,14 +404,13 @@ void state_encodingt::operator()(
397
404
398
405
// 'out state' equality
399
406
constraints.push_back(equal_exprt(lhs, rhs));
407
+ */
400
408
}
401
409
else
402
410
{
403
411
// 'out state' equality
404
- auto lhs = out_state_expr(source);
405
- constraints.push_back(equal_exprt(lhs, return_state));
412
+ dest << equal_exprt (out_state_expr (loc), return_state);
406
413
}
407
- */
408
414
}
409
415
else if (loc->is_set_return_value ())
410
416
{
@@ -495,6 +501,7 @@ class ascii_encoding_targett : public encoding_targett
495
501
496
502
void annotation (const std::string &text) override
497
503
{
504
+ out << ' \n ' << text << ' \n ' ;
498
505
}
499
506
500
507
protected:
0 commit comments