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:
parent
f29a74888c
commit
a086de3d8e
3 changed files with 30 additions and 11 deletions
|
@ -3143,14 +3143,6 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
if (!mHadBuildError)
|
if (!mHadBuildError)
|
||||||
mHadBuildError = true;
|
mHadBuildError = true;
|
||||||
|
|
||||||
if ((mCurMethodState != NULL) && (mCurMethodState->mEmitRefNode != NULL))
|
|
||||||
{
|
|
||||||
bfError = mCompiler->mPassInstance->Fail("Emitted code had errors", mCurMethodState->mEmitRefNode);
|
|
||||||
if (bfError != NULL)
|
|
||||||
mCompiler->mPassInstance->MoreInfo(errorString, refNode);
|
|
||||||
return bfError;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check mixins
|
// Check mixins
|
||||||
{
|
{
|
||||||
auto checkMethodState = mCurMethodState;
|
auto checkMethodState = mCurMethodState;
|
||||||
|
@ -3199,6 +3191,8 @@ BfError* BfModule::Fail(const StringImpl& error, BfAstNode* refNode, bool isPers
|
||||||
|
|
||||||
if ((mCurMethodState != NULL) && (mCurMethodState->mDeferredCallEmitState != NULL) && (mCurMethodState->mDeferredCallEmitState->mCloseNode != NULL))
|
if ((mCurMethodState != NULL) && (mCurMethodState->mDeferredCallEmitState != NULL) && (mCurMethodState->mDeferredCallEmitState->mCloseNode != NULL))
|
||||||
mCompiler->mPassInstance->MoreInfo("Error during deferred statement handling", mCurMethodState->mDeferredCallEmitState->mCloseNode);
|
mCompiler->mPassInstance->MoreInfo("Error during deferred statement handling", mCurMethodState->mDeferredCallEmitState->mCloseNode);
|
||||||
|
else if ((mCurMethodState != NULL) && (mCurMethodState->mEmitRefNode != NULL))
|
||||||
|
mCompiler->mPassInstance->MoreInfo("Error in emitted code", mCurMethodState->mEmitRefNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bfError;
|
return bfError;
|
||||||
|
|
|
@ -2252,6 +2252,18 @@ BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef*
|
||||||
}
|
}
|
||||||
else if (ceEmitSource->mSrcStart == -1)
|
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->mSrcStart = emitSrcStart;
|
||||||
ceEmitSource->mSrcEnd = emitParser->mSrcLength;
|
ceEmitSource->mSrcEnd = emitParser->mSrcLength;
|
||||||
}
|
}
|
||||||
|
@ -2555,6 +2567,12 @@ void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
|
||||||
if (code.IsEmpty())
|
if (code.IsEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (mCurMethodInstance == NULL)
|
||||||
|
{
|
||||||
|
Fail("Invalid code mixin", refNode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto activeTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType;
|
auto activeTypeDef = mCurMethodInstance->mMethodDef->mDeclaringType;
|
||||||
//auto emitParser = activeTypeDef->mEmitParser;
|
//auto emitParser = activeTypeDef->mEmitParser;
|
||||||
|
|
||||||
|
@ -2632,6 +2650,8 @@ void BfModule::CEMixin(BfAstNode* refNode, const StringImpl& code)
|
||||||
mBfIRBuilder->RestoreDebugLocation();
|
mBfIRBuilder->RestoreDebugLocation();
|
||||||
mBfIRBuilder->DupDebugLocation();
|
mBfIRBuilder->DupDebugLocation();
|
||||||
|
|
||||||
|
prevCustomAttribute.Restore();
|
||||||
|
|
||||||
FinishCEParseContext(refNode, mCurTypeInstance, &ceParseContext);
|
FinishCEParseContext(refNode, mCurTypeInstance, &ceParseContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@ bool BfParserData::IsUnwarnedAt(BfAstNode* node)
|
||||||
|
|
||||||
bool BfParserData::IsWarningEnabledAtSrcIndex(int warningNumber, int srcIdx)
|
bool BfParserData::IsWarningEnabledAtSrcIndex(int warningNumber, int srcIdx)
|
||||||
{
|
{
|
||||||
bool enabled = true; //CDH TODO if/when we add warning level support, this default will change based on the warning number and the general project warning level setting
|
int enabled = 1; //CDH TODO if/when we add warning level support, this default will change based on the warning number and the general project warning level setting
|
||||||
int lastUnwarnPos = 0;
|
int lastUnwarnPos = 0;
|
||||||
|
|
||||||
for (const auto& it : mWarningEnabledChanges)
|
for (const auto& it : mWarningEnabledChanges)
|
||||||
|
@ -313,11 +313,16 @@ bool BfParserData::IsWarningEnabledAtSrcIndex(int warningNumber, int srcIdx)
|
||||||
if (it.mKey > srcIdx)
|
if (it.mKey > srcIdx)
|
||||||
break;
|
break;
|
||||||
if (it.mValue.mWarningNumber == warningNumber)
|
if (it.mValue.mWarningNumber == warningNumber)
|
||||||
enabled = it.mValue.mEnable;
|
{
|
||||||
|
if (it.mValue.mEnable)
|
||||||
|
enabled++;
|
||||||
|
else
|
||||||
|
enabled--;
|
||||||
|
}
|
||||||
if (it.mValue.mWarningNumber == -1)
|
if (it.mValue.mWarningNumber == -1)
|
||||||
lastUnwarnPos = -1;
|
lastUnwarnPos = -1;
|
||||||
}
|
}
|
||||||
return enabled;
|
return enabled > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BfParserData::Deref()
|
void BfParserData::Deref()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue