mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Allow type ids in comptype
This commit is contained in:
parent
1b5f85615a
commit
a65b69bcd0
1 changed files with 25 additions and 3 deletions
|
@ -3542,8 +3542,12 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa
|
||||||
|
|
||||||
if (exprModTypeRef->mToken->mToken == BfToken_Comptype)
|
if (exprModTypeRef->mToken->mToken == BfToken_Comptype)
|
||||||
{
|
{
|
||||||
exprFlags = (BfEvalExprFlags)(exprFlags | BfEvalExprFlags_Comptime);
|
auto typeType = ctx->mModule->ResolveTypeDef(ctx->mModule->mCompiler->mTypeTypeDef);
|
||||||
result = ctx->mModule->CreateValueFromExpression(exprModTypeRef->mTarget, ctx->mModule->ResolveTypeDef(ctx->mModule->mCompiler->mTypeTypeDef), exprFlags);
|
exprFlags = (BfEvalExprFlags)(exprFlags | BfEvalExprFlags_Comptime | BfEvalExprFlags_NoCast);
|
||||||
|
result = ctx->mModule->CreateValueFromExpression(exprModTypeRef->mTarget, typeType, exprFlags);
|
||||||
|
if ((result.mType != NULL) && (!result.mType->IsInteger()) && (result.mType != typeType) &&
|
||||||
|
(!result.mType->IsInstanceOf(ctx->mModule->mCompiler->mReflectTypeIdTypeDef)))
|
||||||
|
result = ctx->mModule->Cast(exprModTypeRef->mTarget, result, typeType);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3566,6 +3570,24 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa
|
||||||
ctx->mHadVar = true;
|
ctx->mHadVar = true;
|
||||||
cachedResolvedType = ctx->mModule->GetPrimitiveType(BfTypeCode_Var);
|
cachedResolvedType = ctx->mModule->GetPrimitiveType(BfTypeCode_Var);
|
||||||
}
|
}
|
||||||
|
else if (BfIRConstHolder::IsInt(constant->mTypeCode))
|
||||||
|
{
|
||||||
|
int typeId = constant->mInt32;
|
||||||
|
BfType* type = NULL;
|
||||||
|
if ((typeId >= 0) && (typeId < ctx->mModule->mContext->mTypes.mSize))
|
||||||
|
type = ctx->mModule->mContext->mTypes[typeId];
|
||||||
|
|
||||||
|
if (type != NULL)
|
||||||
|
{
|
||||||
|
cachedResolvedType = type;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctx->mModule->Fail(StrFormat("Invalid type id '%d'", typeId), exprModTypeRef->mTarget);
|
||||||
|
ctx->mHadVar = true;
|
||||||
|
cachedResolvedType = ctx->mModule->GetPrimitiveType(BfTypeCode_Var);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cachedResolvedType == NULL)
|
if (cachedResolvedType == NULL)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue