mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +02:00
Allow attributes on local methods
This commit is contained in:
parent
8567072eef
commit
f081365dab
4 changed files with 24 additions and 8 deletions
|
@ -4134,7 +4134,7 @@ BfAstNode* BfReducer::DoCreateStatement(BfAstNode* node, CreateStmtFlags createS
|
|||
}
|
||||
else if (token == BfToken_LBracket)
|
||||
{
|
||||
return CreateAttributedStatement(tokenNode);
|
||||
return CreateAttributedStatement(tokenNode, createStmtFlags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5663,15 +5663,23 @@ Do_RBracket:
|
|||
return attributeDirective;
|
||||
}
|
||||
|
||||
BfStatement* BfReducer::CreateAttributedStatement(BfTokenNode* tokenNode)
|
||||
BfStatement* BfReducer::CreateAttributedStatement(BfTokenNode* tokenNode, CreateStmtFlags createStmtFlags)
|
||||
{
|
||||
auto attrib = CreateAttributeDirective(tokenNode);
|
||||
if (attrib == NULL)
|
||||
return NULL;
|
||||
|
||||
BfAstNode* stmt = CreateStatementAfter(attrib);
|
||||
BfAstNode* stmt = CreateStatementAfter(attrib, createStmtFlags);
|
||||
if (stmt != NULL)
|
||||
{
|
||||
{
|
||||
if (auto localMethodDecl = BfNodeDynCastExact<BfLocalMethodDeclaration>(stmt))
|
||||
{
|
||||
BF_ASSERT(localMethodDecl->mMethodDeclaration->mAttributes == NULL);
|
||||
localMethodDecl->mSrcStart = attrib->mSrcStart;
|
||||
MEMBER_SET(localMethodDecl->mMethodDeclaration, mAttributes, attrib);
|
||||
return localMethodDecl;
|
||||
}
|
||||
|
||||
bool isValid = true;
|
||||
|
||||
auto checkNode = stmt;
|
||||
|
|
|
@ -196,7 +196,7 @@ public:
|
|||
BfFieldDtorDeclaration* CreateFieldDtorDeclaration(BfAstNode* srcNode);
|
||||
BfFieldDeclaration* CreateFieldDeclaration(BfTokenNode* tokenNode, BfTypeReference* typeRef, BfIdentifierNode* nameIdentifier, BfFieldDeclaration* prevFieldDeclaration);
|
||||
BfAttributeDirective* CreateAttributeDirective(BfTokenNode* startToken);
|
||||
BfStatement* CreateAttributedStatement(BfTokenNode* tokenNode);
|
||||
BfStatement* CreateAttributedStatement(BfTokenNode* tokenNode, CreateStmtFlags createStmtFlags = CreateStmtFlags_None);
|
||||
BfExpression* CreateAttributedExpression(BfTokenNode* tokenNode, bool onlyAllowIdentifier);
|
||||
BfDelegateBindExpression* CreateDelegateBindExpression(BfAstNode* allocNode);
|
||||
BfLambdaBindExpression* CreateLambdaBindExpression(BfAstNode* allocNode, BfTokenNode* parenToken = NULL);
|
||||
|
|
|
@ -17,6 +17,7 @@ BfSourceClassifier::BfSourceClassifier(BfParser* bfParser, CharData* charData)
|
|||
mEnabled = true;
|
||||
mPrevNode = NULL;
|
||||
mCurMember = NULL;
|
||||
mCurLocalMethodDeclaration = NULL;
|
||||
}
|
||||
|
||||
void BfSourceClassifier::ModifyFlags(BfAstNode* node, uint8 andFlags, uint8 orFlags)
|
||||
|
@ -213,10 +214,13 @@ void BfSourceClassifier::Visit(BfAttributeDirective* attributeDirective)
|
|||
return;
|
||||
}
|
||||
|
||||
if (auto methodDecl = BfNodeDynCast<BfMethodDeclaration>(mCurMember))
|
||||
if (mCurLocalMethodDeclaration == NULL)
|
||||
{
|
||||
if (methodDecl->mAttributes == attributeDirective)
|
||||
return;
|
||||
if (auto methodDecl = BfNodeDynCast<BfMethodDeclaration>(mCurMember))
|
||||
{
|
||||
if (methodDecl->mAttributes == attributeDirective)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (auto propDecl = BfNodeDynCast<BfPropertyDeclaration>(mCurMember))
|
||||
|
@ -384,7 +388,10 @@ void BfSourceClassifier::Visit(BfGenericInstanceTypeRef* genericInstTypeRef)
|
|||
void BfSourceClassifier::Visit(BfLocalMethodDeclaration* methodDecl)
|
||||
{
|
||||
if (IsInterestedInMember(methodDecl, true))
|
||||
{
|
||||
SetAndRestoreValue<BfLocalMethodDeclaration*> prevLocalMethodDecl(mCurLocalMethodDeclaration, methodDecl);
|
||||
BfElementVisitor::Visit(methodDecl);
|
||||
}
|
||||
}
|
||||
|
||||
void BfSourceClassifier::Visit(BfLiteralExpression* literalExpr)
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
uint8 mClassifierPassId;
|
||||
BfAstNode* mPrevNode;
|
||||
BfAstNode* mCurMember;
|
||||
BfLocalMethodDeclaration* mCurLocalMethodDeclaration;
|
||||
|
||||
public:
|
||||
void HandleLeafNode(BfAstNode* node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue