1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Improved error handling in Compiler.Emit

This commit is contained in:
Brian Fiete 2022-05-30 17:39:21 -07:00
parent f29a74888c
commit a086de3d8e
3 changed files with 30 additions and 11 deletions

View file

@ -2252,6 +2252,18 @@ BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef*
}
else if (ceEmitSource->mSrcStart == -1)
{
auto parserData = refNode->GetParserData();
if (parserData != NULL)
{
// Add the warning changes occur before the start of the buffer.
// We use this conservatively now - any temporary disabling will permanently disable
for (auto& warning : parserData->mWarningEnabledChanges)
{
if (!warning.mValue.mEnable)
emitParser->mParserData->mWarningEnabledChanges[-warning.mValue.mWarningNumber] = warning.mValue;
}
}
ceEmitSource->mSrcStart = emitSrcStart;
ceEmitSource->mSrcEnd = emitParser->mSrcLength;
}
@ -2555,6 +2567,12 @@ void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
if (code.IsEmpty())
return;
if (mCurMethodInstance == NULL)
{
Fail("Invalid code mixin", refNode);
return;
}
auto activeTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType;
//auto emitParser = activeTypeDef->mEmitParser;
@ -2632,6 +2650,8 @@ void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
mBfIRBuilder->RestoreDebugLocation();
mBfIRBuilder->DupDebugLocation();
prevCustomAttribute.Restore();
FinishCEParseContext(refNode, mCurTypeInstance, &ceParseContext);
}