mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Deleted type protection in EmitGCMarkValue, RequestExtraCompile feature
This commit is contained in:
parent
6e0cabf8aa
commit
471897a150
6 changed files with 81 additions and 1 deletions
|
@ -355,6 +355,7 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
||||||
mHasRequiredTypes = false;
|
mHasRequiredTypes = false;
|
||||||
mNeedsFullRefresh = false;
|
mNeedsFullRefresh = false;
|
||||||
mFastFinish = false;
|
mFastFinish = false;
|
||||||
|
mExtraCompileRequested = false;
|
||||||
mHasQueuedTypeRebuilds = false;
|
mHasQueuedTypeRebuilds = false;
|
||||||
mIsResolveOnly = isResolveOnly;
|
mIsResolveOnly = isResolveOnly;
|
||||||
mResolvePassData = NULL;
|
mResolvePassData = NULL;
|
||||||
|
@ -7182,6 +7183,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
mOutputDirectory = outputDirectory;
|
mOutputDirectory = outputDirectory;
|
||||||
mSystem->StartYieldSection();
|
mSystem->StartYieldSection();
|
||||||
|
|
||||||
|
mExtraCompileRequested = false;
|
||||||
mFastFinish = false;
|
mFastFinish = false;
|
||||||
mHasQueuedTypeRebuilds = false;
|
mHasQueuedTypeRebuilds = false;
|
||||||
mCanceling = false;
|
mCanceling = false;
|
||||||
|
@ -8082,7 +8084,23 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
|
|
||||||
bool BfCompiler::Compile(const StringImpl& outputDirectory)
|
bool BfCompiler::Compile(const StringImpl& outputDirectory)
|
||||||
{
|
{
|
||||||
bool success = DoCompile(outputDirectory);
|
int passIdx = 0;
|
||||||
|
bool success = false;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
auto passState = mPassInstance->GetState();
|
||||||
|
|
||||||
|
success = DoCompile(outputDirectory);
|
||||||
|
if (!mExtraCompileRequested)
|
||||||
|
break;
|
||||||
|
|
||||||
|
mPassInstance->RestoreState(passState);
|
||||||
|
|
||||||
|
if (passIdx == 1)
|
||||||
|
break;
|
||||||
|
passIdx++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
return false;
|
return false;
|
||||||
if (mPassInstance->HasFailed())
|
if (mPassInstance->HasFailed())
|
||||||
|
@ -8132,6 +8150,11 @@ void BfCompiler::RequestFastFinish()
|
||||||
BpEvent("BfCompiler::RequestFastFinish", "");
|
BpEvent("BfCompiler::RequestFastFinish", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfCompiler::RequestExtraCompile()
|
||||||
|
{
|
||||||
|
mExtraCompileRequested = true;
|
||||||
|
}
|
||||||
|
|
||||||
//#define WANT_COMPILE_LOG
|
//#define WANT_COMPILE_LOG
|
||||||
|
|
||||||
void BfCompiler::CompileLog(const char* fmt ...)
|
void BfCompiler::CompileLog(const char* fmt ...)
|
||||||
|
|
|
@ -334,6 +334,7 @@ public:
|
||||||
bool mHasRequiredTypes;
|
bool mHasRequiredTypes;
|
||||||
bool mNeedsFullRefresh;
|
bool mNeedsFullRefresh;
|
||||||
bool mFastFinish;
|
bool mFastFinish;
|
||||||
|
bool mExtraCompileRequested;
|
||||||
bool mHasQueuedTypeRebuilds; // Infers we had a fast finish that requires a type rebuild
|
bool mHasQueuedTypeRebuilds; // Infers we had a fast finish that requires a type rebuild
|
||||||
bool mHadCancel;
|
bool mHadCancel;
|
||||||
bool mWantsDeferMethodDecls;
|
bool mWantsDeferMethodDecls;
|
||||||
|
@ -545,6 +546,7 @@ public:
|
||||||
void GetSymbolReferences();
|
void GetSymbolReferences();
|
||||||
void Cancel();
|
void Cancel();
|
||||||
void RequestFastFinish();
|
void RequestFastFinish();
|
||||||
|
void RequestExtraCompile();
|
||||||
String GetTypeDefList(bool includeLocation);
|
String GetTypeDefList(bool includeLocation);
|
||||||
String GetGeneratorString(BfTypeDef* typeDef, BfTypeInstance* typeInst, const StringImpl& generatorMethodName, const StringImpl* args);
|
String GetGeneratorString(BfTypeDef* typeDef, BfTypeInstance* typeInst, const StringImpl& generatorMethodName, const StringImpl* args);
|
||||||
void HandleGeneratorErrors(StringImpl& result);
|
void HandleGeneratorErrors(StringImpl& result);
|
||||||
|
|
|
@ -5646,6 +5646,7 @@ BfTypedValue BfExprEvaluator::LoadField(BfAstNode* targetSrc, BfTypedValue targe
|
||||||
|
|
||||||
if (fieldInstance->mDataIdx < 0)
|
if (fieldInstance->mDataIdx < 0)
|
||||||
{
|
{
|
||||||
|
mModule->mCompiler->RequestExtraCompile();
|
||||||
mModule->InternalError("LoadField field DataIdx<0 where InstSize>0");
|
mModule->InternalError("LoadField field DataIdx<0 where InstSize>0");
|
||||||
mModule->DeferRebuildType(typeInstance);
|
mModule->DeferRebuildType(typeInstance);
|
||||||
return mModule->GetDefaultTypedValue(resolvedFieldType);
|
return mModule->GetDefaultTypedValue(resolvedFieldType);
|
||||||
|
|
|
@ -4730,6 +4730,7 @@ BfTypedValue BfModule::GetFieldInitializerValue(BfFieldInstance* fieldInstance,
|
||||||
|
|
||||||
if (fieldType->IsDeleting())
|
if (fieldType->IsDeleting())
|
||||||
{
|
{
|
||||||
|
mCompiler->RequestExtraCompile();
|
||||||
InternalError("Field using deleted type", fieldDef->GetRefNode());
|
InternalError("Field using deleted type", fieldDef->GetRefNode());
|
||||||
}
|
}
|
||||||
else if (fieldType->IsVar())
|
else if (fieldType->IsVar())
|
||||||
|
@ -11264,6 +11265,7 @@ BfMethodInstance* BfModule::GetRawMethodInstanceAtIdx(BfTypeInstance* typeInstan
|
||||||
{
|
{
|
||||||
if (typeInstance->IsDeleting())
|
if (typeInstance->IsDeleting())
|
||||||
{
|
{
|
||||||
|
mCompiler->RequestExtraCompile();
|
||||||
InternalError("GetRawMethodInstanceAtIdx for deleted type", typeInstance->mTypeDef->GetRefNode());
|
InternalError("GetRawMethodInstanceAtIdx for deleted type", typeInstance->mTypeDef->GetRefNode());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -20301,6 +20303,13 @@ void BfModule::EmitGCMarkValue(BfTypedValue& thisValue, BfType* checkType, int m
|
||||||
if (!checkType->WantsGCMarking())
|
if (!checkType->WantsGCMarking())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (checkType->IsDeleting())
|
||||||
|
{
|
||||||
|
mCompiler->RequestExtraCompile();
|
||||||
|
InternalError("EmitGCMarkValue deleted type");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto typeInstance = checkType->ToTypeInstance();
|
auto typeInstance = checkType->ToTypeInstance();
|
||||||
bool callMarkMethod = false;
|
bool callMarkMethod = false;
|
||||||
|
|
||||||
|
|
|
@ -1223,6 +1223,37 @@ BfPassInstance::~BfPassInstance()
|
||||||
delete bfError;
|
delete bfError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BfPassInstance::StateInfo BfPassInstance::GetState()
|
||||||
|
{
|
||||||
|
StateInfo stateInfo;
|
||||||
|
stateInfo.mOutStreamSize = (int)mOutStream.mSize;
|
||||||
|
stateInfo.mErrorsSize = mErrors.mSize;
|
||||||
|
stateInfo.mWarningCount = mWarningCount;
|
||||||
|
stateInfo.mDeferredErrorCount = mDeferredErrorCount;
|
||||||
|
stateInfo.mFailedIdx = mFailedIdx;
|
||||||
|
stateInfo.mWarnIdx = mWarnIdx;
|
||||||
|
return stateInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BfPassInstance::RestoreState(StateInfo stateInfo)
|
||||||
|
{
|
||||||
|
while (mOutStream.mSize > stateInfo.mOutStreamSize)
|
||||||
|
mOutStream.pop_back();
|
||||||
|
|
||||||
|
while (mErrors.mSize > stateInfo.mErrorsSize)
|
||||||
|
{
|
||||||
|
auto error = mErrors.back();
|
||||||
|
mErrors.pop_back();
|
||||||
|
mErrorSet.Remove(error);
|
||||||
|
delete error;
|
||||||
|
}
|
||||||
|
|
||||||
|
mWarningCount = stateInfo.mWarningCount;
|
||||||
|
mDeferredErrorCount = stateInfo.mDeferredErrorCount;
|
||||||
|
mFailedIdx = stateInfo.mFailedIdx;
|
||||||
|
mWarnIdx = stateInfo.mWarnIdx;
|
||||||
|
}
|
||||||
|
|
||||||
void BfPassInstance::ClearErrors()
|
void BfPassInstance::ClearErrors()
|
||||||
{
|
{
|
||||||
mFailedIdx = 0;
|
mFailedIdx = 0;
|
||||||
|
|
|
@ -1594,6 +1594,17 @@ public:
|
||||||
|
|
||||||
class BfPassInstance
|
class BfPassInstance
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
struct StateInfo
|
||||||
|
{
|
||||||
|
int mOutStreamSize;
|
||||||
|
int mErrorsSize;
|
||||||
|
int mWarningCount;
|
||||||
|
int mDeferredErrorCount;
|
||||||
|
int mFailedIdx;
|
||||||
|
int mWarnIdx;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const int sMaxDisplayErrors = 100;
|
const int sMaxDisplayErrors = 100;
|
||||||
const int sMaxErrors = 1000;
|
const int sMaxErrors = 1000;
|
||||||
|
@ -1636,6 +1647,9 @@ public:
|
||||||
|
|
||||||
~BfPassInstance();
|
~BfPassInstance();
|
||||||
|
|
||||||
|
StateInfo GetState();
|
||||||
|
void RestoreState(StateInfo stateInfo);
|
||||||
|
|
||||||
void ClearErrors();
|
void ClearErrors();
|
||||||
bool HasFailed();
|
bool HasFailed();
|
||||||
bool HasMessages();
|
bool HasMessages();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue