MCPcopy Create free account
hub / github.com/chigraph/chigraph / retypeLocalVariable

Method retypeLocalVariable

libchigraph/src/GraphFunction.cpp:471–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471void GraphFunction::retypeLocalVariable(boost::string_view name, DataType newType) {
472 // invalidate the cache
473 module().updateLastEditTime();
474
475 std::string qualifiedName = newType.qualifiedName();
476
477 for (auto& var : mLocalVariables) {
478 if (var.name == name) {
479 var.type = std::move(newType);
480 break;
481 }
482 }
483
484 // update existing nodes
485 auto setNodes = nodesWithType(module().fullName(), "_set_" + name.to_string());
486 for (const auto& node : setNodes) {
487 // create a new node type
488 std::unique_ptr<NodeType> ty;
489
490 auto res = module().nodeTypeFromName("_set_" + name.to_string(), qualifiedName, &ty);
491 assert(!!res);
492
493 node->setType(std::move(ty));
494 }
495
496 auto getNodes = nodesWithType(module().fullName(), "_get_" + name.to_string());
497 for (const auto& node : getNodes) {
498 // create a new node type
499 std::unique_ptr<NodeType> ty;
500
501 auto res = module().nodeTypeFromName("_get_" + name.to_string(), qualifiedName, &ty);
502 assert(!!res);
503
504 node->setType(std::move(ty));
505 }
506}
507
508std::vector<NodeInstance*> GraphFunction::setName(boost::string_view newName,
509 bool updateReferences) {

Callers 1

Calls 6

updateLastEditTimeMethod · 0.80
fullNameMethod · 0.80
to_stringMethod · 0.80
setTypeMethod · 0.80
qualifiedNameMethod · 0.45
nodeTypeFromNameMethod · 0.45

Tested by

no test coverage detected