mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Internal protection, 'using internal <type or namespace>;`
This commit is contained in:
parent
7349cdf50f
commit
6b27f0f0b2
25 changed files with 313 additions and 96 deletions
|
@ -631,7 +631,7 @@ void BfStructuralVisitor::Visit(BfUsingDirective* usingDirective)
|
||||||
Visit(usingDirective->ToBase());
|
Visit(usingDirective->ToBase());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfStructuralVisitor::Visit(BfUsingStaticDirective * usingDirective)
|
void BfStructuralVisitor::Visit(BfUsingModDirective * usingDirective)
|
||||||
{
|
{
|
||||||
Visit(usingDirective->ToBase());
|
Visit(usingDirective->ToBase());
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ enum BfProtection : uint8
|
||||||
{
|
{
|
||||||
BfProtection_Hidden,
|
BfProtection_Hidden,
|
||||||
BfProtection_Private,
|
BfProtection_Private,
|
||||||
|
BfProtection_Internal,
|
||||||
BfProtection_Protected,
|
BfProtection_Protected,
|
||||||
BfProtection_Public
|
BfProtection_Public
|
||||||
};
|
};
|
||||||
|
@ -335,7 +336,7 @@ class BfConstructorDeclaration;
|
||||||
class BfDestructorDeclaration;
|
class BfDestructorDeclaration;
|
||||||
class BfQualifiedTypeReference;
|
class BfQualifiedTypeReference;
|
||||||
class BfUsingDirective;
|
class BfUsingDirective;
|
||||||
class BfUsingStaticDirective;
|
class BfUsingModDirective;
|
||||||
class BfPropertyMethodDeclaration;
|
class BfPropertyMethodDeclaration;
|
||||||
class BfPropertyBodyExpression;
|
class BfPropertyBodyExpression;
|
||||||
class BfPropertyDeclaration;
|
class BfPropertyDeclaration;
|
||||||
|
@ -534,7 +535,7 @@ public:
|
||||||
virtual void Visit(BfTypeDeclaration* typeDeclaration);
|
virtual void Visit(BfTypeDeclaration* typeDeclaration);
|
||||||
virtual void Visit(BfTypeAliasDeclaration* typeDeclaration);
|
virtual void Visit(BfTypeAliasDeclaration* typeDeclaration);
|
||||||
virtual void Visit(BfUsingDirective* usingDirective);
|
virtual void Visit(BfUsingDirective* usingDirective);
|
||||||
virtual void Visit(BfUsingStaticDirective* usingDirective);
|
virtual void Visit(BfUsingModDirective* usingDirective);
|
||||||
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration);
|
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration);
|
||||||
virtual void Visit(BfBlock* block);
|
virtual void Visit(BfBlock* block);
|
||||||
virtual void Visit(BfBlockExtension* block);
|
virtual void Visit(BfBlockExtension* block);
|
||||||
|
@ -1932,15 +1933,15 @@ public:
|
||||||
BfIdentifierNode* mNamespace;
|
BfIdentifierNode* mNamespace;
|
||||||
}; BF_AST_DECL(BfUsingDirective, BfStatement);
|
}; BF_AST_DECL(BfUsingDirective, BfStatement);
|
||||||
|
|
||||||
class BfUsingStaticDirective : public BfStatement
|
class BfUsingModDirective : public BfStatement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BF_AST_TYPE(BfUsingStaticDirective, BfStatement);
|
BF_AST_TYPE(BfUsingModDirective, BfStatement);
|
||||||
|
|
||||||
BfTokenNode* mUsingToken;
|
BfTokenNode* mUsingToken;
|
||||||
BfTokenNode* mStaticToken;
|
BfTokenNode* mModToken;
|
||||||
BfTypeReference* mTypeRef;
|
BfTypeReference* mTypeRef;
|
||||||
}; BF_AST_DECL(BfUsingStaticDirective, BfStatement);
|
}; BF_AST_DECL(BfUsingModDirective, BfStatement);
|
||||||
|
|
||||||
class BfAttributeTargetSpecifier : public BfAstNode
|
class BfAttributeTargetSpecifier : public BfAstNode
|
||||||
{
|
{
|
||||||
|
|
|
@ -3536,13 +3536,14 @@ void BfCompiler::VisitAutocompleteExteriorIdentifiers()
|
||||||
{
|
{
|
||||||
checkIdentifier = usingDirective->mNamespace;
|
checkIdentifier = usingDirective->mNamespace;
|
||||||
}
|
}
|
||||||
else if (auto usingDirective = BfNodeDynCast<BfUsingStaticDirective>(checkNode))
|
else if (auto usingDirective = BfNodeDynCast<BfUsingModDirective>(checkNode))
|
||||||
{
|
{
|
||||||
if (usingDirective->mTypeRef != NULL)
|
if (usingDirective->mTypeRef != NULL)
|
||||||
{
|
{
|
||||||
BF_ASSERT(mContext->mScratchModule->mCurTypeInstance == NULL);
|
BF_ASSERT(mContext->mScratchModule->mCurTypeInstance == NULL);
|
||||||
|
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevCurTypeInstance(mContext->mScratchModule->mCurTypeInstance, NULL);
|
SetAndRestoreValue<BfTypeInstance*> prevCurTypeInstance(mContext->mScratchModule->mCurTypeInstance, NULL);
|
||||||
|
SetAndRestoreValue<bool> prevIgnoreErrors(mContext->mScratchModule->mIgnoreErrors, true);
|
||||||
mContext->mScratchModule->ResolveTypeRef(usingDirective->mTypeRef, NULL);
|
mContext->mScratchModule->ResolveTypeRef(usingDirective->mTypeRef, NULL);
|
||||||
if (mResolvePassData->mAutoComplete != NULL)
|
if (mResolvePassData->mAutoComplete != NULL)
|
||||||
mResolvePassData->mAutoComplete->CheckTypeRef(usingDirective->mTypeRef, false, isUsingDirective);
|
mResolvePassData->mAutoComplete->CheckTypeRef(usingDirective->mTypeRef, false, isUsingDirective);
|
||||||
|
@ -3577,26 +3578,37 @@ void BfCompiler::VisitAutocompleteExteriorIdentifiers()
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfCompiler::VisitSourceExteriorNodes()
|
void BfCompiler::VisitSourceExteriorNodes()
|
||||||
{
|
{
|
||||||
BP_ZONE("BfCompiler::VisitSourceExteriorNodes");
|
BP_ZONE("BfCompiler::VisitSourceExteriorNodes");
|
||||||
|
|
||||||
String str;
|
String str;
|
||||||
Array<BfAtom*> namespaceParts;
|
Array<BfAtom*> namespaceParts;
|
||||||
Array<BfAstNode*> srcNodes;
|
Array<BfAstNode*> srcNodes;
|
||||||
std::function<bool(BfAstNode*)> _AddName = [&](BfAstNode* node)
|
std::function<bool(BfAstNode*, bool)> _AddName = [&](BfAstNode* node, bool wantErrors)
|
||||||
{
|
{
|
||||||
|
if (node == NULL)
|
||||||
|
return false;
|
||||||
if (auto qualifiedName = BfNodeDynCast<BfQualifiedNameNode>(node))
|
if (auto qualifiedName = BfNodeDynCast<BfQualifiedNameNode>(node))
|
||||||
{
|
{
|
||||||
if (!_AddName(qualifiedName->mLeft))
|
if (!_AddName(qualifiedName->mLeft, wantErrors))
|
||||||
return false;
|
return false;
|
||||||
if (!_AddName(qualifiedName->mRight))
|
if (!_AddName(qualifiedName->mRight, wantErrors))
|
||||||
return false;
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else if (auto identifier = BfNodeDynCast<BfIdentifierNode>(node))
|
else if (auto qualifedTypeRef = BfNodeDynCast<BfQualifiedTypeReference>(node))
|
||||||
{
|
{
|
||||||
srcNodes.Add(identifier);
|
if (!_AddName(qualifedTypeRef->mLeft, wantErrors))
|
||||||
|
return false;
|
||||||
|
if (!_AddName(qualifedTypeRef->mRight, wantErrors))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if ((node->IsA<BfIdentifierNode>()) || (node->IsA<BfNamedTypeReference>()))
|
||||||
|
{
|
||||||
|
srcNodes.Add(node);
|
||||||
str.Clear();
|
str.Clear();
|
||||||
identifier->ToString(str);
|
node->ToString(str);
|
||||||
auto atom = mSystem->FindAtom(str);
|
auto atom = mSystem->FindAtom(str);
|
||||||
if (atom == NULL)
|
if (atom == NULL)
|
||||||
{
|
{
|
||||||
|
@ -3607,14 +3619,44 @@ void BfCompiler::VisitSourceExteriorNodes()
|
||||||
prevNamespace += ".";
|
prevNamespace += ".";
|
||||||
prevNamespace += part->mString;
|
prevNamespace += part->mString;
|
||||||
}
|
}
|
||||||
|
if (wantErrors)
|
||||||
if (prevNamespace.IsEmpty())
|
{
|
||||||
mPassInstance->Fail(StrFormat("The namespace '%s' does not exist", str.c_str()), identifier);
|
if (prevNamespace.IsEmpty())
|
||||||
else
|
mPassInstance->Fail(StrFormat("The namespace '%s' does not exist", str.c_str()), node);
|
||||||
mPassInstance->Fail(StrFormat("The namespace '%s' does not exist in the namespace '%s'", str.c_str(), prevNamespace.c_str()), identifier);
|
else
|
||||||
|
mPassInstance->Fail(StrFormat("The namespace '%s' does not exist in the namespace '%s'", str.c_str(), prevNamespace.c_str()), node);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
namespaceParts.Add(atom);
|
namespaceParts.Add(atom);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto _CheckNamespace = [&](BfParser* parser, bool wantErrors, bool& failed)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (int)namespaceParts.size(); i++)
|
||||||
|
{
|
||||||
|
BfAtomComposite checkNamespace;
|
||||||
|
checkNamespace.mParts = &namespaceParts[0];
|
||||||
|
checkNamespace.mSize = i + 1;
|
||||||
|
|
||||||
|
if (!mSystem->ContainsNamespace(checkNamespace, parser->mProject))
|
||||||
|
{
|
||||||
|
failed = true;
|
||||||
|
BfAtomComposite prevNamespace;
|
||||||
|
prevNamespace.mParts = &namespaceParts[0];
|
||||||
|
prevNamespace.mSize = i;
|
||||||
|
if (wantErrors)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
mPassInstance->Fail(StrFormat("The namespace '%s' does not exist", namespaceParts[i]->mString.ToString().c_str()), srcNodes[i]);
|
||||||
|
else
|
||||||
|
mPassInstance->Fail(StrFormat("The namespace '%s' does not exist in the namespace '%s'", namespaceParts[i]->mString.ToString().c_str(), prevNamespace.ToString().c_str()), srcNodes[i]);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
@ -3633,44 +3675,44 @@ void BfCompiler::VisitSourceExteriorNodes()
|
||||||
|
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
for (auto node : parser->mParserData->mExteriorNodes)
|
for (auto node : parser->mParserData->mExteriorNodes)
|
||||||
{
|
{
|
||||||
if (auto usingDirective = BfNodeDynCast<BfUsingDirective>(node))
|
if (auto usingDirective = BfNodeDynCast<BfUsingDirective>(node))
|
||||||
{
|
{
|
||||||
srcNodes.Clear();
|
srcNodes.Clear();
|
||||||
namespaceParts.Clear();
|
namespaceParts.Clear();
|
||||||
bool success = _AddName(usingDirective->mNamespace);
|
bool success = _AddName(usingDirective->mNamespace, true);
|
||||||
|
_CheckNamespace(parser, true, failed);
|
||||||
for (int i = 0; i < (int)namespaceParts.size(); i++)
|
|
||||||
{
|
|
||||||
BfAtomComposite checkNamespace;
|
|
||||||
checkNamespace.mParts = &namespaceParts[0];
|
|
||||||
checkNamespace.mSize = i + 1;
|
|
||||||
|
|
||||||
if (!mSystem->ContainsNamespace(checkNamespace, parser->mProject))
|
|
||||||
{
|
|
||||||
failed = true;
|
|
||||||
BfAtomComposite prevNamespace;
|
|
||||||
prevNamespace.mParts = &namespaceParts[0];
|
|
||||||
prevNamespace.mSize = i;
|
|
||||||
if (i == 0)
|
|
||||||
mPassInstance->Fail(StrFormat("The namespace '%s' does not exist", namespaceParts[i]->mString.ToString().c_str()), srcNodes[i]);
|
|
||||||
else
|
|
||||||
mPassInstance->Fail(StrFormat("The namespace '%s' does not exist in the namespace '%s'", namespaceParts[i]->mString.ToString().c_str(), prevNamespace.ToString().c_str()), srcNodes[i]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (auto usingDirective = BfNodeDynCast<BfUsingStaticDirective>(node))
|
else if (auto usingDirective = BfNodeDynCast<BfUsingModDirective>(node))
|
||||||
{
|
{
|
||||||
if (usingDirective->mTypeRef != NULL)
|
if (usingDirective->mTypeRef != NULL)
|
||||||
{
|
{
|
||||||
BF_ASSERT(mContext->mScratchModule->mCurTypeInstance == NULL);
|
BF_ASSERT(mContext->mScratchModule->mCurTypeInstance == NULL);
|
||||||
|
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevCurTypeInstance(mContext->mScratchModule->mCurTypeInstance, NULL);
|
bool wasNamespace = false;
|
||||||
mContext->mScratchModule->ResolveTypeRef(usingDirective->mTypeRef, BfPopulateType_Identity);
|
if (usingDirective->mModToken->mToken == BfToken_Internal)
|
||||||
if ((mResolvePassData != NULL) && (mResolvePassData->mAutoComplete != NULL))
|
{
|
||||||
mResolvePassData->mAutoComplete->CheckTypeRef(usingDirective->mTypeRef, false, false);
|
srcNodes.Clear();
|
||||||
return;
|
namespaceParts.Clear();
|
||||||
|
if (_AddName(usingDirective->mTypeRef, false))
|
||||||
|
{
|
||||||
|
wasNamespace = _CheckNamespace(parser, false, failed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!wasNamespace)
|
||||||
|
{
|
||||||
|
SetAndRestoreValue<BfTypeInstance*> prevCurTypeInstance(mContext->mScratchModule->mCurTypeInstance, NULL);
|
||||||
|
|
||||||
|
if (auto genericTypeRef = BfNodeDynCast<BfGenericInstanceTypeRef>(usingDirective->mTypeRef))
|
||||||
|
{
|
||||||
|
mContext->mScratchModule->ResolveTypeRefAllowUnboundGenerics(usingDirective->mTypeRef, BfPopulateType_Identity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mContext->mScratchModule->ResolveTypeRef(usingDirective->mTypeRef, BfPopulateType_Identity);
|
||||||
|
|
||||||
|
if ((mResolvePassData != NULL) && (mResolvePassData->mAutoComplete != NULL))
|
||||||
|
mResolvePassData->mAutoComplete->CheckTypeRef(usingDirective->mTypeRef, false, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3861,7 +3903,6 @@ void BfCompiler::ProcessAutocompleteTempType()
|
||||||
}
|
}
|
||||||
VisitSourceExteriorNodes();
|
VisitSourceExteriorNodes();
|
||||||
|
|
||||||
|
|
||||||
if (autoComplete->mResolveType == BfResolveType_GetFixits)
|
if (autoComplete->mResolveType == BfResolveType_GetFixits)
|
||||||
{
|
{
|
||||||
BfAstNode* conflictStart = NULL;
|
BfAstNode* conflictStart = NULL;
|
||||||
|
@ -3978,6 +4019,40 @@ void BfCompiler::ProcessAutocompleteTempType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BfInternalAccessSet* internalAccessSet = NULL;
|
||||||
|
if (mResolvePassData->mInternalAccessMap.TryAdd(tempTypeDef, NULL, &internalAccessSet))
|
||||||
|
{
|
||||||
|
for (auto typeRef : tempTypeDef->mInternalAccessSet)
|
||||||
|
{
|
||||||
|
if ((typeRef->IsA<BfNamedTypeReference>()) ||
|
||||||
|
(typeRef->IsA<BfQualifiedTypeReference>()))
|
||||||
|
{
|
||||||
|
String checkNamespaceStr;
|
||||||
|
typeRef->ToString(checkNamespaceStr);
|
||||||
|
BfAtomComposite checkNamespace;
|
||||||
|
if (mSystem->ParseAtomComposite(checkNamespaceStr, checkNamespace))
|
||||||
|
{
|
||||||
|
if (mSystem->ContainsNamespace(checkNamespace, tempTypeDef->mProject))
|
||||||
|
{
|
||||||
|
internalAccessSet->mNamespaces.Add(checkNamespace);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BfType* type;
|
||||||
|
if (auto genericTypeRef = BfNodeDynCast<BfGenericInstanceTypeRef>(typeRef))
|
||||||
|
type = mContext->mScratchModule->ResolveTypeRefAllowUnboundGenerics(typeRef, BfPopulateType_Identity);
|
||||||
|
else
|
||||||
|
type = module->ResolveTypeRef(typeRef, NULL, BfPopulateType_Identity);
|
||||||
|
if (type != NULL)
|
||||||
|
{
|
||||||
|
auto typeInst = type->ToTypeInstance();
|
||||||
|
if (typeInst != NULL)
|
||||||
|
internalAccessSet->mTypes.Add(typeInst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto _FindAcutalTypeDef = [&](BfTypeDef* tempTypeDef)
|
auto _FindAcutalTypeDef = [&](BfTypeDef* tempTypeDef)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1004,6 +1004,7 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typeInst->ReleaseData();
|
||||||
type->mDefineState = BfTypeDefineState_Undefined;
|
type->mDefineState = BfTypeDefineState_Undefined;
|
||||||
typeInst->mSpecializedMethodReferences.Clear();
|
typeInst->mSpecializedMethodReferences.Clear();
|
||||||
typeInst->mLookupResults.Clear();
|
typeInst->mLookupResults.Clear();
|
||||||
|
@ -1040,6 +1041,7 @@ void BfContext::RebuildType(BfType* type, bool deleteOnDemandTypes, bool rebuild
|
||||||
}
|
}
|
||||||
|
|
||||||
typeInst->mStaticSearchMap.Clear();
|
typeInst->mStaticSearchMap.Clear();
|
||||||
|
typeInst->mInternalAccessMap.Clear();
|
||||||
typeInst->mInterfaces.Clear();
|
typeInst->mInterfaces.Clear();
|
||||||
typeInst->mInterfaceMethodTable.Clear();
|
typeInst->mInterfaceMethodTable.Clear();
|
||||||
for (auto operatorInfo : typeInst->mOperatorInfo)
|
for (auto operatorInfo : typeInst->mOperatorInfo)
|
||||||
|
|
|
@ -375,6 +375,8 @@ BfProtection BfDefBuilder::GetProtection(BfTokenNode* protectionToken)
|
||||||
return BfProtection_Public;
|
return BfProtection_Public;
|
||||||
if (protectionToken->GetToken() == BfToken_Protected)
|
if (protectionToken->GetToken() == BfToken_Protected)
|
||||||
return BfProtection_Protected;
|
return BfProtection_Protected;
|
||||||
|
if (protectionToken->GetToken() == BfToken_Internal)
|
||||||
|
return BfProtection_Internal;
|
||||||
return BfProtection_Private;
|
return BfProtection_Private;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1437,6 +1439,7 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration)
|
||||||
mCurTypeDef->mNestDepth = outerTypeDef->mNestDepth + 1;
|
mCurTypeDef->mNestDepth = outerTypeDef->mNestDepth + 1;
|
||||||
mCurTypeDef->mNamespaceSearch = outerTypeDef->mNamespaceSearch;
|
mCurTypeDef->mNamespaceSearch = outerTypeDef->mNamespaceSearch;
|
||||||
mCurTypeDef->mStaticSearch = outerTypeDef->mStaticSearch;
|
mCurTypeDef->mStaticSearch = outerTypeDef->mStaticSearch;
|
||||||
|
mCurTypeDef->mInternalAccessSet = outerTypeDef->mInternalAccessSet;
|
||||||
|
|
||||||
for (auto outerGenericParamDef : outerTypeDef->mGenericParamDefs)
|
for (auto outerGenericParamDef : outerTypeDef->mGenericParamDefs)
|
||||||
{
|
{
|
||||||
|
@ -1457,6 +1460,7 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration)
|
||||||
BF_ASSERT(mCurTypeDef->mNamespaceSearch.size() == 0);
|
BF_ASSERT(mCurTypeDef->mNamespaceSearch.size() == 0);
|
||||||
mCurTypeDef->mNamespaceSearch = mNamespaceSearch;
|
mCurTypeDef->mNamespaceSearch = mNamespaceSearch;
|
||||||
mCurTypeDef->mStaticSearch = mStaticSearch;
|
mCurTypeDef->mStaticSearch = mStaticSearch;
|
||||||
|
mCurTypeDef->mInternalAccessSet = mInternalAccessSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to mix the namespace search into the signature hash because it can change how type references are resolved
|
// We need to mix the namespace search into the signature hash because it can change how type references are resolved
|
||||||
|
@ -1465,10 +1469,10 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration)
|
||||||
mSystem->RefAtomComposite(usingName);
|
mSystem->RefAtomComposite(usingName);
|
||||||
mSignatureHashCtx->MixinStr(usingName.ToString());
|
mSignatureHashCtx->MixinStr(usingName.ToString());
|
||||||
}
|
}
|
||||||
for (auto& usingName : mCurTypeDef->mStaticSearch)
|
for (auto& usingName : mCurTypeDef->mStaticSearch)
|
||||||
{
|
HashNode(*mSignatureHashCtx, usingName);
|
||||||
|
for (auto& usingName : mCurTypeDef->mInternalAccessSet)
|
||||||
HashNode(*mSignatureHashCtx, usingName);
|
HashNode(*mSignatureHashCtx, usingName);
|
||||||
}
|
|
||||||
|
|
||||||
if ((typeDeclaration->mPartialSpecifier != NULL) && (!isAutoCompleteTempType))
|
if ((typeDeclaration->mPartialSpecifier != NULL) && (!isAutoCompleteTempType))
|
||||||
{
|
{
|
||||||
|
@ -2227,12 +2231,17 @@ void BfDefBuilder::Visit(BfUsingDirective* usingDirective)
|
||||||
mSystem->ReleaseAtomComposite(usingComposite);
|
mSystem->ReleaseAtomComposite(usingComposite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfDefBuilder::Visit(BfUsingStaticDirective* usingDirective)
|
void BfDefBuilder::Visit(BfUsingModDirective* usingDirective)
|
||||||
{
|
{
|
||||||
if (mResolvePassData != NULL)
|
if (mResolvePassData != NULL)
|
||||||
mResolvePassData->mExteriorAutocompleteCheckNodes.push_back(usingDirective);
|
mResolvePassData->mExteriorAutocompleteCheckNodes.push_back(usingDirective);
|
||||||
|
|
||||||
if (usingDirective->mTypeRef != NULL)
|
if (usingDirective->mModToken->mToken == BfToken_Internal)
|
||||||
|
{
|
||||||
|
if (usingDirective->mTypeRef != NULL)
|
||||||
|
mInternalAccessSet.Add(usingDirective->mTypeRef);
|
||||||
|
}
|
||||||
|
else if (usingDirective->mTypeRef != NULL)
|
||||||
mStaticSearch.Add(usingDirective->mTypeRef);
|
mStaticSearch.Add(usingDirective->mTypeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
BfAtomComposite mNamespace;
|
BfAtomComposite mNamespace;
|
||||||
Array<BfAtomComposite> mNamespaceSearch;
|
Array<BfAtomComposite> mNamespaceSearch;
|
||||||
Array<BfTypeReference*> mStaticSearch;
|
Array<BfTypeReference*> mStaticSearch;
|
||||||
|
Array<BfTypeReference*> mInternalAccessSet;
|
||||||
HashContext* mFullHashCtx;
|
HashContext* mFullHashCtx;
|
||||||
HashContext* mSignatureHashCtx;
|
HashContext* mSignatureHashCtx;
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ public:
|
||||||
virtual void Visit(BfEnumCaseDeclaration* enumCaseDeclaration) override;
|
virtual void Visit(BfEnumCaseDeclaration* enumCaseDeclaration) override;
|
||||||
virtual void Visit(BfTypeDeclaration* typeDeclaration) override;
|
virtual void Visit(BfTypeDeclaration* typeDeclaration) override;
|
||||||
virtual void Visit(BfUsingDirective* usingDirective) override;
|
virtual void Visit(BfUsingDirective* usingDirective) override;
|
||||||
virtual void Visit(BfUsingStaticDirective* usingDirective) override;
|
virtual void Visit(BfUsingModDirective* usingDirective) override;
|
||||||
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration) override;
|
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration) override;
|
||||||
virtual void Visit(BfBlock* block) override;
|
virtual void Visit(BfBlock* block) override;
|
||||||
virtual void Visit(BfRootNode* rootNode) override;
|
virtual void Visit(BfRootNode* rootNode) override;
|
||||||
|
|
|
@ -1172,12 +1172,12 @@ void BfElementVisitor::Visit(BfUsingDirective* usingDirective)
|
||||||
VisitChild(usingDirective->mNamespace);
|
VisitChild(usingDirective->mNamespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfElementVisitor::Visit(BfUsingStaticDirective * usingDirective)
|
void BfElementVisitor::Visit(BfUsingModDirective* usingDirective)
|
||||||
{
|
{
|
||||||
Visit(usingDirective->ToBase());
|
Visit(usingDirective->ToBase());
|
||||||
|
|
||||||
VisitChild(usingDirective->mUsingToken);
|
VisitChild(usingDirective->mUsingToken);
|
||||||
VisitChild(usingDirective->mStaticToken);
|
VisitChild(usingDirective->mModToken);
|
||||||
VisitChild(usingDirective->mTypeRef);
|
VisitChild(usingDirective->mTypeRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ public:
|
||||||
virtual void Visit(BfTypeDeclaration* typeDeclaration);
|
virtual void Visit(BfTypeDeclaration* typeDeclaration);
|
||||||
virtual void Visit(BfTypeAliasDeclaration* typeDeclaration);
|
virtual void Visit(BfTypeAliasDeclaration* typeDeclaration);
|
||||||
virtual void Visit(BfUsingDirective* usingDirective);
|
virtual void Visit(BfUsingDirective* usingDirective);
|
||||||
virtual void Visit(BfUsingStaticDirective* usingDirective);
|
virtual void Visit(BfUsingModDirective* usingDirective);
|
||||||
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration);
|
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration);
|
||||||
virtual void Visit(BfBlock* block);
|
virtual void Visit(BfBlock* block);
|
||||||
virtual void Visit(BfRootNode* rootNode);
|
virtual void Visit(BfRootNode* rootNode);
|
||||||
|
|
|
@ -2460,7 +2460,7 @@ void BfMethodMatcher::CheckOuterTypeStaticMethods(BfTypeInstance* typeInstance,
|
||||||
if (checkMethod->mName != mMethodName)
|
if (checkMethod->mName != mMethodName)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((!isFailurePass) && (!mModule->CheckProtection(checkMethod->mProtection, allowProtected, allowPrivate)))
|
if ((!isFailurePass) && (!mModule->CheckProtection(checkMethod->mProtection, NULL, allowProtected, allowPrivate)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CheckMethod(typeInstance, curTypeInst, checkMethod, isFailurePass);
|
CheckMethod(typeInstance, curTypeInst, checkMethod, isFailurePass);
|
||||||
|
@ -4059,7 +4059,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
||||||
bool isTemporary = target.IsTempAddr();
|
bool isTemporary = target.IsTempAddr();
|
||||||
bool wantsLoadValue = false;
|
bool wantsLoadValue = false;
|
||||||
bool wantsReadOnly = false;
|
bool wantsReadOnly = false;
|
||||||
if ((field->mIsReadOnly) && ((mModule->mCurMethodInstance->mMethodDef->mMethodType != BfMethodType_Ctor) || (!target.IsThis())))
|
if ((field->mIsReadOnly) && (mModule->mCurMethodInstance != NULL) && ((mModule->mCurMethodInstance->mMethodDef->mMethodType != BfMethodType_Ctor) || (!target.IsThis())))
|
||||||
wantsReadOnly = true;
|
wantsReadOnly = true;
|
||||||
|
|
||||||
bool isComposite = target.mType->IsComposite();
|
bool isComposite = target.mType->IsComposite();
|
||||||
|
|
|
@ -2508,7 +2508,7 @@ void BfModule::SetIllegalExprSrcPos(BfSrcPosFlags flags)
|
||||||
//SetIllegalSrcPos((BfSrcPosFlags)(flags | BfSrcPosFlag_Expression));
|
//SetIllegalSrcPos((BfSrcPosFlags)(flags | BfSrcPosFlag_Expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BfModule::CheckProtection(BfProtection protection, bool allowProtected, bool allowPrivate)
|
bool BfModule::CheckProtection(BfProtection protection, BfTypeDef* checkType, bool allowProtected, bool allowPrivate)
|
||||||
{
|
{
|
||||||
if ((protection == BfProtection_Public) ||
|
if ((protection == BfProtection_Public) ||
|
||||||
((protection == BfProtection_Protected) && (allowProtected)) ||
|
((protection == BfProtection_Protected) && (allowProtected)) ||
|
||||||
|
@ -2519,6 +2519,11 @@ bool BfModule::CheckProtection(BfProtection protection, bool allowProtected, boo
|
||||||
mAttributeState->mUsed = true;
|
mAttributeState->mUsed = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if ((protection == BfProtection_Internal) && (checkType != NULL))
|
||||||
|
{
|
||||||
|
if (CheckInternalProtection(checkType))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2627,6 +2632,12 @@ bool BfModule::CheckProtection(BfProtectionCheckFlags& flags, BfTypeInstance* me
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((memberProtection == BfProtection_Internal) && (memberOwner != NULL))
|
||||||
|
{
|
||||||
|
if (CheckInternalProtection(memberOwner->mTypeDef))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3074,7 +3085,7 @@ void BfModule::NotImpl(BfAstNode* astNode)
|
||||||
Fail("INTERNAL ERROR: Not implemented", astNode);
|
Fail("INTERNAL ERROR: Not implemented", astNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BfModule::CheckAccessMemberProtection(BfProtection protection, BfType* memberType)
|
bool BfModule::CheckAccessMemberProtection(BfProtection protection, BfTypeInstance* memberType)
|
||||||
{
|
{
|
||||||
bool allowPrivate = (memberType == mCurTypeInstance) || (IsInnerType(mCurTypeInstance, memberType));
|
bool allowPrivate = (memberType == mCurTypeInstance) || (IsInnerType(mCurTypeInstance, memberType));
|
||||||
if (!allowPrivate)
|
if (!allowPrivate)
|
||||||
|
@ -3083,7 +3094,7 @@ bool BfModule::CheckAccessMemberProtection(BfProtection protection, BfType* memb
|
||||||
//TODO: We had this commented out, but this makes accessing protected properties fail
|
//TODO: We had this commented out, but this makes accessing protected properties fail
|
||||||
if (mCurTypeInstance != NULL)
|
if (mCurTypeInstance != NULL)
|
||||||
allowProtected |= TypeIsSubTypeOf(mCurTypeInstance, memberType->ToTypeInstance());
|
allowProtected |= TypeIsSubTypeOf(mCurTypeInstance, memberType->ToTypeInstance());
|
||||||
if (!CheckProtection(protection, allowProtected, allowPrivate))
|
if (!CheckProtection(protection, memberType->mTypeDef, allowProtected, allowPrivate))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3393,6 +3404,42 @@ BfStaticSearch* BfModule::GetStaticSearch()
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BfInternalAccessSet* BfModule::GetInternalAccessSet()
|
||||||
|
{
|
||||||
|
auto activeTypeDef = GetActiveTypeDef();
|
||||||
|
BfInternalAccessSet* internalAccessSet = NULL;
|
||||||
|
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->mInternalAccessMap.TryGetValue(activeTypeDef, &internalAccessSet)))
|
||||||
|
return internalAccessSet;
|
||||||
|
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mInternalAccessMap.TryGetValue(activeTypeDef, &internalAccessSet)))
|
||||||
|
return internalAccessSet;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BfModule::CheckInternalProtection(BfTypeDef* usingTypeDef)
|
||||||
|
{
|
||||||
|
auto internalAccessSet = GetInternalAccessSet();
|
||||||
|
if (internalAccessSet == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (auto& nameComposite : internalAccessSet->mNamespaces)
|
||||||
|
{
|
||||||
|
if (usingTypeDef->mNamespace.StartsWith(nameComposite))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto internalType : internalAccessSet->mTypes)
|
||||||
|
{
|
||||||
|
auto checkTypeDef = usingTypeDef;
|
||||||
|
while (checkTypeDef != NULL)
|
||||||
|
{
|
||||||
|
if (checkTypeDef == internalType->mTypeDef)
|
||||||
|
return true;
|
||||||
|
checkTypeDef = checkTypeDef->mOuterType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void PrintUsers(llvm::MDNode* md);
|
void PrintUsers(llvm::MDNode* md);
|
||||||
|
|
||||||
BfModuleOptions BfModule::GetModuleOptions()
|
BfModuleOptions BfModule::GetModuleOptions()
|
||||||
|
@ -10688,7 +10735,7 @@ void BfModule::GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttri
|
||||||
if ((checkMethod->mIsStatic) || (checkMethod->mMethodType != BfMethodType_Ctor))
|
if ((checkMethod->mIsStatic) || (checkMethod->mMethodType != BfMethodType_Ctor))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((!isFailurePass) && (!CheckProtection(checkMethod->mProtection, false, false)))
|
if ((!isFailurePass) && (!CheckProtection(checkMethod->mProtection, attrTypeInst->mTypeDef, false, false)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
methodMatcher.CheckMethod(NULL, attrTypeInst, checkMethod, isFailurePass);
|
methodMatcher.CheckMethod(NULL, attrTypeInst, checkMethod, isFailurePass);
|
||||||
|
|
|
@ -1458,7 +1458,7 @@ public:
|
||||||
void FatalError(const StringImpl& error, const char* file = NULL, int line = -1);
|
void FatalError(const StringImpl& error, const char* file = NULL, int line = -1);
|
||||||
void NotImpl(BfAstNode* astNode);
|
void NotImpl(BfAstNode* astNode);
|
||||||
void AddMethodReference(const BfMethodRef& methodRef, BfGetMethodInstanceFlags flags = BfGetMethodInstanceFlag_None);
|
void AddMethodReference(const BfMethodRef& methodRef, BfGetMethodInstanceFlags flags = BfGetMethodInstanceFlag_None);
|
||||||
bool CheckProtection(BfProtection protection, bool allowProtected, bool allowPrivate);
|
bool CheckProtection(BfProtection protection, BfTypeDef* checkType, bool allowProtected, bool allowPrivate);
|
||||||
void GetAccessAllowed(BfTypeInstance* checkType, bool& allowProtected, bool& allowPrivate);
|
void GetAccessAllowed(BfTypeInstance* checkType, bool& allowProtected, bool& allowPrivate);
|
||||||
bool CheckProtection(BfProtectionCheckFlags& flags, BfTypeInstance* memberOwner, BfProject* memberProject, BfProtection memberProtection, BfTypeInstance* lookupStartType);
|
bool CheckProtection(BfProtectionCheckFlags& flags, BfTypeInstance* memberOwner, BfProject* memberProject, BfProtection memberProtection, BfTypeInstance* lookupStartType);
|
||||||
void SetElementType(BfAstNode* astNode, BfSourceElementType elementType);
|
void SetElementType(BfAstNode* astNode, BfSourceElementType elementType);
|
||||||
|
@ -1651,7 +1651,7 @@ public:
|
||||||
void CheckInjectNewRevision(BfTypeInstance* typeInstance);
|
void CheckInjectNewRevision(BfTypeInstance* typeInstance);
|
||||||
void InitType(BfType* resolvedTypeRef, BfPopulateType populateType);
|
void InitType(BfType* resolvedTypeRef, BfPopulateType populateType);
|
||||||
BfProtection FixProtection(BfProtection protection, BfProject* defProject);
|
BfProtection FixProtection(BfProtection protection, BfProject* defProject);
|
||||||
bool CheckAccessMemberProtection(BfProtection protection, BfType* memberType);
|
bool CheckAccessMemberProtection(BfProtection protection, BfTypeInstance* memberType);
|
||||||
bool CheckDefineMemberProtection(BfProtection protection, BfType* memberType);
|
bool CheckDefineMemberProtection(BfProtection protection, BfType* memberType);
|
||||||
void CheckMemberNames(BfTypeInstance* typeInst);
|
void CheckMemberNames(BfTypeInstance* typeInst);
|
||||||
void AddDependency(BfType* usedType, BfType* userType, BfDependencyMap::DependencyFlags flags);
|
void AddDependency(BfType* usedType, BfType* userType, BfDependencyMap::DependencyFlags flags);
|
||||||
|
@ -1661,6 +1661,8 @@ public:
|
||||||
bool IsAttribute(BfTypeInstance* typeInst);
|
bool IsAttribute(BfTypeInstance* typeInst);
|
||||||
void PopulateGlobalContainersList(const BfGlobalLookup& globalLookup);
|
void PopulateGlobalContainersList(const BfGlobalLookup& globalLookup);
|
||||||
BfStaticSearch* GetStaticSearch();
|
BfStaticSearch* GetStaticSearch();
|
||||||
|
BfInternalAccessSet* GetInternalAccessSet();
|
||||||
|
bool CheckInternalProtection(BfTypeDef* usingTypeDef);
|
||||||
void AddFailType(BfTypeInstance* typeInstance);
|
void AddFailType(BfTypeInstance* typeInstance);
|
||||||
void MarkDerivedDirty(BfTypeInstance* typeInst);
|
void MarkDerivedDirty(BfTypeInstance* typeInst);
|
||||||
void CheckAddFailType();
|
void CheckAddFailType();
|
||||||
|
|
|
@ -2155,26 +2155,72 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
}
|
}
|
||||||
|
|
||||||
auto _AddStaticSearch = [&](BfTypeDef* typeDef)
|
auto _AddStaticSearch = [&](BfTypeDef* typeDef)
|
||||||
{
|
{
|
||||||
if (typeDef->mStaticSearch.IsEmpty())
|
if (!typeDef->mStaticSearch.IsEmpty())
|
||||||
return;
|
|
||||||
BfStaticSearch* staticSearch;
|
|
||||||
if (typeInstance->mStaticSearchMap.TryAdd(typeDef, NULL, &staticSearch))
|
|
||||||
{
|
{
|
||||||
for (auto typeRef : typeDef->mStaticSearch)
|
BfStaticSearch* staticSearch;
|
||||||
|
if (typeInstance->mStaticSearchMap.TryAdd(typeDef, NULL, &staticSearch))
|
||||||
{
|
{
|
||||||
auto staticType = ResolveTypeRef(typeRef, NULL, BfPopulateType_Declaration);
|
for (auto typeRef : typeDef->mStaticSearch)
|
||||||
if (staticType != NULL)
|
|
||||||
{
|
{
|
||||||
auto staticTypeInst = staticType->ToTypeInstance();
|
auto staticType = ResolveTypeRef(typeRef, NULL, BfPopulateType_Identity);
|
||||||
if (staticTypeInst == NULL)
|
if (staticType != NULL)
|
||||||
{
|
{
|
||||||
Fail(StrFormat("Type '%s' cannot be used in a 'using static' declaration", TypeToString(staticType).c_str()), typeRef);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!typeDef->mInternalAccessSet.IsEmpty())
|
||||||
|
{
|
||||||
|
BfInternalAccessSet* internalAccessSet;
|
||||||
|
if (typeInstance->mInternalAccessMap.TryAdd(typeDef, NULL, &internalAccessSet))
|
||||||
|
{
|
||||||
|
for (auto typeRef : typeDef->mInternalAccessSet)
|
||||||
|
{
|
||||||
|
if ((typeRef->IsA<BfNamedTypeReference>()) ||
|
||||||
|
(typeRef->IsA<BfQualifiedTypeReference>()))
|
||||||
{
|
{
|
||||||
staticSearch->mStaticTypes.Add(staticTypeInst);
|
String checkNamespaceStr;
|
||||||
AddDependency(staticTypeInst, typeInstance, BfDependencyMap::DependencyFlag_StaticValue);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5837,7 +5883,7 @@ BfType* BfModule::ResolveInnerType(BfType* outerType, BfTypeReference* typeRef,
|
||||||
{
|
{
|
||||||
auto latestCheckType = checkType->GetLatest();
|
auto latestCheckType = checkType->GetLatest();
|
||||||
|
|
||||||
if ((!isFailurePass) && (!CheckProtection(latestCheckType->mProtection, allowProtected, allowPrivate)))
|
if ((!isFailurePass) && (!CheckProtection(latestCheckType->mProtection, latestCheckType, allowProtected, allowPrivate)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (checkType->mProject != checkOuterType->mTypeDef->mProject)
|
if (checkType->mProject != checkOuterType->mTypeDef->mProject)
|
||||||
|
@ -9413,7 +9459,7 @@ BfType* BfModule::ResolveTypeRefAllowUnboundGenerics(BfTypeReference* typeRef, B
|
||||||
BfTypeVector typeVector;
|
BfTypeVector typeVector;
|
||||||
for (int i = 0; i < (int)genericTypeDef->mGenericParamDefs.size(); i++)
|
for (int i = 0; i < (int)genericTypeDef->mGenericParamDefs.size(); i++)
|
||||||
typeVector.push_back(GetGenericParamType(BfGenericParamKind_Type, i));
|
typeVector.push_back(GetGenericParamType(BfGenericParamKind_Type, i));
|
||||||
return ResolveTypeDef(genericTypeDef, typeVector);
|
return ResolveTypeDef(genericTypeDef, typeVector, populateType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ void BfNamespaceVisitor::Visit(BfUsingDirective* usingDirective)
|
||||||
mResolvePassData->HandleNamespaceReference(usingDirective->mNamespace, usingComposite);
|
mResolvePassData->HandleNamespaceReference(usingDirective->mNamespace, usingComposite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfNamespaceVisitor::Visit(BfUsingStaticDirective* usingDirective)
|
void BfNamespaceVisitor::Visit(BfUsingModDirective* usingDirective)
|
||||||
{
|
{
|
||||||
BfAstNode* useNode = usingDirective->mTypeRef;
|
BfAstNode* useNode = usingDirective->mTypeRef;
|
||||||
BfAstNode* checkNode = usingDirective->mTypeRef;
|
BfAstNode* checkNode = usingDirective->mTypeRef;
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Visit(BfUsingDirective* usingDirective) override;
|
virtual void Visit(BfUsingDirective* usingDirective) override;
|
||||||
virtual void Visit(BfUsingStaticDirective* usingDirective) override;
|
virtual void Visit(BfUsingModDirective* usingDirective) override;
|
||||||
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration) override;
|
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration) override;
|
||||||
virtual void Visit(BfBlock* block) override;
|
virtual void Visit(BfBlock* block) override;
|
||||||
virtual void Visit(BfRootNode* rootNode) override;
|
virtual void Visit(BfRootNode* rootNode) override;
|
||||||
|
|
|
@ -2755,12 +2755,12 @@ void BfPrinter::Visit(BfUsingDirective* usingDirective)
|
||||||
ExpectNewLine();
|
ExpectNewLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfPrinter::Visit(BfUsingStaticDirective * usingDirective)
|
void BfPrinter::Visit(BfUsingModDirective* usingDirective)
|
||||||
{
|
{
|
||||||
ExpectNewLine();
|
ExpectNewLine();
|
||||||
VisitChild(usingDirective->mUsingToken);
|
VisitChild(usingDirective->mUsingToken);
|
||||||
ExpectSpace();
|
ExpectSpace();
|
||||||
VisitChild(usingDirective->mStaticToken);
|
VisitChild(usingDirective->mModToken);
|
||||||
ExpectSpace();
|
ExpectSpace();
|
||||||
VisitChild(usingDirective->mTypeRef);
|
VisitChild(usingDirective->mTypeRef);
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ public:
|
||||||
virtual void Visit(BfTypeAliasDeclaration* typeDeclaration) override;
|
virtual void Visit(BfTypeAliasDeclaration* typeDeclaration) override;
|
||||||
virtual void Visit(BfTypeDeclaration* typeDeclaration) override;
|
virtual void Visit(BfTypeDeclaration* typeDeclaration) override;
|
||||||
virtual void Visit(BfUsingDirective* usingDirective) override;
|
virtual void Visit(BfUsingDirective* usingDirective) override;
|
||||||
virtual void Visit(BfUsingStaticDirective* usingDirective) override;
|
virtual void Visit(BfUsingModDirective* usingDirective) override;
|
||||||
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration) override;
|
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration) override;
|
||||||
virtual void Visit(BfBlock* block) override;
|
virtual void Visit(BfBlock* block) override;
|
||||||
virtual void Visit(BfRootNode* rootNode) override;
|
virtual void Visit(BfRootNode* rootNode) override;
|
||||||
|
|
|
@ -5957,6 +5957,7 @@ BfAstNode* BfReducer::ReadTypeMember(BfTokenNode* tokenNode, int depth, BfAstNod
|
||||||
case BfToken_Public:
|
case BfToken_Public:
|
||||||
case BfToken_Protected:
|
case BfToken_Protected:
|
||||||
case BfToken_Private:
|
case BfToken_Private:
|
||||||
|
case BfToken_Internal:
|
||||||
case BfToken_Virtual:
|
case BfToken_Virtual:
|
||||||
case BfToken_Override:
|
case BfToken_Override:
|
||||||
case BfToken_Abstract:
|
case BfToken_Abstract:
|
||||||
|
@ -6024,7 +6025,8 @@ BfAstNode* BfReducer::ReadTypeMember(BfTokenNode* tokenNode, int depth, BfAstNod
|
||||||
|
|
||||||
if ((token == BfToken_Public) ||
|
if ((token == BfToken_Public) ||
|
||||||
(token == BfToken_Protected) ||
|
(token == BfToken_Protected) ||
|
||||||
(token == BfToken_Private))
|
(token == BfToken_Private) ||
|
||||||
|
(token == BfToken_Internal))
|
||||||
{
|
{
|
||||||
if (memberDecl->mProtectionSpecifier != NULL)
|
if (memberDecl->mProtectionSpecifier != NULL)
|
||||||
{
|
{
|
||||||
|
@ -6246,7 +6248,8 @@ void BfReducer::ReadPropertyBlock(BfPropertyDeclaration* propertyDeclaration, Bf
|
||||||
token = tokenNode->GetToken();
|
token = tokenNode->GetToken();
|
||||||
if ((token == BfToken_Private) ||
|
if ((token == BfToken_Private) ||
|
||||||
(token == BfToken_Protected) ||
|
(token == BfToken_Protected) ||
|
||||||
(token == BfToken_Public))
|
(token == BfToken_Public) ||
|
||||||
|
(token == BfToken_Internal))
|
||||||
{
|
{
|
||||||
if (protectionSpecifier != NULL)
|
if (protectionSpecifier != NULL)
|
||||||
{
|
{
|
||||||
|
@ -7905,13 +7908,13 @@ BfAstNode* BfReducer::CreateTopLevelObject(BfTokenNode* tokenNode, BfAttributeDi
|
||||||
{
|
{
|
||||||
if (auto nextTokenNode = BfNodeDynCast<BfTokenNode>(mVisitorPos.GetNext()))
|
if (auto nextTokenNode = BfNodeDynCast<BfTokenNode>(mVisitorPos.GetNext()))
|
||||||
{
|
{
|
||||||
if (nextTokenNode->mToken == BfToken_Static)
|
if ((nextTokenNode->mToken == BfToken_Static) || (nextTokenNode->mToken == BfToken_Internal))
|
||||||
{
|
{
|
||||||
auto usingDirective = mAlloc->Alloc<BfUsingStaticDirective>();
|
auto usingDirective = mAlloc->Alloc<BfUsingModDirective>();
|
||||||
ReplaceNode(tokenNode, usingDirective);
|
ReplaceNode(tokenNode, usingDirective);
|
||||||
usingDirective->mUsingToken = tokenNode;
|
usingDirective->mUsingToken = tokenNode;
|
||||||
|
|
||||||
MEMBER_SET(usingDirective, mStaticToken, nextTokenNode);
|
MEMBER_SET(usingDirective, mModToken, nextTokenNode);
|
||||||
mVisitorPos.MoveNext();
|
mVisitorPos.MoveNext();
|
||||||
|
|
||||||
auto typeRef = CreateTypeRefAfter(usingDirective);
|
auto typeRef = CreateTypeRefAfter(usingDirective);
|
||||||
|
@ -8029,6 +8032,7 @@ BfAstNode* BfReducer::CreateTopLevelObject(BfTokenNode* tokenNode, BfAttributeDi
|
||||||
case BfToken_Public:
|
case BfToken_Public:
|
||||||
case BfToken_Private:
|
case BfToken_Private:
|
||||||
case BfToken_Protected:
|
case BfToken_Protected:
|
||||||
|
case BfToken_Internal:
|
||||||
case BfToken_Static:
|
case BfToken_Static:
|
||||||
{
|
{
|
||||||
auto nextNode = mVisitorPos.GetNext();
|
auto nextNode = mVisitorPos.GetNext();
|
||||||
|
@ -8078,7 +8082,8 @@ BfAstNode* BfReducer::CreateTopLevelObject(BfTokenNode* tokenNode, BfAttributeDi
|
||||||
BfToken token = tokenNode->GetToken();
|
BfToken token = tokenNode->GetToken();
|
||||||
if ((token == BfToken_Public) ||
|
if ((token == BfToken_Public) ||
|
||||||
(token == BfToken_Protected) ||
|
(token == BfToken_Protected) ||
|
||||||
(token == BfToken_Private))
|
(token == BfToken_Private) ||
|
||||||
|
(token == BfToken_Internal))
|
||||||
{
|
{
|
||||||
if (typeDeclaration->mProtectionSpecifier != NULL)
|
if (typeDeclaration->mProtectionSpecifier != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
BfAutoComplete* mAutoComplete;
|
BfAutoComplete* mAutoComplete;
|
||||||
Array<BfTypeDef*> mAutoCompleteTempTypes; // Contains multiple values when we have nested types
|
Array<BfTypeDef*> mAutoCompleteTempTypes; // Contains multiple values when we have nested types
|
||||||
Dictionary<BfTypeDef*, BfStaticSearch> mStaticSearchMap;
|
Dictionary<BfTypeDef*, BfStaticSearch> mStaticSearchMap;
|
||||||
|
Dictionary<BfTypeDef*, BfInternalAccessSet> mInternalAccessMap;
|
||||||
BfSourceClassifier* mSourceClassifier;
|
BfSourceClassifier* mSourceClassifier;
|
||||||
Array<BfAstNode*> mExteriorAutocompleteCheckNodes;
|
Array<BfAstNode*> mExteriorAutocompleteCheckNodes;
|
||||||
|
|
||||||
|
|
|
@ -1411,6 +1411,7 @@ BfMethodInstanceGroup::~BfMethodInstanceGroup()
|
||||||
|
|
||||||
BfTypeInstance::~BfTypeInstance()
|
BfTypeInstance::~BfTypeInstance()
|
||||||
{
|
{
|
||||||
|
ReleaseData();
|
||||||
delete mTypeInfoEx;
|
delete mTypeInfoEx;
|
||||||
delete mGenericTypeInfo;
|
delete mGenericTypeInfo;
|
||||||
delete mCustomAttributes;
|
delete mCustomAttributes;
|
||||||
|
@ -1423,6 +1424,17 @@ BfTypeInstance::~BfTypeInstance()
|
||||||
delete mConstHolder;
|
delete mConstHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfTypeInstance::ReleaseData()
|
||||||
|
{
|
||||||
|
for (auto& kv : mInternalAccessMap)
|
||||||
|
{
|
||||||
|
auto& internalAcessSet = kv.mValue;
|
||||||
|
for (auto& namespaceComposite : internalAcessSet.mNamespaces)
|
||||||
|
mModule->mSystem->ReleaseAtomComposite(namespaceComposite);
|
||||||
|
}
|
||||||
|
mInternalAccessMap.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
int BfTypeInstance::GetSplatCount()
|
int BfTypeInstance::GetSplatCount()
|
||||||
{
|
{
|
||||||
if (IsValuelessType())
|
if (IsValuelessType())
|
||||||
|
@ -2797,6 +2809,8 @@ int BfResolvedTypeSet::DirectHash(BfTypeReference* typeRef, LookupContext* ctx,
|
||||||
|
|
||||||
BfTypeDef* BfResolvedTypeSet::FindRootCommonOuterType(BfTypeDef* outerType, LookupContext* ctx, BfTypeInstance*& outOuterTypeInstance)
|
BfTypeDef* BfResolvedTypeSet::FindRootCommonOuterType(BfTypeDef* outerType, LookupContext* ctx, BfTypeInstance*& outOuterTypeInstance)
|
||||||
{
|
{
|
||||||
|
if (ctx->mModule->mCurTypeInstance == NULL)
|
||||||
|
return NULL;
|
||||||
BfTypeDef* commonOuterType = ctx->mModule->FindCommonOuterType(ctx->mModule->mCurTypeInstance->mTypeDef, outerType);
|
BfTypeDef* commonOuterType = ctx->mModule->FindCommonOuterType(ctx->mModule->mCurTypeInstance->mTypeDef, outerType);
|
||||||
if ((commonOuterType == NULL) && (outerType != NULL))
|
if ((commonOuterType == NULL) && (outerType != NULL))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1654,6 +1654,13 @@ public:
|
||||||
Array<BfTypeInstance*> mStaticTypes;
|
Array<BfTypeInstance*> mStaticTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class BfInternalAccessSet
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Array<BfTypeInstance*> mTypes;
|
||||||
|
Array<BfAtomComposite> mNamespaces;
|
||||||
|
};
|
||||||
|
|
||||||
class BfTypeInfoEx
|
class BfTypeInfoEx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1760,6 +1767,7 @@ public:
|
||||||
Array<BfFieldInstance> mFieldInstances;
|
Array<BfFieldInstance> mFieldInstances;
|
||||||
Array<BfMethodInstance*> mInternalMethods;
|
Array<BfMethodInstance*> mInternalMethods;
|
||||||
Dictionary<BfTypeDef*, BfStaticSearch> mStaticSearchMap;
|
Dictionary<BfTypeDef*, BfStaticSearch> mStaticSearchMap;
|
||||||
|
Dictionary<BfTypeDef*, BfInternalAccessSet> mInternalAccessMap;
|
||||||
bool mHasStaticInitMethod;
|
bool mHasStaticInitMethod;
|
||||||
bool mHasStaticDtorMethod;
|
bool mHasStaticDtorMethod;
|
||||||
bool mHasStaticMarkMethod;
|
bool mHasStaticMarkMethod;
|
||||||
|
@ -1854,6 +1862,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
~BfTypeInstance();
|
~BfTypeInstance();
|
||||||
|
|
||||||
|
void ReleaseData();
|
||||||
|
|
||||||
virtual bool IsInstanceOf(BfTypeDef* typeDef) override { return typeDef == mTypeDef; }
|
virtual bool IsInstanceOf(BfTypeDef* typeDef) override { return typeDef == mTypeDef; }
|
||||||
virtual BfModule* GetModule() override { return mModule; }
|
virtual BfModule* GetModule() override { return mModule; }
|
||||||
|
|
|
@ -664,7 +664,7 @@ void BfSourceClassifier::Visit(BfUsingDirective* usingDirective)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfSourceClassifier::Visit(BfUsingStaticDirective* usingDirective)
|
void BfSourceClassifier::Visit(BfUsingModDirective* usingDirective)
|
||||||
{
|
{
|
||||||
BfElementVisitor::Visit(usingDirective);
|
BfElementVisitor::Visit(usingDirective);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ public:
|
||||||
virtual void Visit(BfTypeDeclaration* typeDeclaration) override;
|
virtual void Visit(BfTypeDeclaration* typeDeclaration) override;
|
||||||
virtual void Visit(BfTypeAliasDeclaration* typeDeclaration) override;
|
virtual void Visit(BfTypeAliasDeclaration* typeDeclaration) override;
|
||||||
virtual void Visit(BfUsingDirective* usingDirective) override;
|
virtual void Visit(BfUsingDirective* usingDirective) override;
|
||||||
virtual void Visit(BfUsingStaticDirective* usingDirective) override;
|
virtual void Visit(BfUsingModDirective* usingDirective) override;
|
||||||
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration) override;
|
virtual void Visit(BfNamespaceDeclaration* namespaceDeclaration) override;
|
||||||
virtual void Visit(BfBlock* block) override;
|
virtual void Visit(BfBlock* block) override;
|
||||||
virtual void Visit(BfRootNode* rootNode) override;
|
virtual void Visit(BfRootNode* rootNode) override;
|
||||||
|
|
|
@ -3923,7 +3923,7 @@ void BfModule::Visit(BfDeleteStatement* deleteStmt)
|
||||||
auto checkTypeDef = checkTypeInst->mTypeDef;
|
auto checkTypeDef = checkTypeInst->mTypeDef;
|
||||||
if (checkTypeDef->mDtorDef != NULL)
|
if (checkTypeDef->mDtorDef != NULL)
|
||||||
{
|
{
|
||||||
if (!CheckProtection(checkTypeDef->mDtorDef->mProtection, allowProtected, allowPrivate))
|
if (!CheckProtection(checkTypeDef->mDtorDef->mProtection, checkTypeInst->mTypeDef, allowProtected, allowPrivate))
|
||||||
{
|
{
|
||||||
auto error = Fail(StrFormat("'%s.~this()' is inaccessible due to its protection level", TypeToString(checkTypeInst).c_str()), deleteStmt->mExpression); // CS0122
|
auto error = Fail(StrFormat("'%s.~this()' is inaccessible due to its protection level", TypeToString(checkTypeInst).c_str()), deleteStmt->mExpression); // CS0122
|
||||||
}
|
}
|
||||||
|
|
|
@ -657,6 +657,7 @@ void BfTypeDef::FreeMembers()
|
||||||
mNamespaceSearch.Clear();
|
mNamespaceSearch.Clear();
|
||||||
|
|
||||||
mStaticSearch.Clear();
|
mStaticSearch.Clear();
|
||||||
|
mInternalAccessSet.Clear();
|
||||||
|
|
||||||
for (auto allocNode : mDirectAllocNodes)
|
for (auto allocNode : mDirectAllocNodes)
|
||||||
delete allocNode;
|
delete allocNode;
|
||||||
|
@ -832,6 +833,7 @@ void BfTypeDef::ReportMemory(MemReporter* memReporter)
|
||||||
memReporter->Add(sizeof(BfTypeDef));
|
memReporter->Add(sizeof(BfTypeDef));
|
||||||
memReporter->AddVec(mNamespaceSearch, false);
|
memReporter->AddVec(mNamespaceSearch, false);
|
||||||
memReporter->AddVec(mStaticSearch, false);
|
memReporter->AddVec(mStaticSearch, false);
|
||||||
|
memReporter->AddVec(mInternalAccessSet, false);
|
||||||
memReporter->AddVecPtr("Fields", mFields, false);
|
memReporter->AddVecPtr("Fields", mFields, false);
|
||||||
memReporter->AddVecPtr("Properties", mProperties, false);
|
memReporter->AddVecPtr("Properties", mProperties, false);
|
||||||
|
|
||||||
|
@ -2656,6 +2658,7 @@ void BfSystem::InjectNewRevision(BfTypeDef* typeDef)
|
||||||
RefAtomComposite(name);
|
RefAtomComposite(name);
|
||||||
|
|
||||||
typeDef->mStaticSearch = nextTypeDef->mStaticSearch;
|
typeDef->mStaticSearch = nextTypeDef->mStaticSearch;
|
||||||
|
typeDef->mInternalAccessSet = nextTypeDef->mInternalAccessSet;
|
||||||
|
|
||||||
for (auto prevField : typeDef->mFields)
|
for (auto prevField : typeDef->mFields)
|
||||||
{
|
{
|
||||||
|
|
|
@ -885,6 +885,7 @@ public:
|
||||||
BfProtection mProtection;
|
BfProtection mProtection;
|
||||||
Array<BfAtomComposite> mNamespaceSearch;
|
Array<BfAtomComposite> mNamespaceSearch;
|
||||||
Array<BfTypeReference*> mStaticSearch;
|
Array<BfTypeReference*> mStaticSearch;
|
||||||
|
Array<BfTypeReference*> mInternalAccessSet;
|
||||||
Array<BfFieldDef*> mFields;
|
Array<BfFieldDef*> mFields;
|
||||||
Array<BfPropertyDef*> mProperties;
|
Array<BfPropertyDef*> mProperties;
|
||||||
Array<BfMethodDef*> mMethods;
|
Array<BfMethodDef*> mMethods;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue