MCPcopy Create free account
hub / github.com/WheretIB/nullc / GetGenericFunctionRating

Function GetGenericFunctionRating

NULLC/Callbacks.cpp:3449–3614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3447}
3448
3449TypeInfo* GetGenericFunctionRating(FunctionInfo *fInfo, unsigned &newRating, unsigned count)
3450{
3451 // There could be function calls in constrain expression, so we backup current function and rating list
3452 unsigned prevBackupSize = bestFuncListBackup.size();
3453 bestFuncListBackup.push_back(&bestFuncList[0], count);
3454 bestFuncRatingBackup.push_back(&bestFuncRating[0], count);
3455
3456 // Out function
3457 unsigned argumentCount = fInfo->paramCount;
3458
3459 Lexeme *start = CodeInfo::lexStart + fInfo->generic->start;
3460
3461 // Save current type
3462 TypeInfo *lastType = currType;
3463
3464 // Add aliases from member function parent type if it has one
3465 if(fInfo->generic->parent->parentClass)
3466 {
3467 AliasInfo *baseClassAlias = fInfo->generic->parent->parentClass->childAlias;
3468 while(baseClassAlias)
3469 {
3470 CodeInfo::classMap.insert(baseClassAlias->nameHash, baseClassAlias->type);
3471 baseClassAlias = baseClassAlias->next;
3472 }
3473 }
3474 // Reset function alias list
3475 fInfo->childAlias = NULL;
3476
3477 // apply resolved argument types and test if it is ok
3478 unsigned nodeOffset = CodeInfo::nodeList.size() - argumentCount;
3479 // Move through all the arguments
3480 VariableInfo *tempListS = NULL, *tempListE = NULL;
3481 Lexeme *prevArg = NULL; // previous argument type position
3482 for(unsigned argID = 0; argID < argumentCount; argID++)
3483 {
3484 if(argID)
3485 {
3486 assert(start->type == lex_comma);
3487 start++;
3488 }
3489
3490 // Get type to which we resolve our generic argument
3491 SelectTypeForGeneric(nodeOffset + argID);
3492 TypeInfo *referenceType = currType;
3493 // If it's not possible to select a function overload
3494 if(currType == typeVoid && CodeInfo::nodeList[nodeOffset + argID]->nodeType == typeNodeFunctionProxy)
3495 {
3496 newRating = ~0u; // function is not instanced
3497 return NULL;
3498 }
3499 // Flag of instantiation failure
3500 bool instanceFailure = false;
3501 // Set generic function as being in definition so that type aliases will get into functions alias list and will not spill to outer scope
3502 currDefinedFunc.push_back(fInfo);
3503 Lexeme *oldStart = start;
3504 // Try to reparse the type
3505 if(!ParseSelectType(&start, true, true, false, true, referenceType, &instanceFailure))
3506 {

Callers 1

SelectBestFunctionFunction · 0.85

Calls 15

assertFunction · 0.85
SelectTypeForGenericFunction · 0.85
ParseSelectTypeFunction · 0.85
ThrowErrorFunction · 0.85
InplaceStrClass · 0.85
ParseTernaryExprFunction · 0.85
GetFunctionTypeFunction · 0.85
GetFunctionRatingFunction · 0.85
insertMethod · 0.80
GetFullTypeNameMethod · 0.80
removeMethod · 0.80
GetStringHashFunction · 0.70

Tested by

no test coverage detected