|
2 | 2 |
|
3 | 3 | #include <goto-programs/goto_trace.h>
|
4 | 4 |
|
| 5 | +#include <cegis/cegis-util/program_helper.h> |
| 6 | +#include <cegis/instrument/literals.h> |
5 | 7 | #include <cegis/control/value/control_vars.h>
|
6 | 8 | #include <cegis/control/value/control_vector_solution.h>
|
7 | 9 | #include <cegis/control/preprocessing/propagate_controller_sizes.h>
|
8 | 10 | #include <cegis/control/learn/print_control_solution.h>
|
9 | 11 | #include <cegis/control/learn/vector_solution_configuration.h>
|
10 | 12 |
|
| 13 | +namespace |
| 14 | +{ |
| 15 | +bool is_assignment_to_solution_var(const goto_programt::instructiont &instr) |
| 16 | +{ |
| 17 | + if (goto_program_instruction_typet::ASSIGN != instr.type) return false; |
| 18 | + const std::string &var_name=id2string(get_affected_variable(instr)); |
| 19 | + return CEGIS_CONTROL_VECTOR_SOLUTION_VAR_NAME == var_name; |
| 20 | +} |
| 21 | +} |
| 22 | + |
11 | 23 | void vector_solution_configurationt::nondeterminise_solution_configuration(
|
12 | 24 | symbol_tablet &st, goto_functionst &gf)
|
13 | 25 | {
|
| 26 | + goto_programt &init_body=get_body(gf, CPROVER_INIT); |
| 27 | + goto_programt::instructionst &init_instrs=init_body.instructions; |
| 28 | + const goto_programt::targett assignment=std::find_if(init_instrs.begin(), |
| 29 | + init_instrs.end(), is_assignment_to_solution_var); |
| 30 | + goto_programt &entry_body=get_entry_body(gf); |
| 31 | + const goto_programt::targett first_entry=entry_body.instructions.begin(); |
| 32 | + const goto_programt::targett new_assignment=entry_body.insert_before( |
| 33 | + first_entry); |
| 34 | + new_assignment->source_location=first_entry->source_location; |
| 35 | + new_assignment->type=assignment->type; |
| 36 | + new_assignment->code=assignment->code; |
| 37 | + init_body.instructions.erase(assignment); |
| 38 | + init_body.update(); |
| 39 | + entry_body.update(); |
14 | 40 | }
|
15 | 41 |
|
16 | 42 | namespace
|
|
0 commit comments