mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed internal access in type aliases
This commit is contained in:
parent
3a87b926b3
commit
b048cafcfd
2 changed files with 103 additions and 89 deletions
|
@ -2589,6 +2589,13 @@ void BfModule::DoPopulateType_TypeAlias(BfTypeInstance* typeAlias)
|
|||
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeAlias);
|
||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
||||
SetAndRestoreValue<BfMethodState*> prevMethodState(mCurMethodState, NULL);
|
||||
|
||||
if (typeAlias->mDefineState < BfTypeDefineState_Declaring)
|
||||
{
|
||||
typeAlias->mDefineState = BfTypeDefineState_Declaring;
|
||||
DoPopulateType_InitSearches(typeAlias);
|
||||
}
|
||||
|
||||
BF_ASSERT(mCurMethodInstance == NULL);
|
||||
auto typeDef = typeAlias->mTypeDef;
|
||||
auto typeAliasDecl = (BfTypeAliasDeclaration*)typeDef->mTypeDeclaration;
|
||||
|
@ -2666,6 +2673,99 @@ void BfModule::DoPopulateType_TypeAlias(BfTypeInstance* typeAlias)
|
|||
}
|
||||
}
|
||||
|
||||
void BfModule::DoPopulateType_InitSearches(BfTypeInstance* typeInstance)
|
||||
{
|
||||
auto typeDef = typeInstance->mTypeDef;
|
||||
|
||||
if (typeInstance->IsGenericTypeInstance())
|
||||
{
|
||||
DoPopulateType_SetGenericDependencies(typeInstance);
|
||||
}
|
||||
|
||||
auto _AddStaticSearch = [&](BfTypeDef* typeDef)
|
||||
{
|
||||
if (!typeDef->mStaticSearch.IsEmpty())
|
||||
{
|
||||
BfStaticSearch* staticSearch;
|
||||
if (typeInstance->mStaticSearchMap.TryAdd(typeDef, NULL, &staticSearch))
|
||||
{
|
||||
SetAndRestoreValue<BfTypeDef*> prevTypeDef(mContext->mCurTypeState->mCurTypeDef, typeDef);
|
||||
for (auto typeRef : typeDef->mStaticSearch)
|
||||
{
|
||||
auto staticType = ResolveTypeRef(typeRef, NULL, BfPopulateType_Identity);
|
||||
if (staticType != NULL)
|
||||
{
|
||||
auto staticTypeInst = staticType->ToTypeInstance();
|
||||
if (staticTypeInst == NULL)
|
||||
{
|
||||
Fail(StrFormat("Type '%s' cannot be used in a 'using static' declaration", TypeToString(staticType).c_str()), typeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
staticSearch->mStaticTypes.Add(staticTypeInst);
|
||||
AddDependency(staticTypeInst, typeInstance, BfDependencyMap::DependencyFlag_StaticValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!typeDef->mInternalAccessSet.IsEmpty())
|
||||
{
|
||||
BfInternalAccessSet* internalAccessSet;
|
||||
BF_ASSERT(!typeDef->IsEmitted());
|
||||
if (typeInstance->mInternalAccessMap.TryAdd(typeDef, NULL, &internalAccessSet))
|
||||
{
|
||||
for (auto typeRef : typeDef->mInternalAccessSet)
|
||||
{
|
||||
if ((typeRef->IsA<BfNamedTypeReference>()) ||
|
||||
(typeRef->IsA<BfQualifiedTypeReference>()))
|
||||
{
|
||||
String checkNamespaceStr;
|
||||
typeRef->ToString(checkNamespaceStr);
|
||||
BfAtomComposite checkNamespace;
|
||||
if (mSystem->ParseAtomComposite(checkNamespaceStr, checkNamespace))
|
||||
{
|
||||
if (mSystem->ContainsNamespace(checkNamespace, typeDef->mProject))
|
||||
{
|
||||
mSystem->RefAtomComposite(checkNamespace);
|
||||
internalAccessSet->mNamespaces.Add(checkNamespace);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BfType* internalType = NULL;
|
||||
if (auto genericTypeRef = BfNodeDynCast<BfGenericInstanceTypeRef>(typeRef))
|
||||
internalType = mContext->mScratchModule->ResolveTypeRefAllowUnboundGenerics(typeRef, BfPopulateType_Identity);
|
||||
else
|
||||
internalType = ResolveTypeRef(typeRef, NULL, BfPopulateType_Identity);
|
||||
if (internalType != NULL)
|
||||
{
|
||||
auto internalTypeInst = internalType->ToTypeInstance();
|
||||
if (internalTypeInst == NULL)
|
||||
{
|
||||
Fail(StrFormat("Type '%s' cannot be used in a 'using internal' declaration", TypeToString(internalType).c_str()), typeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
internalAccessSet->mTypes.Add(internalTypeInst);
|
||||
AddDependency(internalTypeInst, typeInstance, BfDependencyMap::DependencyFlag_StaticValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (typeDef->mIsCombinedPartial)
|
||||
{
|
||||
for (auto partialTypeDef : typeDef->mPartials)
|
||||
_AddStaticSearch(partialTypeDef);
|
||||
}
|
||||
else
|
||||
_AddStaticSearch(typeDef);
|
||||
}
|
||||
|
||||
void BfModule::DoPopulateType_FinishEnum(BfTypeInstance* typeInstance, bool underlyingTypeDeferred, HashContext* dataMemberHashCtx, BfType* unionInnerType)
|
||||
{
|
||||
if (typeInstance->IsEnum())
|
||||
|
@ -2966,94 +3066,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
if (typeInstance->mDefineState < BfTypeDefineState_Declaring)
|
||||
{
|
||||
typeInstance->mDefineState = BfTypeDefineState_Declaring;
|
||||
|
||||
if (typeInstance->IsGenericTypeInstance())
|
||||
{
|
||||
DoPopulateType_SetGenericDependencies(typeInstance);
|
||||
}
|
||||
|
||||
auto _AddStaticSearch = [&](BfTypeDef* typeDef)
|
||||
{
|
||||
if (!typeDef->mStaticSearch.IsEmpty())
|
||||
{
|
||||
BfStaticSearch* staticSearch;
|
||||
if (typeInstance->mStaticSearchMap.TryAdd(typeDef, NULL, &staticSearch))
|
||||
{
|
||||
SetAndRestoreValue<BfTypeDef*> prevTypeDef(mContext->mCurTypeState->mCurTypeDef, typeDef);
|
||||
for (auto typeRef : typeDef->mStaticSearch)
|
||||
{
|
||||
auto staticType = ResolveTypeRef(typeRef, NULL, BfPopulateType_Identity);
|
||||
if (staticType != NULL)
|
||||
{
|
||||
auto staticTypeInst = staticType->ToTypeInstance();
|
||||
if (staticTypeInst == NULL)
|
||||
{
|
||||
Fail(StrFormat("Type '%s' cannot be used in a 'using static' declaration", TypeToString(staticType).c_str()), typeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
staticSearch->mStaticTypes.Add(staticTypeInst);
|
||||
AddDependency(staticTypeInst, typeInstance, BfDependencyMap::DependencyFlag_StaticValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!typeDef->mInternalAccessSet.IsEmpty())
|
||||
{
|
||||
BfInternalAccessSet* internalAccessSet;
|
||||
BF_ASSERT(!typeDef->IsEmitted());
|
||||
if (typeInstance->mInternalAccessMap.TryAdd(typeDef, NULL, &internalAccessSet))
|
||||
{
|
||||
for (auto typeRef : typeDef->mInternalAccessSet)
|
||||
{
|
||||
if ((typeRef->IsA<BfNamedTypeReference>()) ||
|
||||
(typeRef->IsA<BfQualifiedTypeReference>()))
|
||||
{
|
||||
String checkNamespaceStr;
|
||||
typeRef->ToString(checkNamespaceStr);
|
||||
BfAtomComposite checkNamespace;
|
||||
if (mSystem->ParseAtomComposite(checkNamespaceStr, checkNamespace))
|
||||
{
|
||||
if (mSystem->ContainsNamespace(checkNamespace, typeDef->mProject))
|
||||
{
|
||||
mSystem->RefAtomComposite(checkNamespace);
|
||||
internalAccessSet->mNamespaces.Add(checkNamespace);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BfType* internalType = NULL;
|
||||
if (auto genericTypeRef = BfNodeDynCast<BfGenericInstanceTypeRef>(typeRef))
|
||||
internalType = mContext->mScratchModule->ResolveTypeRefAllowUnboundGenerics(typeRef, BfPopulateType_Identity);
|
||||
else
|
||||
internalType = ResolveTypeRef(typeRef, NULL, BfPopulateType_Identity);
|
||||
if (internalType != NULL)
|
||||
{
|
||||
auto internalTypeInst = internalType->ToTypeInstance();
|
||||
if (internalTypeInst == NULL)
|
||||
{
|
||||
Fail(StrFormat("Type '%s' cannot be used in a 'using internal' declaration", TypeToString(internalType).c_str()), typeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
internalAccessSet->mTypes.Add(internalTypeInst);
|
||||
AddDependency(internalTypeInst, typeInstance, BfDependencyMap::DependencyFlag_StaticValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (typeDef->mIsCombinedPartial)
|
||||
{
|
||||
for (auto partialTypeDef : typeDef->mPartials)
|
||||
_AddStaticSearch(partialTypeDef);
|
||||
}
|
||||
else
|
||||
_AddStaticSearch(typeDef);
|
||||
DoPopulateType_InitSearches(typeInstance);
|
||||
}
|
||||
|
||||
bool underlyingTypeDeferred = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue