mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Removed 'internal' protection - it's all about [Friend] now
This commit is contained in:
parent
81af04a1ce
commit
14ac27c977
119 changed files with 1339 additions and 1388 deletions
|
@ -51,9 +51,9 @@ class BfPassInstance;
|
|||
enum BfProtection : uint8
|
||||
{
|
||||
BfProtection_Hidden,
|
||||
BfProtection_Private,
|
||||
BfProtection_Private,
|
||||
BfProtection_Protected,
|
||||
BfProtection_Public,
|
||||
BfProtection_Public
|
||||
};
|
||||
|
||||
enum BfCheckedKind : int8
|
||||
|
@ -64,7 +64,7 @@ enum BfCheckedKind : int8
|
|||
};
|
||||
|
||||
static bool CheckProtection(BfProtection protection, bool allowProtected, bool allowPrivate)
|
||||
{
|
||||
{
|
||||
return (protection == BfProtection_Public) ||
|
||||
((protection == BfProtection_Protected) && (allowProtected)) ||
|
||||
((protection == BfProtection_Private) && (allowPrivate));
|
||||
|
@ -2131,8 +2131,7 @@ public:
|
|||
BfCommentNode* mDocumentation;
|
||||
BfAttributeDirective* mAttributes;
|
||||
BfTokenNode* mAbstractSpecifier;
|
||||
BfTokenNode* mSealedSpecifier;
|
||||
BfTokenNode* mInternalSpecifier;
|
||||
BfTokenNode* mSealedSpecifier;
|
||||
BfTokenNode* mProtectionSpecifier;
|
||||
BfTokenNode* mStaticSpecifier;
|
||||
BfTokenNode* mPartialSpecifier;
|
||||
|
@ -2603,6 +2602,7 @@ public:
|
|||
BfTokenNode* mDeleteToken;
|
||||
BfTokenNode* mTargetTypeToken; // colon token
|
||||
BfAstNode* mAllocExpr;
|
||||
BfAttributeDirective* mAttributes;
|
||||
BfExpression* mExpression;
|
||||
}; BF_AST_DECL(BfDeleteStatement, BfStatement);
|
||||
|
||||
|
@ -2688,8 +2688,7 @@ class BfMemberDeclaration : public BfAstNode
|
|||
public:
|
||||
BF_AST_TYPE(BfMemberDeclaration, BfAstNode);
|
||||
|
||||
BfAttributeDirective* mAttributes;
|
||||
BfTokenNode* mInternalSpecifier;
|
||||
BfAttributeDirective* mAttributes;
|
||||
BfTokenNode* mProtectionSpecifier;
|
||||
BfTokenNode* mStaticSpecifier;
|
||||
BfTokenNode* mReadOnlySpecifier; // Also stores 'inline'
|
||||
|
|
|
@ -599,7 +599,7 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
|
|||
continue;
|
||||
|
||||
if ((CHECK_STATIC(fieldDef->mIsStatic)) &&
|
||||
((mIsGetDefinition) || (mModule->CheckProtection(protectionCheckFlags, typeInst, fieldDef->mProtection, startType))))
|
||||
((mIsGetDefinition) || (mModule->CheckProtection(protectionCheckFlags, typeInst, fieldDef->mDeclaringType->mProject, fieldDef->mProtection, startType))))
|
||||
{
|
||||
if ((!typeInst->IsTypeMemberIncluded(fieldDef->mDeclaringType, activeTypeDef, mModule)) ||
|
||||
(!typeInst->IsTypeMemberAccessible(fieldDef->mDeclaringType, activeTypeDef)))
|
||||
|
@ -644,7 +644,7 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
|
|||
else
|
||||
{
|
||||
canUseMethod &= (CHECK_STATIC(methodDef->mIsStatic) &&
|
||||
(mModule->CheckProtection(protectionCheckFlags, typeInst, methodDef->mProtection, startType)));
|
||||
(mModule->CheckProtection(protectionCheckFlags, typeInst, methodDef->mDeclaringType->mProject, methodDef->mProtection, startType)));
|
||||
}
|
||||
if (canUseMethod)
|
||||
{
|
||||
|
@ -661,7 +661,7 @@ void BfAutoComplete::AddTypeMembers(BfTypeInstance* typeInst, bool addStatic, bo
|
|||
(!typeInst->IsTypeMemberAccessible(propDef->mDeclaringType, activeTypeDef)))
|
||||
continue;
|
||||
|
||||
if ((CHECK_STATIC(propDef->mIsStatic)) && (mModule->CheckProtection(protectionCheckFlags, typeInst, propDef->mProtection, startType)))
|
||||
if ((CHECK_STATIC(propDef->mIsStatic)) && (mModule->CheckProtection(protectionCheckFlags, typeInst, propDef->mDeclaringType->mProject, propDef->mProtection, startType)))
|
||||
{
|
||||
if ((!allowInterfaces) && (propDef->HasExplicitInterface()))
|
||||
continue;
|
||||
|
|
|
@ -370,7 +370,7 @@ void BfDefBuilder::ParseGenericParams(BfGenericParamsDeclaration* genericParamsD
|
|||
}
|
||||
|
||||
BfProtection BfDefBuilder::GetProtection(BfTokenNode* protectionToken)
|
||||
{
|
||||
{
|
||||
if (protectionToken == NULL)
|
||||
{
|
||||
if (mCurTypeDef->mTypeCode == BfTypeCode_Interface)
|
||||
|
@ -380,9 +380,9 @@ BfProtection BfDefBuilder::GetProtection(BfTokenNode* protectionToken)
|
|||
}
|
||||
|
||||
if (protectionToken->GetToken() == BfToken_Public)
|
||||
return BfProtection_Public;
|
||||
return BfProtection_Public;
|
||||
if (protectionToken->GetToken() == BfToken_Protected)
|
||||
return BfProtection_Protected;
|
||||
return BfProtection_Protected;
|
||||
return BfProtection_Private;
|
||||
}
|
||||
|
||||
|
@ -412,11 +412,7 @@ BfMethodDef* BfDefBuilder::CreateMethodDef(BfMethodDeclaration* methodDeclaratio
|
|||
methodDef->mMethodDeclaration = methodDeclaration;
|
||||
methodDef->mExplicitInterface = methodDeclaration->mExplicitInterface;
|
||||
methodDef->mReturnTypeRef = methodDeclaration->mReturnType;
|
||||
methodDef->mProtection = GetProtection(methodDeclaration->mProtectionSpecifier);
|
||||
//if (mCurTypeDef->mIsPartial)
|
||||
//methodDef->mProtection = BfProtection_Public;
|
||||
if (methodDeclaration->mInternalSpecifier != NULL) // TODO: Do this properly
|
||||
methodDef->mProtection = BfProtection_Public;
|
||||
methodDef->mProtection = GetProtection(methodDeclaration->mProtectionSpecifier);
|
||||
methodDef->mIsReadOnly = methodDeclaration->mReadOnlySpecifier != NULL;
|
||||
methodDef->mIsStatic = methodDeclaration->mStaticSpecifier != NULL;
|
||||
methodDef->mIsVirtual = methodDeclaration->mVirtualSpecifier != NULL;
|
||||
|
@ -826,9 +822,7 @@ void BfDefBuilder::Visit(BfPropertyDeclaration* propertyDeclaration)
|
|||
|
||||
BfPropertyDef* propertyDef = new BfPropertyDef();
|
||||
mCurTypeDef->mProperties.push_back(propertyDef);
|
||||
propertyDef->mProtection = GetProtection(propertyDeclaration->mProtectionSpecifier);
|
||||
if (propertyDeclaration->mInternalSpecifier != NULL) // TODO: Do this properly
|
||||
propertyDef->mProtection = BfProtection_Public;
|
||||
propertyDef->mProtection = GetProtection(propertyDeclaration->mProtectionSpecifier);
|
||||
propertyDef->mIdx = (int)mCurTypeDef->mProperties.size() - 1;
|
||||
propertyDef->mIsConst = false;
|
||||
propertyDef->mIsStatic = propertyDeclaration->mStaticSpecifier != NULL;
|
||||
|
@ -1013,9 +1007,7 @@ void BfDefBuilder::Visit(BfFieldDeclaration* fieldDeclaration)
|
|||
if (mCurTypeDef->mIsPartial)
|
||||
fieldDef->mProtection = BfProtection_Public;
|
||||
else if (isEnumEntryDecl)
|
||||
fieldDef->mProtection = BfProtection_Public;
|
||||
if (fieldDeclaration->mInternalSpecifier != NULL) // TODO: Do this properly
|
||||
fieldDef->mProtection = BfProtection_Public;
|
||||
fieldDef->mProtection = BfProtection_Public;
|
||||
fieldDef->mIsReadOnly = fieldDeclaration->mReadOnlySpecifier != NULL;
|
||||
fieldDef->mIsInline = (fieldDeclaration->mReadOnlySpecifier != NULL) && (fieldDeclaration->mReadOnlySpecifier->GetToken() == BfToken_Inline);
|
||||
fieldDef->mIsExtern = (fieldDeclaration->mExternSpecifier != NULL);
|
||||
|
@ -1271,15 +1263,13 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration)
|
|||
|
||||
BfLogSys(mCurSource->mSystem, "DefBuilder %p %p TypeDecl:%s\n", mCurTypeDef, mCurSource, mCurTypeDef->mName->ToString().mPtr);
|
||||
|
||||
mCurTypeDef->mProtection = (outerTypeDef == NULL) ? BfProtection_Public : BfProtection_Private;
|
||||
if (typeDeclaration->mInternalSpecifier != NULL)
|
||||
mCurTypeDef->mProtection = BfProtection_Public;
|
||||
mCurTypeDef->mProtection = (outerTypeDef == NULL) ? BfProtection_Public : BfProtection_Private;
|
||||
if (typeDeclaration->mProtectionSpecifier != NULL)
|
||||
{
|
||||
if ((outerTypeDef == NULL) && (typeDeclaration->mProtectionSpecifier->GetToken() != BfToken_Public))
|
||||
{
|
||||
//CS1527
|
||||
Fail("Elements defined in a namespace cannot be explicitly declared as private, protected, or protected internal", typeDeclaration->mProtectionSpecifier);
|
||||
Fail("Elements defined in a namespace cannot be explicitly declared as private or protected", typeDeclaration->mProtectionSpecifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1305,8 +1295,7 @@ void BfDefBuilder::Visit(BfTypeDeclaration* typeDeclaration)
|
|||
HashNode(*mSignatureHashCtx, baseClassNode);
|
||||
HashNode(*mSignatureHashCtx, typeDeclaration->mAttributes);
|
||||
HashNode(*mSignatureHashCtx, typeDeclaration->mAbstractSpecifier);
|
||||
HashNode(*mSignatureHashCtx, typeDeclaration->mSealedSpecifier);
|
||||
HashNode(*mSignatureHashCtx, typeDeclaration->mInternalSpecifier);
|
||||
HashNode(*mSignatureHashCtx, typeDeclaration->mSealedSpecifier);
|
||||
HashNode(*mSignatureHashCtx, typeDeclaration->mProtectionSpecifier);
|
||||
HashNode(*mSignatureHashCtx, typeDeclaration->mPartialSpecifier);
|
||||
HashNode(*mSignatureHashCtx, typeDeclaration->mNameNode);
|
||||
|
|
|
@ -966,8 +966,7 @@ void BfElementVisitor::Visit(BfMethodDeclaration* methodDeclaration)
|
|||
{
|
||||
Visit(methodDeclaration->ToBase());
|
||||
|
||||
VisitChild(methodDeclaration->mAttributes);
|
||||
VisitChild(methodDeclaration->mInternalSpecifier);
|
||||
VisitChild(methodDeclaration->mAttributes);
|
||||
VisitChild(methodDeclaration->mProtectionSpecifier);
|
||||
VisitChild(methodDeclaration->mReadOnlySpecifier);
|
||||
VisitChild(methodDeclaration->mStaticSpecifier);
|
||||
|
@ -1027,8 +1026,7 @@ void BfElementVisitor::Visit(BfPropertyDeclaration* propertyDeclaration)
|
|||
{
|
||||
Visit(propertyDeclaration->ToBase());
|
||||
|
||||
VisitChild(propertyDeclaration->mAttributes);
|
||||
VisitChild(propertyDeclaration->mInternalSpecifier);
|
||||
VisitChild(propertyDeclaration->mAttributes);
|
||||
VisitChild(propertyDeclaration->mProtectionSpecifier);
|
||||
VisitChild(propertyDeclaration->mStaticSpecifier);
|
||||
|
||||
|
@ -1068,8 +1066,7 @@ void BfElementVisitor::Visit(BfFieldDeclaration* fieldDeclaration)
|
|||
{
|
||||
Visit(fieldDeclaration->ToBase());
|
||||
|
||||
VisitChild(fieldDeclaration->mAttributes);
|
||||
VisitChild(fieldDeclaration->mInternalSpecifier);
|
||||
VisitChild(fieldDeclaration->mAttributes);
|
||||
VisitChild(fieldDeclaration->mProtectionSpecifier);
|
||||
VisitChild(fieldDeclaration->mStaticSpecifier);
|
||||
|
||||
|
@ -1112,8 +1109,7 @@ void BfElementVisitor::Visit(BfTypeDeclaration* typeDeclaration)
|
|||
|
||||
VisitChild(typeDeclaration->mAttributes);
|
||||
VisitChild(typeDeclaration->mAbstractSpecifier);
|
||||
VisitChild(typeDeclaration->mSealedSpecifier);
|
||||
VisitChild(typeDeclaration->mInternalSpecifier);
|
||||
VisitChild(typeDeclaration->mSealedSpecifier);
|
||||
VisitChild(typeDeclaration->mProtectionSpecifier);
|
||||
VisitChild(typeDeclaration->mStaticSpecifier);
|
||||
VisitChild(typeDeclaration->mPartialSpecifier);
|
||||
|
|
|
@ -1003,8 +1003,8 @@ BfTypedValue BfMethodMatcher::ResolveArgTypedValue(BfResolvedArg& resolvedArg, B
|
|||
|
||||
bool BfMethodMatcher::WantsCheckMethod(BfProtectionCheckFlags& flags, BfTypeInstance* startTypeInstance, BfTypeInstance* checkTypeInstance, BfMethodDef* checkMethod)
|
||||
{
|
||||
MatchFailKind matchFailKind = MatchFailKind_None;
|
||||
if (!mModule->CheckProtection(flags, checkTypeInstance, checkMethod->mProtection, startTypeInstance))
|
||||
MatchFailKind matchFailKind = MatchFailKind_None;
|
||||
if (!mModule->CheckProtection(flags, checkTypeInstance, checkMethod->mDeclaringType->mProject, checkMethod->mProtection, startTypeInstance))
|
||||
{
|
||||
if ((mBypassVirtual) && (checkMethod->mProtection == BfProtection_Protected) && (mModule->TypeIsSubTypeOf(mModule->mCurTypeInstance, startTypeInstance)))
|
||||
{
|
||||
|
@ -1777,7 +1777,7 @@ bool BfMethodMatcher::CheckType(BfTypeInstance* typeInstance, BfTypedValue targe
|
|||
}
|
||||
|
||||
MatchFailKind matchFailKind = MatchFailKind_None;
|
||||
if (!mModule->CheckProtection(protectionCheckFlags, curTypeInst, checkMethod->mProtection, typeInstance))
|
||||
if (!mModule->CheckProtection(protectionCheckFlags, curTypeInst, checkMethod->mDeclaringType->mProject, checkMethod->mProtection, typeInstance))
|
||||
{
|
||||
if ((mBypassVirtual) && (checkMethod->mProtection == BfProtection_Protected) && (mModule->TypeIsSubTypeOf(mModule->mCurTypeInstance, typeInstance)))
|
||||
{
|
||||
|
@ -3307,7 +3307,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
auto field = nextField;
|
||||
nextField = nextField->mNextWithSameName;
|
||||
|
||||
if ((!isFailurePass) && (!mModule->CheckProtection(protectionCheckFlags, curCheckType, field->mProtection, startCheckType)))
|
||||
if ((!isFailurePass) && (!mModule->CheckProtection(protectionCheckFlags, curCheckType, field->mDeclaringType->mProject, field->mProtection, startCheckType)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -3721,7 +3721,7 @@ BfTypedValue BfExprEvaluator::LookupField(BfAstNode* targetSrc, BfTypedValue tar
|
|||
auto prop = nextProp;
|
||||
nextProp = nextProp->mNextWithSameName;
|
||||
|
||||
if ((!isFailurePass) && (!mModule->CheckProtection(protectionCheckFlags, curCheckType, prop->mProtection, startCheckType)))
|
||||
if ((!isFailurePass) && (!mModule->CheckProtection(protectionCheckFlags, curCheckType, prop->mDeclaringType->mProject, prop->mProtection, startCheckType)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -5666,8 +5666,8 @@ BfTypedValue BfExprEvaluator::MatchConstructor(BfAstNode* targetSrc, BfMethodBou
|
|||
else
|
||||
{
|
||||
if (checkProt == BfProtection_Protected) // Treat protected constructors as private
|
||||
checkProt = BfProtection_Private;
|
||||
if (!mModule->CheckProtection(protectionCheckFlags, curTypeInst, checkProt, curTypeInst))
|
||||
checkProt = BfProtection_Private;
|
||||
if (!mModule->CheckProtection(protectionCheckFlags, curTypeInst, checkMethod->mDeclaringType->mProject, checkProt, curTypeInst))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -10888,9 +10888,12 @@ void BfExprEvaluator::Visit(BfObjectCreateExpression* objCreateExpr)
|
|||
//if (objCreateExpr->mArraySizeSpecifier == NULL)
|
||||
CheckObjectCreateTypeRef(mExpectingType, objCreateExpr->mNewNode);
|
||||
|
||||
BfAttributeState attributeState;
|
||||
attributeState.mTarget = BfAttributeTargets_Alloc;
|
||||
SetAndRestoreValue<BfAttributeState*> prevAttributeState(mModule->mAttributeState, &attributeState);
|
||||
BfTokenNode* newToken = NULL;
|
||||
BfAllocTarget allocTarget = ResolveAllocTarget(objCreateExpr->mNewNode, newToken);
|
||||
|
||||
BfAllocTarget allocTarget = ResolveAllocTarget(objCreateExpr->mNewNode, newToken, &attributeState.mCustomAttributes);
|
||||
|
||||
bool isScopeAlloc = newToken->GetToken() == BfToken_Scope;
|
||||
bool isAppendAlloc = newToken->GetToken() == BfToken_Append;
|
||||
bool isStackAlloc = (newToken->GetToken() == BfToken_Stack) || (isScopeAlloc);
|
||||
|
@ -11882,7 +11885,7 @@ void BfExprEvaluator::Visit(BfBoxExpression* boxExpr)
|
|||
}
|
||||
}
|
||||
|
||||
BfAllocTarget BfExprEvaluator::ResolveAllocTarget(BfAstNode* allocNode, BfTokenNode*& newToken)
|
||||
BfAllocTarget BfExprEvaluator::ResolveAllocTarget(BfAstNode* allocNode, BfTokenNode*& newToken, BfCustomAttributes** outCustomAttributes)
|
||||
{
|
||||
auto autoComplete = GetAutoComplete();
|
||||
BfAttributeDirective* attributeDirective = NULL;
|
||||
|
@ -11941,7 +11944,7 @@ BfAllocTarget BfExprEvaluator::ResolveAllocTarget(BfAstNode* allocNode, BfTokenN
|
|||
if (attrib.mType->mTypeDef == mModule->mCompiler->mAlignAttributeTypeDef)
|
||||
{
|
||||
allocTarget.mAlignOverride = 16; // System conservative default
|
||||
|
||||
|
||||
if (!attrib.mCtorArgs.IsEmpty())
|
||||
{
|
||||
BfIRConstHolder* constHolder = mModule->mCurTypeInstance->mConstHolder;
|
||||
|
@ -11952,13 +11955,18 @@ BfAllocTarget BfExprEvaluator::ResolveAllocTarget(BfAstNode* allocNode, BfTokenN
|
|||
if ((alignOverride & (alignOverride - 1)) == 0)
|
||||
allocTarget.mAlignOverride = alignOverride;
|
||||
else
|
||||
mModule->Fail("Alignment must be a power of 2", attrib.GetRefNode());
|
||||
mModule->Fail("Alignment must be a power of 2", attrib.GetRefNode());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (attrib.mType->mTypeDef == mModule->mCompiler->mFriendAttributeTypeDef)
|
||||
allocTarget.mIsFriend = true;
|
||||
}
|
||||
|
||||
delete customAttrs;
|
||||
if (outCustomAttributes != NULL)
|
||||
*outCustomAttributes = customAttrs;
|
||||
else
|
||||
delete customAttrs;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -325,7 +325,7 @@ public:
|
|||
BfType* ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType populateType = BfPopulateType_Data, BfResolveTypeRefFlags resolveFlags = (BfResolveTypeRefFlags)0);
|
||||
void ResolveGenericType();
|
||||
void ResolveArgValues(BfResolvedArgs& resolvedArgs, BfResolveArgFlags flags = BfResolveArgFlag_None);
|
||||
BfAllocTarget ResolveAllocTarget(BfAstNode* newNode, BfTokenNode*& newToken);
|
||||
BfAllocTarget ResolveAllocTarget(BfAstNode* newNode, BfTokenNode*& newToken, BfCustomAttributes** outCustomAttributes = NULL);
|
||||
BfTypedValue ResolveArgValue(BfResolvedArg& resolvedArg, BfType* wantType, BfTypedValue* receivingValue = NULL, BfParamKind paramKind = BfParamKind_Normal);
|
||||
BfMethodDef* GetPropertyMethodDef(BfPropertyDef* propDef, BfMethodType methodType, BfCheckedKind checkedKind);
|
||||
BfModuleMethodInstance GetPropertyMethodInstance(BfMethodDef* methodDef);
|
||||
|
|
|
@ -2339,8 +2339,8 @@ void BfModule::GetAccessAllowed(BfTypeInstance* checkType, bool &allowProtected,
|
|||
allowProtected = allowPrivate;
|
||||
}
|
||||
|
||||
bool BfModule::CheckProtection(BfProtectionCheckFlags& flags, BfTypeInstance* memberOwner, BfProtection memberProtection, BfTypeInstance* lookupStartType)
|
||||
{
|
||||
bool BfModule::CheckProtection(BfProtectionCheckFlags& flags, BfTypeInstance* memberOwner, BfProject* memberProject, BfProtection memberProtection, BfTypeInstance* lookupStartType)
|
||||
{
|
||||
if (memberProtection == BfProtection_Hidden)
|
||||
return false;
|
||||
if (memberProtection == BfProtection_Public)
|
||||
|
|
|
@ -476,6 +476,7 @@ public:
|
|||
BfScopedInvocationTarget* mScopedInvocationTarget;
|
||||
int mAlignOverride;
|
||||
BfCaptureInfo mCaptureInfo;
|
||||
bool mIsFriend;
|
||||
|
||||
public:
|
||||
BfAllocTarget()
|
||||
|
@ -485,6 +486,7 @@ public:
|
|||
mCustomAllocator = NULL;
|
||||
mScopedInvocationTarget = NULL;
|
||||
mAlignOverride = -1;
|
||||
mIsFriend = false;
|
||||
}
|
||||
|
||||
BfAllocTarget(BfScopeData* scopeData)
|
||||
|
@ -1405,7 +1407,7 @@ public:
|
|||
void AddMethodReference(const BfMethodRef& methodRef, BfGetMethodInstanceFlags flags = BfGetMethodInstanceFlag_None);
|
||||
bool CheckProtection(BfProtection protection, bool allowProtected, bool allowPrivate);
|
||||
void GetAccessAllowed(BfTypeInstance* checkType, bool& allowProtected, bool& allowPrivate);
|
||||
bool CheckProtection(BfProtectionCheckFlags& flags, BfTypeInstance* memberOwner, BfProtection memberProtection, BfTypeInstance* lookupStartType);
|
||||
bool CheckProtection(BfProtectionCheckFlags& flags, BfTypeInstance* memberOwner, BfProject* memberProject, BfProtection memberProtection, BfTypeInstance* lookupStartType);
|
||||
void SetElementType(BfAstNode* astNode, BfSourceElementType elementType);
|
||||
BfError* Fail(const StringImpl& error, BfAstNode* refNode = NULL, bool isPersistent = false);
|
||||
BfError* FailAfter(const StringImpl& error, BfAstNode* refNode);
|
||||
|
@ -1584,6 +1586,7 @@ public:
|
|||
bool ShouldAllowMultipleDefinitions(BfTypeInstance* typeInst, BfTypeDef* firstDeclaringTypeDef, BfTypeDef* secondDeclaringTypeDef);
|
||||
void CheckInjectNewRevision(BfTypeInstance* typeInstance);
|
||||
bool InitType(BfType* resolvedTypeRef, BfPopulateType populateType);
|
||||
BfProtection FixProtection(BfProtection protection, BfProject* defProject);
|
||||
bool CheckAccessMemberProtection(BfProtection protection, BfType* memberType);
|
||||
bool CheckDefineMemberProtection(BfProtection protection, BfType* memberType);
|
||||
void CheckMemberNames(BfTypeInstance* typeInst);
|
||||
|
|
|
@ -485,7 +485,6 @@ bool BfModule::InitType(BfType* resolvedTypeRef, BfPopulateType populateType)
|
|||
return PopulateType(resolvedTypeRef, populateType);
|
||||
}
|
||||
|
||||
|
||||
void BfModule::AddFieldDependency(BfTypeInstance* typeInstance, BfFieldInstance* fieldInstance, BfType* fieldType)
|
||||
{
|
||||
auto fieldTypeInstance = fieldType->ToTypeInstance();
|
||||
|
|
|
@ -1910,9 +1910,7 @@ void BfPrinter::Visit(BfConstructorDeclaration* ctorDeclaration)
|
|||
|
||||
QueueVisitChild(ctorDeclaration->mAttributes);
|
||||
ExpectNewLine();
|
||||
QueueVisitChild(ctorDeclaration->mProtectionSpecifier);
|
||||
ExpectSpace();
|
||||
QueueVisitChild(ctorDeclaration->mInternalSpecifier);
|
||||
QueueVisitChild(ctorDeclaration->mProtectionSpecifier);
|
||||
ExpectSpace();
|
||||
QueueVisitChild(ctorDeclaration->mNewSpecifier);
|
||||
ExpectSpace();
|
||||
|
@ -1958,9 +1956,7 @@ void BfPrinter::Visit(BfDestructorDeclaration* dtorDeclaration)
|
|||
|
||||
QueueVisitChild(dtorDeclaration->mAttributes);
|
||||
ExpectNewLine();
|
||||
QueueVisitChild(dtorDeclaration->mProtectionSpecifier);
|
||||
ExpectSpace();
|
||||
QueueVisitChild(dtorDeclaration->mInternalSpecifier);
|
||||
QueueVisitChild(dtorDeclaration->mProtectionSpecifier);
|
||||
ExpectSpace();
|
||||
QueueVisitChild(dtorDeclaration->mNewSpecifier);
|
||||
ExpectSpace();
|
||||
|
@ -2016,13 +2012,7 @@ void BfPrinter::QueueMethodDeclaration(BfMethodDeclaration* methodDeclaration)
|
|||
ExpectSpace();
|
||||
QueueVisitChild(methodDeclaration->mProtectionSpecifier);
|
||||
}
|
||||
|
||||
if (methodDeclaration->mInternalSpecifier != NULL)
|
||||
{
|
||||
ExpectSpace();
|
||||
QueueVisitChild(methodDeclaration->mInternalSpecifier);
|
||||
}
|
||||
|
||||
|
||||
if (methodDeclaration->mNewSpecifier != NULL)
|
||||
{
|
||||
ExpectSpace();
|
||||
|
@ -2146,9 +2136,7 @@ void BfPrinter::Visit(BfPropertyDeclaration* propertyDeclaration)
|
|||
|
||||
ExpectNewLine();
|
||||
QueueVisitChild(propertyDeclaration->mAttributes);
|
||||
ExpectNewLine();
|
||||
QueueVisitChild(propertyDeclaration->mInternalSpecifier);
|
||||
ExpectSpace();
|
||||
ExpectNewLine();
|
||||
QueueVisitChild(propertyDeclaration->mProtectionSpecifier);
|
||||
ExpectSpace();
|
||||
QueueVisitChild(propertyDeclaration->mConstSpecifier);
|
||||
|
@ -2238,9 +2226,7 @@ void BfPrinter::Visit(BfFieldDeclaration* fieldDeclaration)
|
|||
{
|
||||
QueueVisitChild(fieldDeclaration->mAttributes);
|
||||
ExpectNewLine();
|
||||
}
|
||||
QueueVisitChild(fieldDeclaration->mInternalSpecifier);
|
||||
ExpectSpace();
|
||||
}
|
||||
QueueVisitChild(fieldDeclaration->mProtectionSpecifier);
|
||||
ExpectSpace();
|
||||
QueueVisitChild(fieldDeclaration->mConstSpecifier);
|
||||
|
@ -2356,9 +2342,7 @@ void BfPrinter::Visit(BfTypeDeclaration* typeDeclaration)
|
|||
QueueVisitChild(typeDeclaration->mAbstractSpecifier);
|
||||
ExpectSpace();
|
||||
QueueVisitChild(typeDeclaration->mSealedSpecifier);
|
||||
ExpectSpace();
|
||||
QueueVisitChild(typeDeclaration->mInternalSpecifier);
|
||||
ExpectSpace();
|
||||
ExpectSpace();
|
||||
QueueVisitChild(typeDeclaration->mProtectionSpecifier);
|
||||
ExpectSpace();
|
||||
QueueVisitChild(typeDeclaration->mStaticSpecifier);
|
||||
|
|
|
@ -3543,11 +3543,7 @@ BfAstNode* BfReducer::DoCreateStatement(BfAstNode* node, CreateStmtFlags createS
|
|||
auto nextNode = mVisitorPos.GetNext();
|
||||
if ((tokenNode = BfNodeDynCast<BfTokenNode>(nextNode)))
|
||||
{
|
||||
if (tokenNode->GetToken() == BfToken_Append)
|
||||
{
|
||||
MEMBER_SET(deleteStmt, mTargetTypeToken, tokenNode);
|
||||
}
|
||||
else if (tokenNode->GetToken() == BfToken_Colon)
|
||||
if (tokenNode->GetToken() == BfToken_Colon)
|
||||
{
|
||||
MEMBER_SET(deleteStmt, mTargetTypeToken, tokenNode);
|
||||
mVisitorPos.MoveNext();
|
||||
|
@ -3572,6 +3568,19 @@ BfAstNode* BfReducer::DoCreateStatement(BfAstNode* node, CreateStmtFlags createS
|
|||
}
|
||||
}
|
||||
|
||||
nextNode = mVisitorPos.GetNext();
|
||||
if ((tokenNode = BfNodeDynCast<BfTokenNode>(nextNode)))
|
||||
{
|
||||
if (tokenNode->mToken == BfToken_LBracket)
|
||||
{
|
||||
mVisitorPos.MoveNext();
|
||||
auto attrib = CreateAttributeDirective(tokenNode);
|
||||
if (attrib == NULL)
|
||||
return deleteStmt;
|
||||
MEMBER_SET(deleteStmt, mAttributes, attrib);
|
||||
}
|
||||
}
|
||||
|
||||
auto expr = CreateExpressionAfter(deleteStmt);
|
||||
MEMBER_SET_CHECKED(deleteStmt, mExpression, expr);
|
||||
return deleteStmt;
|
||||
|
@ -5468,8 +5477,7 @@ BfFieldDeclaration* BfReducer::CreateFieldDeclaration(BfTokenNode* tokenNode, Bf
|
|||
MEMBER_SET(fieldDeclaration, mPrecedingComma, tokenNode);
|
||||
MEMBER_SET(fieldDeclaration, mNameNode, nameIdentifier);
|
||||
fieldDeclaration->mDocumentation = prevFieldDeclaration->mDocumentation;
|
||||
fieldDeclaration->mAttributes = prevFieldDeclaration->mAttributes;
|
||||
fieldDeclaration->mInternalSpecifier = prevFieldDeclaration->mInternalSpecifier;
|
||||
fieldDeclaration->mAttributes = prevFieldDeclaration->mAttributes;
|
||||
fieldDeclaration->mProtectionSpecifier = prevFieldDeclaration->mProtectionSpecifier;
|
||||
fieldDeclaration->mStaticSpecifier = prevFieldDeclaration->mStaticSpecifier;
|
||||
fieldDeclaration->mTypeRef = prevFieldDeclaration->mTypeRef;
|
||||
|
@ -5799,8 +5807,7 @@ BfAstNode* BfReducer::ReadTypeMember(BfTokenNode* tokenNode, int depth)
|
|||
case BfToken_Virtual:
|
||||
case BfToken_Override:
|
||||
case BfToken_Abstract:
|
||||
case BfToken_Concrete:
|
||||
case BfToken_Internal:
|
||||
case BfToken_Concrete:
|
||||
case BfToken_Extern:
|
||||
case BfToken_New:
|
||||
case BfToken_Implicit:
|
||||
|
@ -5874,18 +5881,7 @@ BfAstNode* BfReducer::ReadTypeMember(BfTokenNode* tokenNode, int depth)
|
|||
MEMBER_SET(memberDecl, mProtectionSpecifier, tokenNode);
|
||||
return memberDecl;
|
||||
}
|
||||
|
||||
if (token == BfToken_Internal)
|
||||
{
|
||||
if (memberDecl->mInternalSpecifier != NULL)
|
||||
{
|
||||
AddErrorNode(memberDecl->mInternalSpecifier);
|
||||
Fail("Internal already specified", memberDecl->mInternalSpecifier);
|
||||
}
|
||||
MEMBER_SET(memberDecl, mInternalSpecifier, tokenNode);
|
||||
return memberDecl;
|
||||
}
|
||||
|
||||
|
||||
if (auto methodDecl = BfNodeDynCast<BfMethodDeclaration>(memberDecl))
|
||||
{
|
||||
if ((token == BfToken_Virtual) ||
|
||||
|
@ -6029,12 +6025,6 @@ BfAstNode* BfReducer::ReadTypeMember(BfTokenNode* tokenNode, int depth)
|
|||
handled = true;
|
||||
}
|
||||
|
||||
if (token == BfToken_Internal)
|
||||
{
|
||||
MEMBER_SET(fieldDecl, mInternalSpecifier, tokenNode);
|
||||
handled = true;
|
||||
}
|
||||
|
||||
if (token == BfToken_New)
|
||||
{
|
||||
if (fieldDecl->mNewSpecifier != NULL)
|
||||
|
@ -6103,8 +6093,7 @@ void BfReducer::ReadPropertyBlock(BfPropertyDeclaration* propertyDeclaration, Bf
|
|||
token = tokenNode->GetToken();
|
||||
if ((token == BfToken_Private) ||
|
||||
(token == BfToken_Protected) ||
|
||||
(token == BfToken_Public) ||
|
||||
(token == BfToken_Internal))
|
||||
(token == BfToken_Public))
|
||||
{
|
||||
if (protectionSpecifier != NULL)
|
||||
{
|
||||
|
@ -7718,8 +7707,7 @@ BfAstNode* BfReducer::CreateTopLevelObject(BfTokenNode* tokenNode, BfAttributeDi
|
|||
|
||||
case BfToken_Sealed:
|
||||
case BfToken_Abstract:
|
||||
case BfToken_Concrete:
|
||||
case BfToken_Internal:
|
||||
case BfToken_Concrete:
|
||||
case BfToken_Public:
|
||||
case BfToken_Private:
|
||||
case BfToken_Protected:
|
||||
|
@ -7780,16 +7768,7 @@ BfAstNode* BfReducer::CreateTopLevelObject(BfTokenNode* tokenNode, BfAttributeDi
|
|||
}
|
||||
MEMBER_SET(typeDeclaration, mProtectionSpecifier, tokenNode);
|
||||
}
|
||||
|
||||
if (token == BfToken_Internal)
|
||||
{
|
||||
if (typeDeclaration->mInternalSpecifier != NULL)
|
||||
{
|
||||
Fail("Internal already specified", typeDeclaration->mInternalSpecifier);
|
||||
}
|
||||
MEMBER_SET(typeDeclaration, mInternalSpecifier, tokenNode);
|
||||
}
|
||||
|
||||
|
||||
if (token == BfToken_Static)
|
||||
{
|
||||
if (typeDeclaration->mStaticSpecifier != NULL)
|
||||
|
|
|
@ -1418,7 +1418,8 @@ enum BfAttributeTargets : int32
|
|||
BfAttributeTargets_Invocation = 0x10000,
|
||||
BfAttributeTargets_MemberAccess = 0x20000,
|
||||
BfAttributeTargets_Alloc = 0x40000,
|
||||
BfAttributeTargets_All = 0x3FFFF
|
||||
BfAttributeTargets_Delete = 0x80000,
|
||||
BfAttributeTargets_All = 0xFFFFF
|
||||
};
|
||||
|
||||
class BfAttributeData
|
||||
|
|
|
@ -3626,6 +3626,11 @@ void BfModule::Visit(BfDeleteStatement* deleteStmt)
|
|||
}
|
||||
}
|
||||
|
||||
BfAttributeState attributeState;
|
||||
attributeState.mTarget = BfAttributeTargets_Delete;
|
||||
SetAndRestoreValue<BfAttributeState*> prevAttributeState(mAttributeState, &attributeState);
|
||||
attributeState.mCustomAttributes = GetCustomAttributes(deleteStmt->mAttributes, attributeState.mTarget);
|
||||
|
||||
if (deleteStmt->mExpression == NULL)
|
||||
{
|
||||
AssertErrorState();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue