MCPcopy Create free account
hub / github.com/alecazam/kram / MatchFunctionCall

Method MatchFunctionCall

hlslparser/src/HLSLParser.cpp:4469–4567  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4467}
4468
4469const 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

Callers

nothing calls this directly

Calls 8

GetScalarTypeFunction · 0.85
CompareFunctionsFunction · 0.85
String_EqualFunction · 0.85
IsMemberFunctionMethod · 0.80
GetSizeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected