1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 12:32:20 +02:00

Allow some cases of uninitialized parsers

This commit is contained in:
Brian Fiete 2022-06-11 05:48:55 -07:00
parent 931e29a1f3
commit 8163d5b647
2 changed files with 68 additions and 56 deletions

View file

@ -9824,6 +9824,8 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
BfPreprocessorNode* prevPreprocessorNode = NULL;
int ignoredSectionStart = -1;
if (bfParser->mSidechannelRootNode != NULL)
{
for (auto element : bfParser->mSidechannelRootNode->mChildArr)
{
if (auto preprocessorNode = BfNodeDynCast<BfPreprocessorNode>(element))
@ -9884,6 +9886,7 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
collapseVisitor.UpdateSeries(commentNode, 'C');
}
}
}
collapseVisitor.FlushSeries();
@ -10063,7 +10066,12 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
int endLineChar = 0;
if (srcEnd >= 0)
emitParser->GetLineCharAtIdx(srcEnd, endLine, endLineChar);
outString += StrFormat("e%d,%d,%d,%d,%d\n", embedId, charIdx, startLine, endLine + 1, typeInst->mTypeDef->mTypeDeclaration->GetParser()->mTextVersion);
int textVersion = -1;
auto declParser = typeInst->mTypeDef->mTypeDeclaration->GetParser();
if (declParser != NULL)
textVersion = declParser->mTextVersion;
outString += StrFormat("e%d,%d,%d,%d,%d\n", embedId, charIdx, startLine, endLine + 1, textVersion);
}
}

View file

@ -404,7 +404,11 @@ BfParser::~BfParser()
{
int parserCount = gParserCount--;
if (mParserData->mRefCount == -1)
if (mParserData == NULL)
{
}
else if (mParserData->mRefCount == -1)
{
// Owned data, never intended for cache
mParserData->mSrc = NULL; // Count on BfSource dtor to release strc