| 329 | } |
| 330 | |
| 331 | std::pair<UHDM::task_func *, DesignComponent *> CompileHelper::getTaskFunc( |
| 332 | std::string_view name, DesignComponent *component, |
| 333 | CompileDesign *compileDesign, ValuedComponentI *instance, any *pexpr) { |
| 334 | std::pair<UHDM::task_func *, DesignComponent *> result = {nullptr, nullptr}; |
| 335 | DesignComponent *comp = component; |
| 336 | if (name.find("::") != std::string::npos) { |
| 337 | std::vector<std::string_view> res; |
| 338 | StringUtils::tokenizeMulti(name, "::", res); |
| 339 | if (res.size() > 1) { |
| 340 | const std::string_view packName = res[0]; |
| 341 | const std::string_view funcName = res[1]; |
| 342 | Design *design = compileDesign->getCompiler()->getDesign(); |
| 343 | if (Package *pack = design->getPackage(packName)) { |
| 344 | if (pack->getTask_funcs()) { |
| 345 | for (UHDM::task_func *tf : *pack->getTask_funcs()) { |
| 346 | if (tf->VpiName() == funcName) { |
| 347 | result = std::make_pair(tf, pack); |
| 348 | return result; |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | while (comp) { |
| 356 | if (comp->getTask_funcs()) { |
| 357 | for (UHDM::task_func *tf : *comp->getTask_funcs()) { |
| 358 | if (tf->VpiName() == name) { |
| 359 | result = std::make_pair(tf, component); |
| 360 | return result; |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | comp = valuedcomponenti_cast<DesignComponent *>( |
| 365 | (DesignComponent *)comp->getParentScope()); |
| 366 | } |
| 367 | if (component) { |
| 368 | for (const FileContent *cfC : component->getFileContents()) { |
| 369 | FileContent *fC = (FileContent *)cfC; |
| 370 | if (fC->getTask_funcs()) { |
| 371 | for (UHDM::task_func *tf : *fC->getTask_funcs()) { |
| 372 | if (tf->VpiName() == name) { |
| 373 | result = std::make_pair(tf, component); |
| 374 | return result; |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | if (component) { |
| 381 | std::set<DesignComponent *> visited; |
| 382 | task_func *res = getFuncFromPackage(name, component, visited); |
| 383 | if (res) { |
| 384 | result = std::make_pair(res, component); |
| 385 | return result; |
| 386 | } |
| 387 | } |
| 388 | if (instance) { |
no test coverage detected