| 4467 | } |
| 4468 | |
| 4469 | const HLSLFunction* HLSLParser::MatchFunctionCall(const HLSLFunctionCall* functionCall, const char* name, const HLSLType* memberType) |
| 4470 | { |
| 4471 | const HLSLFunction* matchedFunction = NULL; |
| 4472 | |
| 4473 | //int numArguments = functionCall->numArguments; |
| 4474 | int numMatchedOverloads = 0; |
| 4475 | bool nameMatches = false; |
| 4476 | |
| 4477 | // Get the user defined c functions with the specified name. |
| 4478 | // There may be more than one, and these are not ordered. |
| 4479 | for (int i = 0; i < m_functions.GetSize(); ++i) { |
| 4480 | const HLSLFunction* function = m_functions[i]; |
| 4481 | if (function->name == name) { |
| 4482 | nameMatches = true; |
| 4483 | |
| 4484 | // if caller requests member function, then memberType must match |
| 4485 | bool isMemberFunc = function->IsMemberFunction(); |
| 4486 | |
| 4487 | if (memberType) { |
| 4488 | if (!isMemberFunc) |
| 4489 | continue; |
| 4490 | |
| 4491 | if (memberType->baseType != function->memberType) |
| 4492 | continue; |
| 4493 | |
| 4494 | if (memberType->formatType != GetScalarType(function->returnType.baseType)) |
| 4495 | continue; |
| 4496 | } |
| 4497 | else { |
| 4498 | if (isMemberFunc) |
| 4499 | continue; |
| 4500 | } |
| 4501 | |
| 4502 | CompareFunctionsResult result = CompareFunctions(m_tree, functionCall, function, matchedFunction); |
| 4503 | if (result == Function1Better) { |
| 4504 | matchedFunction = function; |
| 4505 | numMatchedOverloads = 1; |
| 4506 | } |
| 4507 | else if (result == FunctionsEqual) { |
| 4508 | ++numMatchedOverloads; |
| 4509 | } |
| 4510 | } |
| 4511 | } |
| 4512 | |
| 4513 | // Get the intrinsic functions with the specified name. |
| 4514 | const auto& iter = _intrinsicRangeMap.find(name); |
| 4515 | if (iter != _intrinsicRangeMap.end()) { |
| 4516 | Range range = iter->second; |
| 4517 | for (int i = 0; i < range.count; ++i) { |
| 4518 | uint32_t idx = range.start + i; |
| 4519 | const HLSLFunction* function = &_intrinsics[idx].function; |
| 4520 | |
| 4521 | // if caller requests member function, then memberType must match |
| 4522 | bool isMemberFunc = function->IsMemberFunction(); |
| 4523 | if (memberType) { |
| 4524 | if (!isMemberFunc) |
| 4525 | break; |
| 4526 |
nothing calls this directly
no test coverage detected