mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22: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
|
@ -1761,9 +1761,10 @@ public:
|
||||||
void DoCEEmit(BfTypeInstance* typeInstance, bool& hadNewMembers, bool underlyingTypeDeferred);
|
void DoCEEmit(BfTypeInstance* typeInstance, bool& hadNewMembers, bool underlyingTypeDeferred);
|
||||||
void DoCEEmit(BfMethodInstance* methodInstance);
|
void DoCEEmit(BfMethodInstance* methodInstance);
|
||||||
void DoPopulateType_TypeAlias(BfTypeInstance* typeAlias);
|
void DoPopulateType_TypeAlias(BfTypeInstance* typeAlias);
|
||||||
|
void DoPopulateType_InitSearches(BfTypeInstance* typeInstance);
|
||||||
void DoPopulateType_SetGenericDependencies(BfTypeInstance* genericTypeInstance);
|
void DoPopulateType_SetGenericDependencies(BfTypeInstance* genericTypeInstance);
|
||||||
void DoPopulateType_FinishEnum(BfTypeInstance* typeInstance, bool underlyingTypeDeferred, HashContext* dataMemberHashCtx, BfType* unionInnerType);
|
void DoPopulateType_FinishEnum(BfTypeInstance* typeInstance, bool underlyingTypeDeferred, HashContext* dataMemberHashCtx, BfType* unionInnerType);
|
||||||
void DoPopulateType_CeCheckEnum(BfTypeInstance* typeInstance, bool underlyingTypeDeferred);
|
void DoPopulateType_CeCheckEnum(BfTypeInstance* typeInstance, bool underlyingTypeDeferred);
|
||||||
void DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType = BfPopulateType_Data);
|
void DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateType = BfPopulateType_Data);
|
||||||
static BfModule* GetModuleFor(BfType* type);
|
static BfModule* GetModuleFor(BfType* type);
|
||||||
void DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance);
|
void DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance);
|
||||||
|
|
|
@ -2589,6 +2589,13 @@ void BfModule::DoPopulateType_TypeAlias(BfTypeInstance* typeAlias)
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeAlias);
|
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mCurTypeInstance, typeAlias);
|
||||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, NULL);
|
||||||
SetAndRestoreValue<BfMethodState*> prevMethodState(mCurMethodState, NULL);
|
SetAndRestoreValue<BfMethodState*> prevMethodState(mCurMethodState, NULL);
|
||||||
|
|
||||||
|
if (typeAlias->mDefineState < BfTypeDefineState_Declaring)
|
||||||
|
{
|
||||||
|
typeAlias->mDefineState = BfTypeDefineState_Declaring;
|
||||||
|
DoPopulateType_InitSearches(typeAlias);
|
||||||
|
}
|
||||||
|
|
||||||
BF_ASSERT(mCurMethodInstance == NULL);
|
BF_ASSERT(mCurMethodInstance == NULL);
|
||||||
auto typeDef = typeAlias->mTypeDef;
|
auto typeDef = typeAlias->mTypeDef;
|
||||||
auto typeAliasDecl = (BfTypeAliasDeclaration*)typeDef->mTypeDeclaration;
|
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)
|
void BfModule::DoPopulateType_FinishEnum(BfTypeInstance* typeInstance, bool underlyingTypeDeferred, HashContext* dataMemberHashCtx, BfType* unionInnerType)
|
||||||
{
|
{
|
||||||
if (typeInstance->IsEnum())
|
if (typeInstance->IsEnum())
|
||||||
|
@ -2966,94 +3066,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
if (typeInstance->mDefineState < BfTypeDefineState_Declaring)
|
if (typeInstance->mDefineState < BfTypeDefineState_Declaring)
|
||||||
{
|
{
|
||||||
typeInstance->mDefineState = BfTypeDefineState_Declaring;
|
typeInstance->mDefineState = BfTypeDefineState_Declaring;
|
||||||
|
DoPopulateType_InitSearches(typeInstance);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool underlyingTypeDeferred = false;
|
bool underlyingTypeDeferred = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue