| 1304 | } |
| 1305 | |
| 1306 | void program::remove_module(const std::string& name) |
| 1307 | { |
| 1308 | // cppcheck-suppress assertWithSideEffect |
| 1309 | assert(is_unused_module(impl->modules, generic_get_modules(this->get_main_module()), name) and |
| 1310 | "Module used in program"); |
| 1311 | assert(std::none_of( |
| 1312 | impl->modules.at(name).begin(), |
| 1313 | impl->modules.at(name).end(), |
| 1314 | [&](auto&& ins) { return references_instruction(impl->modules, ins, name); }) and |
| 1315 | "Instruction referenced in another module"); |
| 1316 | |
| 1317 | // if an instruction has an input out side of the current module, need to remove |
| 1318 | // the instruction from its input's outputs |
| 1319 | auto& mod = impl->modules.at(name); |
| 1320 | for(auto ins : iterator_for(mod)) |
| 1321 | { |
| 1322 | auto inputs = ins->inputs(); |
| 1323 | for(auto in : inputs) |
| 1324 | { |
| 1325 | if(not mod.has_instruction(in)) |
| 1326 | { |
| 1327 | in->remove_output(ins); |
| 1328 | } |
| 1329 | } |
| 1330 | } |
| 1331 | |
| 1332 | impl->modules.erase(name); |
| 1333 | } |
| 1334 | |
| 1335 | void program::rename_module(const std::string& old_name, const std::string& new_name) |
| 1336 | { |
no test coverage detected