mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Fixed failed anonymous inline type declaration with attributes
This commit is contained in:
parent
41b280f2df
commit
eebb0f7882
2 changed files with 20 additions and 5 deletions
|
@ -50,6 +50,7 @@ BfReducer::BfReducer()
|
||||||
mDocumentCheckIdx = 0;
|
mDocumentCheckIdx = 0;
|
||||||
mTypeMemberNodeStart = NULL;
|
mTypeMemberNodeStart = NULL;
|
||||||
mCurTypeState = NULL;
|
mCurTypeState = NULL;
|
||||||
|
mLastErrorSrcEnd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BfReducer::IsSemicolon(BfAstNode* node)
|
bool BfReducer::IsSemicolon(BfAstNode* node)
|
||||||
|
@ -84,7 +85,7 @@ void BfReducer::AssertCurrentNode(BfAstNode* node)
|
||||||
auto currentNode = mVisitorPos.GetCurrent();
|
auto currentNode = mVisitorPos.GetCurrent();
|
||||||
if (currentNode == NULL)
|
if (currentNode == NULL)
|
||||||
return;
|
return;
|
||||||
if (!node->LocationEndEquals(currentNode))
|
if ((!node->LocationEndEquals(currentNode)) && (mLastErrorSrcEnd != currentNode->mSrcEnd))
|
||||||
{
|
{
|
||||||
const char* lastCPtr = &node->GetSourceData()->mSrc[node->GetSrcEnd() - 1];
|
const char* lastCPtr = &node->GetSourceData()->mSrc[node->GetSrcEnd() - 1];
|
||||||
// We have an "exceptional" case where breaking a double chevron will look like a position error
|
// We have an "exceptional" case where breaking a double chevron will look like a position error
|
||||||
|
@ -237,6 +238,7 @@ void BfReducer::AddErrorNode(BfAstNode* astNode, bool removeNode)
|
||||||
mSource->AddErrorNode(astNode);
|
mSource->AddErrorNode(astNode);
|
||||||
if (removeNode)
|
if (removeNode)
|
||||||
astNode->RemoveSelf();
|
astNode->RemoveSelf();
|
||||||
|
mLastErrorSrcEnd = astNode->mSrcEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BfReducer::IsTypeReference(BfAstNode* checkNode, BfToken successToken, int endNode, int* retryNode, int* outEndNode, bool* couldBeExpr, bool* isGenericType, bool* isTuple)
|
bool BfReducer::IsTypeReference(BfAstNode* checkNode, BfToken successToken, int endNode, int* retryNode, int* outEndNode, bool* couldBeExpr, bool* isGenericType, bool* isTuple)
|
||||||
|
@ -5739,7 +5741,14 @@ BfTypeReference* BfReducer::CreateTypeRefAfter(BfAstNode* astNode, CreateTypeRef
|
||||||
BfTypeReference* typeRef = CreateTypeRef(nextNode, createTypeRefFlags);
|
BfTypeReference* typeRef = CreateTypeRef(nextNode, createTypeRefFlags);
|
||||||
if (typeRef == NULL)
|
if (typeRef == NULL)
|
||||||
{
|
{
|
||||||
BF_ASSERT(mVisitorPos.mReadPos == startPos);
|
if (mLastErrorSrcEnd > startPos)
|
||||||
|
{
|
||||||
|
// We added an error node and made progress
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BF_ASSERT(mVisitorPos.mReadPos == startPos);
|
||||||
|
}
|
||||||
mVisitorPos.mReadPos--;
|
mVisitorPos.mReadPos--;
|
||||||
}
|
}
|
||||||
return typeRef;
|
return typeRef;
|
||||||
|
@ -8264,13 +8273,18 @@ void BfReducer::InitAnonymousType(BfTypeDeclaration* typeDecl)
|
||||||
typeDecl->mAnonymousName = (char*)mAlloc->AllocBytes(len);
|
typeDecl->mAnonymousName = (char*)mAlloc->AllocBytes(len);
|
||||||
memcpy(typeDecl->mAnonymousName, name.c_str(), len);
|
memcpy(typeDecl->mAnonymousName, name.c_str(), len);
|
||||||
|
|
||||||
if (mCurTypeState != NULL)
|
auto parser = typeDecl->GetParser();
|
||||||
|
if ((parser != NULL) && (parser->mIsEmitted))
|
||||||
|
{
|
||||||
|
Fail("Type declarations are not allowed in emitted code", typeDecl);
|
||||||
|
}
|
||||||
|
else if (mCurTypeState != NULL)
|
||||||
{
|
{
|
||||||
mCurTypeState->mAnonymousTypeDecls.Add(typeDecl);
|
mCurTypeState->mAnonymousTypeDecls.Add(typeDecl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Fail("Type declarations are not allowed in emitted code", typeDecl);
|
Fail("Invalid use of anonymous type declaration", typeDecl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,7 @@ public:
|
||||||
BfAstNode* mTypeMemberNodeStart;
|
BfAstNode* mTypeMemberNodeStart;
|
||||||
int mClassDepth;
|
int mClassDepth;
|
||||||
int mMethodDepth;
|
int mMethodDepth;
|
||||||
|
int mLastErrorSrcEnd;
|
||||||
BfTypeDeclaration* mCurTypeDecl;
|
BfTypeDeclaration* mCurTypeDecl;
|
||||||
CurTypeState* mCurTypeState;
|
CurTypeState* mCurTypeState;
|
||||||
BfTypeDeclaration* mLastTypeDecl;
|
BfTypeDeclaration* mLastTypeDecl;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue