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

Change Beefy::defer to be simpler (no std::function), macOS changes

This commit is contained in:
Brian Fiete 2019-10-15 12:28:21 -07:00
parent 3bf4c792d8
commit c8ca66ec5c
18 changed files with 168 additions and 221 deletions

View file

@ -4717,9 +4717,9 @@ bool COFF::CvParseDBI(int wantAge)
uint8* data = CvReadStream(3);
uint8* sectionData = data;
defer
{
(
delete sectionData;
};
);
// Header
GET_INTO(int32, signature);
@ -5578,22 +5578,7 @@ bool COFF::ParseCv(DataStream& pdbFS, uint8* rootDirData, int pageSize, uint8 wa
if (mParseKind == ParseKind_Header)
return true;
//ParseSymbolData();
//TODO: Remove
/*for (int streamIdx = 0; streamIdx < numStreams; streamIdx++)
{
int outSize;
uint8* data = CvReadStream(streamIdx, &outSize);
if (outSize > 0)
{
FILE* fp = fopen(StrFormat("c:/temp/test4/pdb_stream_%d.bin", streamIdx).c_str(), "wb");
fwrite(data, 1, outSize, fp);
fclose(fp);
delete [] data;
}
}*/
///
{
BP_ZONE("COFF::ParseCv_ReadStrTable");
if (mStringTable.mStream != -1)
@ -5604,28 +5589,12 @@ bool COFF::ParseCv(DataStream& pdbFS, uint8* rootDirData, int pageSize, uint8 wa
}
for (int compileUnitId = 0; compileUnitId < (int)mCvModuleInfo.size(); compileUnitId++)
{
//ParseCompileUnit(compileUnitId);
{
ScanCompileUnit(compileUnitId);
}
/*for (int streamIdx = 0; streamIdx < (int)mDeferredModuleInfo.size(); streamIdx++)
{
if (mDeferredModuleInfo[streamIdx].empty())
continue;
uint8* data = CvReadStream(streamIdx);
uint8* sectionData = data;
for (auto& moduleInfo : mDeferredModuleInfo[streamIdx])
{
CvParseModuleInfo(*moduleInfo, data, sectionData, mCvTypeSectionData, mStringTable);
}
}*/
//////////////////////////////////////////////////////////////////////////
return true;
}
@ -5764,9 +5733,6 @@ bool COFF::TryLoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge)
return false;
}
//FixTypes(startingTypeIdx);
//MapTypes(startingTypeIdx);
if (mCvDataStream->mFailed)
return false;
@ -5928,24 +5894,13 @@ void COFF::ProcessDebugInfo()
GET_INTO(uint32, infoType);
BF_ASSERT(infoType == CV_SIGNATURE_C13);
CvInitStreamRaw(mCvTypeSectionReader, entry.mData + 4, entry.mSize - 4);
//ParseTypeData(data, mCvTypeSectionDataSize - sizeof(uint32));
CvInitStreamRaw(mCvTypeSectionReader, entry.mData + 4, entry.mSize - 4);
ParseTypeData(mCvTypeSectionReader, 0);
}
FixTypes(startingTypeIdx);
linkedModule->MapTypes(startingTypeIdx);
/*std::unordered_set<String, >
for (int typeIdx = startingTypeIdx; typeIdx < (int)mTypes.size(); typeIdx++)
{
DbgType* dbgType = linkedModule->mTypes[typeIdx];
if ((!dbgType->mIsDeclaration) && (dbgType->IsCompositeType()))
{
}
}*/
CvCompileUnit* compileUnit = NULL;
for (auto entry : mCvCompileUnitData)
{

View file

@ -377,7 +377,7 @@ void BfCodeGenThread::RunLoop()
{
#ifdef BF_PLATFORM_WINDOWS
BeIRCodeGen* beIRCodeGen = new BeIRCodeGen();
defer { delete beIRCodeGen; };
defer ( delete beIRCodeGen; );
beIRCodeGen->SetConfigConst(BfIRConfigConst_VirtualMethodOfs, request->mOptions.mVirtualMethodOfs);
beIRCodeGen->SetConfigConst(BfIRConfigConst_DynSlotOfs, request->mOptions.mDynSlotOfs);

View file

@ -5709,7 +5709,7 @@ BfTypedValue BfExprEvaluator::MatchMethod(BfAstNode* targetSrc, BfMethodBoundExp
}
}
OnScopeExit doRestoreAutocomplete([&]()
defer(
{
if ((restoreCapturingMethodMatchInfo != NULL) && (autoComplete->mMethodMatchInfo == restoreCapturingMethodMatchInfo))
autoComplete->mIsCapturingMethodMatchInfo = true;
@ -9365,10 +9365,12 @@ BfLambdaInstance* BfExprEvaluator::GetLambdaInstance(BfLambdaBindExpression* lam
}
defer
{
if (autoComplete != NULL)
autoComplete->mIsCapturingMethodMatchInfo = (wasCapturingMethodInfo) && (!autoComplete->mIsCapturingMethodMatchInfo);
};
(
{
if (autoComplete != NULL)
autoComplete->mIsCapturingMethodMatchInfo = (wasCapturingMethodInfo) && (!autoComplete->mIsCapturingMethodMatchInfo);
}
);
if (lambdaBindExpr->mBody == NULL)
{
@ -11848,11 +11850,13 @@ void BfExprEvaluator::InjectMixin(BfAstNode* targetSrc, BfTypedValue target, boo
SizedArray<BfResolvedArg, 4> args;
SizedArray<BfExprEvaluator*, 8> argExprEvaluators;
OnScopeExit freeMem([&]()
{
for (auto exprEvaluator : argExprEvaluators)
delete exprEvaluator;
});
defer
(
{
for (auto exprEvaluator : argExprEvaluators)
delete exprEvaluator;
}
);
auto _AddArg = [&](BfExpression* argExpr)
{
@ -12155,11 +12159,14 @@ void BfExprEvaluator::InjectMixin(BfAstNode* targetSrc, BfTypedValue target, boo
prevSymbolRefKind = mModule->mCompiler->mResolvePassData->mGetSymbolReferenceKind;
mModule->mCompiler->mResolvePassData->mGetSymbolReferenceKind = BfGetSymbolReferenceKind_None;
}
defer
{
if (mModule->mCompiler->mResolvePassData != NULL)
mModule->mCompiler->mResolvePassData->mGetSymbolReferenceKind = prevSymbolRefKind;
};
(
{
if (mModule->mCompiler->mResolvePassData != NULL)
mModule->mCompiler->mResolvePassData->mGetSymbolReferenceKind = prevSymbolRefKind;
}
);
auto methodDef = methodInstance->mMethodDef;
auto methodDeclaration = methodDef->GetMethodDeclaration();
@ -15142,14 +15149,14 @@ void BfExprEvaluator::DoMemberReference(BfMemberReferenceExpression* memberRefEx
findName = memberRefExpr->mMemberName->ToString();
defer
{
(
if (attributeState.mCustomAttributes != NULL)
{
if (mPropDef != NULL)
attributeState.mTarget = BfAttributeTargets_Invocation;
mModule->ValidateCustomAttributes(attributeState.mCustomAttributes, attributeState.mTarget);
}
};
}
);
SetAndRestoreValue<BfAttributeState*> prevAttributeState(mModule->mAttributeState, &attributeState);
@ -15451,11 +15458,12 @@ void BfExprEvaluator::Visit(BfIndexerExpression* indexerExpr)
wasCapturingMethodMatchInfo = autoComplete->mIsCapturingMethodMatchInfo;
autoComplete->mIsCapturingMethodMatchInfo = false;
}
defer
{
(
if (autoComplete != NULL)
autoComplete->mIsCapturingMethodMatchInfo = wasCapturingMethodMatchInfo;
};
);
if ((!isFailurePass) && (!methodMatcher.WantsCheckMethod(protectionCheckFlags, startCheckTypeInst, curCheckType, checkMethod)))
continue;

View file

@ -4013,7 +4013,7 @@ bool BfIRCodeGen::WriteObjectFile(const StringImpl& outFileName, const BfCodeGen
PopulateModulePassManager(PM, codeGenOptions);
llvm::raw_fd_ostream* outStream = NULL;
defer{ delete outStream; };
defer ( delete outStream; );
if (enableLTO)
{

View file

@ -956,31 +956,6 @@ void BfModule::FinishInit()
mBfIRBuilder->Module_SetTargetTriple(mCompiler->mOptions.mTargetTriple);
// #ifdef BF_PLATFORM_WINDOWS
// if (mCompiler->mOptions.mToolsetType == BfToolsetType_GNU)
// {
// if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
// mBfIRBuilder->Module_SetTargetTriple("i686-pc-windows-gnu");
// else
// mBfIRBuilder->Module_SetTargetTriple("x86_64-pc-windows-gnu");
// }
// else //if (mCompiler->mOptions.mToolsetType == BfToolsetType_Microsoft)
// {
// if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
// mBfIRBuilder->Module_SetTargetTriple("i686-pc-windows-msvc");
// else
// mBfIRBuilder->Module_SetTargetTriple("x86_64-pc-windows-msvc");
// }
// #elif defined BF_PLATFORM_LINUX
// if (mCompiler->mOptions.mMachineType == BfMachineType_x86)
// mBfIRBuilder->Module_SetTargetTriple("i686-unknown-linux-gnu");
// else
// mBfIRBuilder->Module_SetTargetTriple("x86_64-unknown-linux-gnu");
// #else
// // Leave it default
// mBfIRBuilder->Module_SetTargetTriple("");
// #endif
mBfIRBuilder->SetBackend(IsTargetingBeefBackend());
if (moduleOptions.mOptLevel == BfOptLevel_OgPlus)
@ -991,15 +966,6 @@ void BfModule::FinishInit()
mHasFullDebugInfo = moduleOptions.mEmitDebugInfo == 1;
// We need to create DIBuilder for mIsSpecialModule so we have it around when we need it
// if ((!mCompiler->mIsResolveOnly) && ((mIsScratchModule) || (moduleOptions.mEmitDebugInfo != 0)))
// {
// BF_ASSERT((!mBfIRBuilder->mIgnoreWrites) || (mIsScratchModule) || (!mIsReified));
// mBfIRBuilder->DbgInit();
// }
// else
// mHasFullDebugInfo = false;
if ((!mCompiler->mIsResolveOnly) && (!mIsScratchModule) && (moduleOptions.mEmitDebugInfo != 0) && (mIsReified))
{
mBfIRBuilder->DbgInit();

View file

@ -2505,10 +2505,10 @@ BfTypedValue BfModule::TryCaseEnumMatch(BfTypedValue enumVal, BfTypedValue tagVa
}
defer
{
(
if (autoComplete != NULL)
autoComplete->mIsCapturingMethodMatchInfo = (wasCapturingMethodInfo) && (!autoComplete->mIsCapturingMethodMatchInfo);
};
);
///

View file

@ -5319,10 +5319,10 @@ bool DbgModule::ReadCOFF(DataStream* stream, bool isHotObjectFile)
mMemReporter->Add(mImageSize);
}
defer
{
(
if (mMemReporter != NULL)
mMemReporter->EndSection();
};
);
DbgModule* mainModule = mDebugTarget->mTargetBinary;

View file

@ -123,6 +123,8 @@ void free_resources(Find_Result *result) {
// Defer macro/thing.
#undef defer
#define CONCAT_INTERNAL(x,y) x##y
#define CONCAT(x,y) CONCAT_INTERNAL(x,y)

View file

@ -11092,10 +11092,10 @@ String WinDebugger::DisassembleAtRaw(intptr inAddress)
DbgModule* dbgModule = mDebugTarget->FindDbgModuleForAddress(address);
DbgModuleMemoryCache* memCache = NULL;
defer
{
(
if (dbgModule == NULL)
delete memCache;
};
);
if ((dbgModule != NULL) && (dbgModule->mOrigImageData == NULL))
dbgModule = NULL;