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)
|
else if (token == BfToken_LBracket)
|
||||||
{
|
{
|
||||||
return CreateAttributedStatement(tokenNode);
|
return CreateAttributedStatement(tokenNode, createStmtFlags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5663,15 +5663,23 @@ Do_RBracket:
|
||||||
return attributeDirective;
|
return attributeDirective;
|
||||||
}
|
}
|
||||||
|
|
||||||
BfStatement* BfReducer::CreateAttributedStatement(BfTokenNode* tokenNode)
|
BfStatement* BfReducer::CreateAttributedStatement(BfTokenNode* tokenNode, CreateStmtFlags createStmtFlags)
|
||||||
{
|
{
|
||||||
auto attrib = CreateAttributeDirective(tokenNode);
|
auto attrib = CreateAttributeDirective(tokenNode);
|
||||||
if (attrib == NULL)
|
if (attrib == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BfAstNode* stmt = CreateStatementAfter(attrib);
|
BfAstNode* stmt = CreateStatementAfter(attrib, createStmtFlags);
|
||||||
if (stmt != NULL)
|
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;
|
bool isValid = true;
|
||||||
|
|
||||||
auto checkNode = stmt;
|
auto checkNode = stmt;
|
||||||
|
|
|
@ -196,7 +196,7 @@ public:
|
||||||
BfFieldDtorDeclaration* CreateFieldDtorDeclaration(BfAstNode* srcNode);
|
BfFieldDtorDeclaration* CreateFieldDtorDeclaration(BfAstNode* srcNode);
|
||||||
BfFieldDeclaration* CreateFieldDeclaration(BfTokenNode* tokenNode, BfTypeReference* typeRef, BfIdentifierNode* nameIdentifier, BfFieldDeclaration* prevFieldDeclaration);
|
BfFieldDeclaration* CreateFieldDeclaration(BfTokenNode* tokenNode, BfTypeReference* typeRef, BfIdentifierNode* nameIdentifier, BfFieldDeclaration* prevFieldDeclaration);
|
||||||
BfAttributeDirective* CreateAttributeDirective(BfTokenNode* startToken);
|
BfAttributeDirective* CreateAttributeDirective(BfTokenNode* startToken);
|
||||||
BfStatement* CreateAttributedStatement(BfTokenNode* tokenNode);
|
BfStatement* CreateAttributedStatement(BfTokenNode* tokenNode, CreateStmtFlags createStmtFlags = CreateStmtFlags_None);
|
||||||
BfExpression* CreateAttributedExpression(BfTokenNode* tokenNode, bool onlyAllowIdentifier);
|
BfExpression* CreateAttributedExpression(BfTokenNode* tokenNode, bool onlyAllowIdentifier);
|
||||||
BfDelegateBindExpression* CreateDelegateBindExpression(BfAstNode* allocNode);
|
BfDelegateBindExpression* CreateDelegateBindExpression(BfAstNode* allocNode);
|
||||||
BfLambdaBindExpression* CreateLambdaBindExpression(BfAstNode* allocNode, BfTokenNode* parenToken = NULL);
|
BfLambdaBindExpression* CreateLambdaBindExpression(BfAstNode* allocNode, BfTokenNode* parenToken = NULL);
|
||||||
|
|
|
@ -17,6 +17,7 @@ BfSourceClassifier::BfSourceClassifier(BfParser* bfParser, CharData* charData)
|
||||||
mEnabled = true;
|
mEnabled = true;
|
||||||
mPrevNode = NULL;
|
mPrevNode = NULL;
|
||||||
mCurMember = NULL;
|
mCurMember = NULL;
|
||||||
|
mCurLocalMethodDeclaration = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfSourceClassifier::ModifyFlags(BfAstNode* node, uint8 andFlags, uint8 orFlags)
|
void BfSourceClassifier::ModifyFlags(BfAstNode* node, uint8 andFlags, uint8 orFlags)
|
||||||
|
@ -213,11 +214,14 @@ void BfSourceClassifier::Visit(BfAttributeDirective* attributeDirective)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mCurLocalMethodDeclaration == NULL)
|
||||||
|
{
|
||||||
if (auto methodDecl = BfNodeDynCast<BfMethodDeclaration>(mCurMember))
|
if (auto methodDecl = BfNodeDynCast<BfMethodDeclaration>(mCurMember))
|
||||||
{
|
{
|
||||||
if (methodDecl->mAttributes == attributeDirective)
|
if (methodDecl->mAttributes == attributeDirective)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (auto propDecl = BfNodeDynCast<BfPropertyDeclaration>(mCurMember))
|
if (auto propDecl = BfNodeDynCast<BfPropertyDeclaration>(mCurMember))
|
||||||
{
|
{
|
||||||
|
@ -384,7 +388,10 @@ void BfSourceClassifier::Visit(BfGenericInstanceTypeRef* genericInstTypeRef)
|
||||||
void BfSourceClassifier::Visit(BfLocalMethodDeclaration* methodDecl)
|
void BfSourceClassifier::Visit(BfLocalMethodDeclaration* methodDecl)
|
||||||
{
|
{
|
||||||
if (IsInterestedInMember(methodDecl, true))
|
if (IsInterestedInMember(methodDecl, true))
|
||||||
|
{
|
||||||
|
SetAndRestoreValue<BfLocalMethodDeclaration*> prevLocalMethodDecl(mCurLocalMethodDeclaration, methodDecl);
|
||||||
BfElementVisitor::Visit(methodDecl);
|
BfElementVisitor::Visit(methodDecl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfSourceClassifier::Visit(BfLiteralExpression* literalExpr)
|
void BfSourceClassifier::Visit(BfLiteralExpression* literalExpr)
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
uint8 mClassifierPassId;
|
uint8 mClassifierPassId;
|
||||||
BfAstNode* mPrevNode;
|
BfAstNode* mPrevNode;
|
||||||
BfAstNode* mCurMember;
|
BfAstNode* mCurMember;
|
||||||
|
BfLocalMethodDeclaration* mCurLocalMethodDeclaration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void HandleLeafNode(BfAstNode* node);
|
void HandleLeafNode(BfAstNode* node);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue