mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixing reification of attributes
This commit is contained in:
parent
14ad1b72fc
commit
622b832858
3 changed files with 28 additions and 19 deletions
|
@ -9791,7 +9791,7 @@ void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttri
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfType* attrType = ResolveTypeRef(attributesDirective->mAttributeTypeRef, BfPopulateType_Identity, BfResolveTypeRefFlag_Attribute);
|
BfType* attrType = ResolveTypeRef(attributesDirective->mAttributeTypeRef, BfPopulateType_Identity, (BfResolveTypeRefFlags)(BfResolveTypeRefFlag_Attribute | BfResolveTypeRefFlag_NoReify));
|
||||||
BfTypeDef* attrTypeDef = NULL;
|
BfTypeDef* attrTypeDef = NULL;
|
||||||
if ((attrType != NULL) && (attrType->IsTypeInstance()))
|
if ((attrType != NULL) && (attrType->IsTypeInstance()))
|
||||||
attrTypeDef = attrType->ToTypeInstance()->mTypeDef;
|
attrTypeDef = attrType->ToTypeInstance()->mTypeDef;
|
||||||
|
|
|
@ -1276,7 +1276,8 @@ enum BfResolveTypeRefFlags
|
||||||
BfResolveTypeRefFlag_AllowGenericParamConstValue = 0x10 | 0x20,
|
BfResolveTypeRefFlag_AllowGenericParamConstValue = 0x10 | 0x20,
|
||||||
BfResolveTypeRefFlag_AutoComplete = 0x40,
|
BfResolveTypeRefFlag_AutoComplete = 0x40,
|
||||||
BfResolveTypeRefFlag_FromIndirectSource = 0x80, // Such as a type alias or a generic parameter
|
BfResolveTypeRefFlag_FromIndirectSource = 0x80, // Such as a type alias or a generic parameter
|
||||||
BfResolveTypeRefFlag_Attribute = 0x100
|
BfResolveTypeRefFlag_Attribute = 0x100,
|
||||||
|
BfResolveTypeRefFlag_NoReify = 0x200
|
||||||
};
|
};
|
||||||
|
|
||||||
enum BfSrcPosFlags
|
enum BfSrcPosFlags
|
||||||
|
|
|
@ -786,7 +786,7 @@ bool BfModule::PopulateType(BfType* resolvedTypeRef, BfPopulateType populateType
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Are we "demanding" to reify a type that is currently resolve-only?
|
// Are we "demanding" to reify a type that is currently resolve-only?
|
||||||
if (mIsReified)
|
if ((mIsReified) && (populateType >= BfPopulateType_Declaration))
|
||||||
{
|
{
|
||||||
if (resolvedTypeRef->IsTypeInstance())
|
if (resolvedTypeRef->IsTypeInstance())
|
||||||
{
|
{
|
||||||
|
@ -6103,9 +6103,13 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
||||||
|
|
||||||
BfTypeInstance* typeInstance = resolvedTypeRef->ToTypeInstance();
|
BfTypeInstance* typeInstance = resolvedTypeRef->ToTypeInstance();
|
||||||
BfGenericTypeInstance* genericTypeInstance = resolvedTypeRef->ToGenericTypeInstance();
|
BfGenericTypeInstance* genericTypeInstance = resolvedTypeRef->ToGenericTypeInstance();
|
||||||
|
|
||||||
|
auto populateModule = this;
|
||||||
|
if ((resolveFlags & BfResolveTypeRefFlag_NoReify) != 0)
|
||||||
|
populateModule = mContext->mUnreifiedModule;
|
||||||
|
|
||||||
bool hadError = false;
|
bool hadError = false;
|
||||||
hadError = !PopulateType(resolvedTypeRef, populateType);
|
hadError = !populateModule->PopulateType(resolvedTypeRef, populateType);
|
||||||
|
|
||||||
if ((genericTypeInstance != NULL) && (genericTypeInstance != mCurTypeInstance) && (populateType > BfPopulateType_Identity))
|
if ((genericTypeInstance != NULL) && (genericTypeInstance != mCurTypeInstance) && (populateType > BfPopulateType_Identity))
|
||||||
{
|
{
|
||||||
|
@ -7369,6 +7373,10 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
return ResolveTypeResult(typeRef, resolvedEntry->mValue, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, resolvedEntry->mValue, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BfModule* populateModule = this;
|
||||||
|
if ((resolveFlags & BfResolveTypeRefFlag_NoReify) != 0)
|
||||||
|
populateModule = mContext->mUnreifiedModule;
|
||||||
|
|
||||||
if (typeRef->IsTypeDefTypeReference())
|
if (typeRef->IsTypeDefTypeReference())
|
||||||
{
|
{
|
||||||
//BF_ASSERT(typeDefTypeRef->mTypeDef != NULL); // Resolved higher up
|
//BF_ASSERT(typeDefTypeRef->mTypeDef != NULL); // Resolved higher up
|
||||||
|
@ -7379,7 +7387,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
primType->mTypeDef = typeDef;
|
primType->mTypeDef = typeDef;
|
||||||
resolvedEntry->mValue = primType;
|
resolvedEntry->mValue = primType;
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(primType, &lookupCtx, false) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(primType, &lookupCtx, false) == resolvedEntry->mHash);
|
||||||
InitType(primType, populateType);
|
populateModule->InitType(primType, populateType);
|
||||||
return ResolveTypeResult(typeRef, primType, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, primType, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7431,7 +7439,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
|
|
||||||
resolvedEntry->mValue = genericTypeInst;
|
resolvedEntry->mValue = genericTypeInst;
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(genericTypeInst, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(genericTypeInst, &lookupCtx) == resolvedEntry->mHash);
|
||||||
InitType(genericTypeInst, populateType);
|
populateModule->InitType(genericTypeInst, populateType);
|
||||||
return ResolveTypeResult(typeRef, genericTypeInst, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, genericTypeInst, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7457,7 +7465,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
}
|
}
|
||||||
resolvedEntry->mValue = typeInst;
|
resolvedEntry->mValue = typeInst;
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(typeInst, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(typeInst, &lookupCtx) == resolvedEntry->mHash);
|
||||||
InitType(typeInst, populateType);
|
populateModule->InitType(typeInst, populateType);
|
||||||
return ResolveTypeResult(typeRef, typeInst, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, typeInst, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
else if (auto arrayTypeRef = BfNodeDynCast<BfArrayTypeRef>(typeRef))
|
else if (auto arrayTypeRef = BfNodeDynCast<BfArrayTypeRef>(typeRef))
|
||||||
|
@ -7502,7 +7510,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
resolvedEntry->mValue = arrayType;
|
resolvedEntry->mValue = arrayType;
|
||||||
|
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(arrayType, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(arrayType, &lookupCtx) == resolvedEntry->mHash);
|
||||||
InitType(arrayType, populateType);
|
populateModule->InitType(arrayType, populateType);
|
||||||
return ResolveTypeResult(typeRef, arrayType, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, arrayType, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7535,7 +7543,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
resolvedEntry->mValue = arrayType;
|
resolvedEntry->mValue = arrayType;
|
||||||
|
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(arrayType, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(arrayType, &lookupCtx) == resolvedEntry->mHash);
|
||||||
InitType(arrayType, populateType);
|
populateModule->InitType(arrayType, populateType);
|
||||||
return ResolveTypeResult(typeRef, arrayType, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, arrayType, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7549,7 +7557,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
CheckUnspecializedGenericType(arrayType, populateType);
|
CheckUnspecializedGenericType(arrayType, populateType);
|
||||||
|
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(arrayType, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(arrayType, &lookupCtx) == resolvedEntry->mHash);
|
||||||
InitType(arrayType, populateType);
|
populateModule->InitType(arrayType, populateType);
|
||||||
return ResolveTypeResult(typeRef, arrayType, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, arrayType, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
else if (auto genericTypeInstRef = BfNodeDynCast<BfGenericInstanceTypeRef>(typeRef))
|
else if (auto genericTypeInstRef = BfNodeDynCast<BfGenericInstanceTypeRef>(typeRef))
|
||||||
|
@ -7668,7 +7676,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
CheckUnspecializedGenericType(genericTypeInst, populateType);
|
CheckUnspecializedGenericType(genericTypeInst, populateType);
|
||||||
|
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(genericTypeInst, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(genericTypeInst, &lookupCtx) == resolvedEntry->mHash);
|
||||||
InitType(genericTypeInst, populateType);
|
populateModule->InitType(genericTypeInst, populateType);
|
||||||
return ResolveTypeResult(typeRef, genericTypeInst, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, genericTypeInst, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
else if (auto tupleTypeRef = BfNodeDynCast<BfTupleTypeRef>(typeRef))
|
else if (auto tupleTypeRef = BfNodeDynCast<BfTupleTypeRef>(typeRef))
|
||||||
|
@ -7723,7 +7731,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
|
|
||||||
resolvedEntry->mValue = tupleType;
|
resolvedEntry->mValue = tupleType;
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(tupleType, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(tupleType, &lookupCtx) == resolvedEntry->mHash);
|
||||||
InitType(tupleType, populateType);
|
populateModule->InitType(tupleType, populateType);
|
||||||
return ResolveTypeResult(typeRef, tupleType, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, tupleType, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
else if (auto nullableTypeRef = BfNodeDynCast<BfNullableTypeRef>(typeRef))
|
else if (auto nullableTypeRef = BfNodeDynCast<BfNullableTypeRef>(typeRef))
|
||||||
|
@ -7751,7 +7759,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
|
|
||||||
resolvedEntry->mValue = genericTypeInst;
|
resolvedEntry->mValue = genericTypeInst;
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(genericTypeInst, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(genericTypeInst, &lookupCtx) == resolvedEntry->mHash);
|
||||||
InitType(genericTypeInst, populateType);
|
populateModule->InitType(genericTypeInst, populateType);
|
||||||
return ResolveTypeResult(typeRef, genericTypeInst, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, genericTypeInst, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
else if (auto pointerTypeRef = BfNodeDynCast<BfPointerTypeRef>(typeRef))
|
else if (auto pointerTypeRef = BfNodeDynCast<BfPointerTypeRef>(typeRef))
|
||||||
|
@ -7771,7 +7779,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
//int hashVal = mContext->mResolvedTypes.Hash(typeRef, &lookupCtx);
|
//int hashVal = mContext->mResolvedTypes.Hash(typeRef, &lookupCtx);
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(pointerType, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(pointerType, &lookupCtx) == resolvedEntry->mHash);
|
||||||
|
|
||||||
InitType(pointerType, populateType);
|
populateModule->InitType(pointerType, populateType);
|
||||||
return ResolveTypeResult(typeRef, pointerType, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, pointerType, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
else if (auto refTypeRef = BfNodeDynCast<BfRefTypeRef>(typeRef))
|
else if (auto refTypeRef = BfNodeDynCast<BfRefTypeRef>(typeRef))
|
||||||
|
@ -7794,7 +7802,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
|
|
||||||
resolvedEntry->mValue = refType;
|
resolvedEntry->mValue = refType;
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(refType, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(refType, &lookupCtx) == resolvedEntry->mHash);
|
||||||
InitType(refType, populateType);
|
populateModule->InitType(refType, populateType);
|
||||||
return ResolveTypeResult(typeRef, refType, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, refType, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
else if (auto delegateTypeRef = BfNodeDynCast<BfDelegateTypeRef>(typeRef))
|
else if (auto delegateTypeRef = BfNodeDynCast<BfDelegateTypeRef>(typeRef))
|
||||||
|
@ -7898,7 +7906,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
|
|
||||||
delegateType->mContext = mContext;
|
delegateType->mContext = mContext;
|
||||||
delegateType->mTypeDef = typeDef;
|
delegateType->mTypeDef = typeDef;
|
||||||
InitType(delegateType, populateType);
|
populateModule->InitType(delegateType, populateType);
|
||||||
resolvedEntry->mValue = delegateType;
|
resolvedEntry->mValue = delegateType;
|
||||||
|
|
||||||
// #ifdef _DEBUG
|
// #ifdef _DEBUG
|
||||||
|
@ -7931,7 +7939,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
resolvedEntry->mValue = retTypeType;
|
resolvedEntry->mValue = retTypeType;
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(retTypeType, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(retTypeType, &lookupCtx) == resolvedEntry->mHash);
|
||||||
|
|
||||||
InitType(retTypeType, populateType);
|
populateModule->InitType(retTypeType, populateType);
|
||||||
return ResolveTypeResult(typeRef, retTypeType, populateType, resolveFlags);
|
return ResolveTypeResult(typeRef, retTypeType, populateType, resolveFlags);
|
||||||
}
|
}
|
||||||
else if (auto qualifiedTypeRef = BfNodeDynCast<BfQualifiedTypeReference>(typeRef))
|
else if (auto qualifiedTypeRef = BfNodeDynCast<BfQualifiedTypeReference>(typeRef))
|
||||||
|
@ -7964,7 +7972,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
resolvedEntry->mValue = constExprType;
|
resolvedEntry->mValue = constExprType;
|
||||||
BF_ASSERT(BfResolvedTypeSet::Hash(constExprType, &lookupCtx) == resolvedEntry->mHash);
|
BF_ASSERT(BfResolvedTypeSet::Hash(constExprType, &lookupCtx) == resolvedEntry->mHash);
|
||||||
|
|
||||||
InitType(constExprType, populateType);
|
populateModule->InitType(constExprType, populateType);
|
||||||
return constExprType;
|
return constExprType;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue