@@ -53,6 +53,7 @@ class state_encodingt
5353 using loct = goto_programt::const_targett;
5454
5555 symbol_exprt out_state_expr (loct) const ;
56+ symbol_exprt state_expr_with_suffix (loct, const std::string &suffix) const ;
5657 symbol_exprt out_state_expr (loct, bool taken) const ;
5758 symbol_exprt in_state_expr (loct) const ;
5859 exprt evaluate_expr (loct, const exprt &, const exprt &) const ;
@@ -72,16 +73,19 @@ class state_encodingt
7273
7374symbol_exprt state_encodingt::out_state_expr (loct loc) const
7475{
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 ());
7784}
7885
7986symbol_exprt state_encodingt::out_state_expr (loct loc, bool taken) const
8087{
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" : " " );
8589}
8690
8791symbol_exprt state_encodingt::in_state_expr (loct loc) const
@@ -349,40 +353,43 @@ void state_encodingt::operator()(
349353 }
350354 else if (loc->is_function_call ())
351355 {
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'
358357 multi_ary_exprt arguments_evaluated (ID_tuple, {}, typet (ID_tuple));
359358 arguments_evaluated.reserve_operands (loc->call_arguments ().size ());
360359
360+ const auto in_state = in_state_expr (loc);
361+
361362 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" );
363366
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).
365371 // This is the state after exiting the function but prior to
366372 // 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" );
371374
375+ /*
372376 constraints.push_back(
373377 multi_ary_exprt(
374378 ID_goto_contract,
375379 {loc->call_function(), in_state, return_state, arguments_evaluated},
376380 bool_typet()));
381+ */
377382
378383 // assign the return value, if any
379384 if (loc->call_lhs ().is_not_nil ())
380385 {
381386 exprt equality_rhs = return_state;
382387
388+ /*
383389 auto &return_type = loc->call_lhs().type();
384390 auto rhs_evaluated =
385- evaluate_exprt(
391+ evaluate_expr(
392+ loc,
386393 return_state,
387394 symbol_exprt("return_value", return_type));
388395
@@ -397,14 +404,13 @@ void state_encodingt::operator()(
397404
398405 // 'out state' equality
399406 constraints.push_back(equal_exprt(lhs, rhs));
407+ */
400408 }
401409 else
402410 {
403411 // '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);
406413 }
407- */
408414 }
409415 else if (loc->is_set_return_value ())
410416 {
@@ -495,6 +501,7 @@ class ascii_encoding_targett : public encoding_targett
495501
496502 void annotation (const std::string &text) override
497503 {
504+ out << ' \n ' << text << ' \n ' ;
498505 }
499506
500507protected:
0 commit comments