goto_programt::targett cegis_assign(const symbol_tablet &st, goto_functionst &gf, const goto_programt::targett &insert_after_pos, const exprt &lhs, const exprt &rhs) { return cegis_assign(st, gf, insert_after_pos, lhs, rhs, default_cegis_source_location()); }
const symbolt &declare_global_meta_variable(symbol_tablet &st, goto_functionst &gf, const std::string &name, const exprt &value) { const symbolt &symbol=declare_global_meta_variable(st, name, value.type()); goto_programt &init_body=get_body(gf, CPROVER_INIT); goto_programt::instructionst &instrs=init_body.instructions; goto_programt::targett pos=instrs.begin(); if (instrs.size() >= 2) pos=std::prev(init_body.instructions.end(), 2); const symbol_exprt lhs(symbol.symbol_expr()); cegis_assign(st, init_body, pos, lhs, value, default_cegis_source_location()); return symbol; }
const symbolt &declare_global_meta_variable(symbol_tablet &st, const std::string &name, const typet &type) { symbolt new_symbol; new_symbol.name=name; new_symbol.type=type; new_symbol.base_name=name; new_symbol.pretty_name=name; new_symbol.location=default_cegis_source_location(); new_symbol.mode=ID_C; new_symbol.module=CEGIS_MODULE; new_symbol.is_lvalue=true; new_symbol.is_static_lifetime=true; new_symbol.is_state_var=true; assert(!st.add(new_symbol)); return st.lookup(name); }
symbolt &create_local_cegis_symbol(symbol_tablet &st, const std::string &full_name, const std::string &base_name, const typet &type) { symbolt new_symbol; new_symbol.name=full_name; new_symbol.type=type; new_symbol.base_name=base_name; new_symbol.pretty_name=base_name; new_symbol.location=default_cegis_source_location(); new_symbol.mode=ID_C; new_symbol.module=CEGIS_MODULE; new_symbol.is_thread_local=true; new_symbol.is_static_lifetime=false; new_symbol.is_file_local=true; new_symbol.is_lvalue=true; assert(!st.add(new_symbol)); return st.lookup(new_symbol.name); }
void execute_inv_prog(const symbol_tablet &st, goto_functionst &gf, const size_t max_solution_size, const goto_programt::targett &decl, const std::string &prog_base_name) { goto_programt &body=get_entry_body(gf); goto_programt::targett pos=decl; goto_programt::targett execution=body.insert_after(++pos); execution->type=goto_program_instruction_typet::FUNCTION_CALL; execution->source_location=default_cegis_source_location(); code_function_callt call; call.function()=st.lookup(DANGER_EXECUTE).symbol_expr(); const std::string prog_name(get_cegis_meta_name(prog_base_name)); const symbol_exprt prog_symbol(st.lookup(prog_name).symbol_expr()); const typet size_type(unsigned_int_type()); const constant_exprt index(from_integer(0u, size_type)); const index_exprt first_elem(prog_symbol, index); call.arguments().push_back(address_of_exprt(first_elem)); const constant_exprt size(from_integer(max_solution_size, size_type)); call.arguments().push_back(size); execution->code=call; }