1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Expanded const generic params to support structs

This commit is contained in:
Brian Fiete 2024-02-13 06:12:12 -05:00
parent d9de51a019
commit b80db38cdc
13 changed files with 443 additions and 36 deletions

View file

@ -3100,6 +3100,12 @@ BfVariant BfResolvedTypeSet::EvaluateToVariant(LookupContext* ctx, BfExpression*
{
outType = NULL;
BfMethodState methodState;
methodState.mTempKind = BfMethodState::TempKind_Static;
SetAndRestoreValue<BfMethodState*> prevMethodState;
if (ctx->mModule->mCurMethodState == NULL)
prevMethodState.Init(ctx->mModule->mCurMethodState, &methodState);
BfConstResolver constResolver(ctx->mModule);
BfVariant variant;
constResolver.mBfEvalExprFlags = BfEvalExprFlags_NoCast;
@ -3303,7 +3309,8 @@ int BfResolvedTypeSet::DoHash(BfType* type, LookupContext* ctx, bool allowRef, i
else if (type->IsConstExprValue())
{
BfConstExprValueType* constExprValueType = (BfConstExprValueType*)type;
int hashVal = ((int)constExprValueType->mValue.mTypeCode << 17) ^ (constExprValueType->mValue.mInt32 << 3) ^ HASH_CONSTTYPE;
int32 dataHash = BeefHash<BfVariant>()(constExprValueType->mValue);
int hashVal = ((int)constExprValueType->mValue.mTypeCode << 17) ^ (dataHash << 3) ^ HASH_CONSTTYPE;
hashVal = ((hashVal ^ (Hash(constExprValueType->mType, ctx, BfHashFlag_AllowRef, hashSeed))) << 5) - hashVal;
return hashVal;
}
@ -4078,7 +4085,8 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa
return 0;
}
auto hashVal = ((int)result.mTypeCode << 17) ^ (result.mInt32 << 3) ^ HASH_CONSTTYPE;
int32 dataHash = BeefHash<BfVariant>()(result);
auto hashVal = ((int)result.mTypeCode << 17) ^ (dataHash << 3) ^ HASH_CONSTTYPE;
hashVal = ((hashVal ^ (Hash(resultType, ctx, BfHashFlag_AllowRef, hashSeed))) << 5) - hashVal;
return hashVal;
}
@ -4331,7 +4339,7 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfType* rhs, LookupContext* ctx)
BfConstExprValueType* rhsConstExprValueType = (BfConstExprValueType*)rhs;
return (lhsConstExprValueType->mType == rhsConstExprValueType->mType) &&
(lhsConstExprValueType->mValue.mInt64 == rhsConstExprValueType->mValue.mInt64);
(lhsConstExprValueType->mValue == rhsConstExprValueType->mValue);
}
else
{
@ -5032,8 +5040,7 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
return false;
}
return (result.mTypeCode == lhsConstExprType->mValue.mTypeCode) &&
(result.mInt64 == lhsConstExprType->mValue.mInt64);
return result == lhsConstExprType->mValue;
}
else
{