| 3357 | } |
| 3358 | |
| 3359 | int BfResolvedTypeSet::DoHash(BfType* type, LookupContext* ctx, bool allowRef, int hashSeed) |
| 3360 | { |
| 3361 | //BP_ZONE("BfResolvedTypeSet::Hash"); |
| 3362 | |
| 3363 | // if (type->IsTypeAlias()) |
| 3364 | // { |
| 3365 | // auto underlyingType = type->GetUnderlyingType(); |
| 3366 | // BF_ASSERT(underlyingType != NULL); |
| 3367 | // if (underlyingType == NULL) |
| 3368 | // { |
| 3369 | // ctx->mFailed = true; |
| 3370 | // return 0; |
| 3371 | // } |
| 3372 | // return Hash(underlyingType, ctx, allowRef); |
| 3373 | // } |
| 3374 | // else |
| 3375 | |
| 3376 | if (type->IsBoxed()) |
| 3377 | { |
| 3378 | BfBoxedType* boxedType = (BfBoxedType*)type; |
| 3379 | int elemHash = Hash(boxedType->mElementType, ctx, BfHashFlag_None, hashSeed) ^ HASH_VAL_BOXED; |
| 3380 | return (elemHash << 5) - elemHash; |
| 3381 | } |
| 3382 | else if (type->IsArray()) |
| 3383 | { |
| 3384 | BfArrayType* arrayType = (BfArrayType*)type; |
| 3385 | int elemHash = Hash(arrayType->mGenericTypeInfo->mTypeGenericArguments[0], ctx, BfHashFlag_None, hashSeed) ^ (arrayType->mDimensions << 8); |
| 3386 | return (elemHash << 5) - elemHash; |
| 3387 | } |
| 3388 | else if (type->IsDelegateFromTypeRef() || type->IsFunctionFromTypeRef()) |
| 3389 | { |
| 3390 | auto typeInst = (BfTypeInstance*)type; |
| 3391 | int hashVal = HASH_DELEGATE; |
| 3392 | |
| 3393 | auto delegateInfo = type->GetDelegateInfo(); |
| 3394 | |
| 3395 | hashVal = HASH_MIX(hashVal, Hash(delegateInfo->mReturnType, ctx, BfHashFlag_None, hashSeed + 1)); |
| 3396 | |
| 3397 | auto methodDef = typeInst->mTypeDef->mMethods[0]; |
| 3398 | BF_ASSERT(methodDef->mName == "Invoke"); |
| 3399 | |
| 3400 | int infoParamCount = (int)delegateInfo->mParams.size(); |
| 3401 | if (delegateInfo->mHasVarArgs) |
| 3402 | infoParamCount++; |
| 3403 | |
| 3404 | BF_ASSERT(infoParamCount == methodDef->mParams.size()); |
| 3405 | |
| 3406 | for (int paramIdx = 0; paramIdx < delegateInfo->mParams.size(); paramIdx++) |
| 3407 | { |
| 3408 | // Parse attributes? |
| 3409 | hashVal = HASH_MIX(hashVal, Hash(delegateInfo->mParams[paramIdx], ctx, BfHashFlag_None, hashSeed + 1)); |
| 3410 | String paramName = methodDef->mParams[paramIdx]->mName; |
| 3411 | int nameHash = (int)Hash64(paramName.c_str(), (int)paramName.length()); |
| 3412 | hashVal = HASH_MIX(hashVal, nameHash); |
| 3413 | } |
| 3414 | |
| 3415 | if (delegateInfo->mHasVarArgs) |
| 3416 | hashVal = HASH_MIX(hashVal, HASH_DOTDOTDOT); |
nothing calls this directly
no test coverage detected