| 428 | } |
| 429 | |
| 430 | void GraphFunction::renameLocalVariable(std::string oldName, std::string newName) { |
| 431 | // invalidate the cache |
| 432 | module().updateLastEditTime(); |
| 433 | |
| 434 | bool setanything = false; |
| 435 | for (auto& var : mLocalVariables) { |
| 436 | if (var.name == oldName) { |
| 437 | var.name = newName; |
| 438 | |
| 439 | setanything = true; |
| 440 | break; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | // if it wans't found, then we don't have to update |
| 445 | if (!setanything) { return; } |
| 446 | |
| 447 | // update existing nodes |
| 448 | auto setNodes = nodesWithType(module().fullName(), "_set_" + oldName); |
| 449 | for (const auto& node : setNodes) { |
| 450 | // create a new node type |
| 451 | std::unique_ptr<NodeType> ty; |
| 452 | |
| 453 | auto res = module().nodeTypeFromName("_set_" + newName, node->type().toJSON(), &ty); |
| 454 | assert(!!res); |
| 455 | |
| 456 | node->setType(std::move(ty)); |
| 457 | } |
| 458 | |
| 459 | auto getNodes = nodesWithType(module().fullName(), "_get_" + oldName); |
| 460 | for (const auto& node : getNodes) { |
| 461 | // create a new node type |
| 462 | std::unique_ptr<NodeType> ty; |
| 463 | |
| 464 | auto res = module().nodeTypeFromName("_get_" + newName, node->type().toJSON(), &ty); |
| 465 | assert(!!res); |
| 466 | |
| 467 | node->setType(std::move(ty)); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | void GraphFunction::retypeLocalVariable(boost::string_view name, DataType newType) { |
| 472 | // invalidate the cache |
no test coverage detected