1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 03:28:20 +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

@ -32,7 +32,7 @@ using namespace Beefy;
BF_IMPORT void BF_CALLTYPE Debugger_ProgramDone(); BF_IMPORT void BF_CALLTYPE Debugger_ProgramDone();
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
#ifdef TEST_CRASH #ifdef TEST_CRASH
CrashCatcher catcher; CrashCatcher catcher;
catcher.SetCrashReportKind(BfpCrashReportKind_GUI); catcher.SetCrashReportKind(BfpCrashReportKind_GUI);

View file

@ -763,7 +763,11 @@ void BootApp::DoLinkGNU()
linkLine.Append(" "); linkLine.Append(" ");
linkLine.Append("-g "); linkLine.Append("-g ");
linkLine.Append("-debug -no-pie "); linkLine.Append("-debug ");
#ifdef BF_PLATFORM_LINUX
linkLine.Append("-no-pie ");
#endif
linkLine.Append(mLinkParams); linkLine.Append(mLinkParams);
auto runCmd = QueueRun(linkerPath, linkLine, mWorkingDir, BfpSpawnFlag_UseArgsFile); auto runCmd = QueueRun(linkerPath, linkLine, mWorkingDir, BfpSpawnFlag_UseArgsFile);

View file

@ -17,7 +17,7 @@ typedef fd_set FD_SET;
#define closesocket close #define closesocket close
#endif #endif
#ifdef BF_PLATFORM_OSX #ifdef BF_PLATFORM_MACOS
#include <sys/socket.h> #include <sys/socket.h>
#include <mach/error.h> #include <mach/error.h>
#include <mach/mach.h> #include <mach/mach.h>

View file

@ -38,6 +38,18 @@ namespace IDE
Failed Failed
} }
Workspace.PlatformType mPlatformType;
Workspace.ToolsetType mToolset;
int mPtrSize;
public this()
{
Workspace.Options workspaceOptions = gApp.GetCurWorkspaceOptions();
mToolset = workspaceOptions.mToolsetType;
mPlatformType = Workspace.PlatformType.GetFromName(gApp.mPlatformName);
mPtrSize = Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName);
}
public CustomBuildCommandResult QueueProjectCustomBuildCommands(Project project, String targetPath, Project.BuildCommandTrigger trigger, List<String> cmdList) public CustomBuildCommandResult QueueProjectCustomBuildCommands(Project project, String targetPath, Project.BuildCommandTrigger trigger, List<String> cmdList)
{ {
if (cmdList.IsEmpty) if (cmdList.IsEmpty)
@ -186,7 +198,8 @@ namespace IDE
linkLine.Append("-mwindows "); linkLine.Append("-mwindows ");
} }
linkLine.Append("-no-pie "); if (mPlatformType == .Linux)
linkLine.Append("-no-pie ");
linkLine.Append(objectsArg); linkLine.Append(objectsArg);
@ -204,7 +217,7 @@ namespace IDE
String[] mingwFiles; String[] mingwFiles;
String fromDir; String fromDir;
if (Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 4) if (mPtrSize == 4)
{ {
fromDir = scope:: String(llvmDir, "i686-w64-mingw32/bin/"); fromDir = scope:: String(llvmDir, "i686-w64-mingw32/bin/");
mingwFiles = scope:: String[] { "libgcc_s_dw2-1.dll", "libstdc++-6.dll" }; mingwFiles = scope:: String[] { "libgcc_s_dw2-1.dll", "libstdc++-6.dll" };
@ -298,7 +311,7 @@ namespace IDE
if (workspaceOptions.mToolsetType == .GNU) if (workspaceOptions.mToolsetType == .GNU)
{ {
if (Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 4) if (mPtrSize == 4)
{ {
} }
else else
@ -311,7 +324,7 @@ namespace IDE
} }
else // Microsoft else // Microsoft
{ {
if (Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 4) if (mPtrSize == 4)
{ {
//linkLine.Append("-L\"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10586.0\\ucrt\\x86\" "); //linkLine.Append("-L\"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10586.0\\ucrt\\x86\" ");
for (var libPath in gApp.mSettings.mVSSettings.mLib32Paths) for (var libPath in gApp.mSettings.mVSSettings.mLib32Paths)
@ -411,33 +424,11 @@ namespace IDE
outDbg.Append("_d"); outDbg.Append("_d");
outDbg.Append(dynName ? ".dll" : ".lib"); outDbg.Append(dynName ? ".dll" : ".lib");
} }
/*if ((workspaceOptions.mEnableObjectDebugFlags) &&
((!dynName) || (options.mBuildOptions.mBeefLibType != .Static)))
{
outDbg.Append("Beef", IDEApp.sRTVersionStr, "Dbg");
outDbg.Append((workspaceOptions.mMachineType == .x86) ? "32" : "64");
switch (options.mBuildOptions.mBeefLibType)
{
case .Dynamic:
case .DynamicDebug: outDbg.Append("_d");
case .Static:
switch (options.mBuildOptions.mCLibType)
{
case .None:
case .Dynamic, .SystemMSVCRT: outDbg.Append("_s");
case .DynamicDebug: outDbg.Append("_sd");
case .Static: outDbg.Append("_ss");
case .StaticDebug: outDbg.Append("_ssd");
}
}
outDbg.Append(dynName ? ".dll" : ".lib");
}*/
} }
bool QueueProjectMSLink(Project project, String targetPath, String configName, Workspace.Options workspaceOptions, Project.Options options, String objectsArg) bool QueueProjectMSLink(Project project, String targetPath, String configName, Workspace.Options workspaceOptions, Project.Options options, String objectsArg)
{ {
bool is64Bit = Workspace.PlatformType.GetPtrSizeByName(gApp.mPlatformName) == 8; bool is64Bit = mPtrSize == 8;
String llvmDir = scope String(IDEApp.sApp.mInstallDir); String llvmDir = scope String(IDEApp.sApp.mInstallDir);
IDEUtils.FixFilePath(llvmDir); IDEUtils.FixFilePath(llvmDir);
@ -1060,7 +1051,12 @@ namespace IDE
} }
else // MS else // MS
{ {
if (!QueueProjectMSLink(project, targetPath, configSelection.mConfig, workspaceOptions, options, objectsArg)) if (mPlatformType != .Windows)
{
gApp.OutputErrorLine("Project '{}' cannot be linked with the Windows Toolset for platform '{}'", project.mProjectName, mPlatformType);
return false;
}
else if (!QueueProjectMSLink(project, targetPath, configSelection.mConfig, workspaceOptions, options, objectsArg))
return false; return false;
} }

View file

@ -107,7 +107,7 @@ namespace IDE
#elif BF_PLATFORM_LINUX #elif BF_PLATFORM_LINUX
public static readonly String sPlatform64Name = "Linux64"; public static readonly String sPlatform64Name = "Linux64";
public static readonly String sPlatform32Name = "Linux32"; public static readonly String sPlatform32Name = "Linux32";
#elif BF_PLATFORM_OSX #elif BF_PLATFORM_MACOS
public static readonly String sPlatform64Name = "macOS"; public static readonly String sPlatform64Name = "macOS";
public static readonly String sPlatform32Name = null; public static readonly String sPlatform32Name = null;
#else #else
@ -8358,17 +8358,24 @@ namespace IDE
if (!DoResolveConfigString(platformName, workspaceOptions, project, options, options.mBuildOptions.mTargetName, error, newString)) if (!DoResolveConfigString(platformName, workspaceOptions, project, options, options.mBuildOptions.mTargetName, error, newString))
return false; return false;
#if BF_PLATFORM_WINDOWS
if (project.mGeneralOptions.mTargetType == .BeefLib) let platformType = Workspace.PlatformType.GetFromName(platformName);
newString.Append(".lib"); switch (platformType)
else if (project.mGeneralOptions.mTargetType == .BeefDynLib) {
newString.Append(".dll"); case .Windows:
else if (project.mGeneralOptions.mTargetType != .CustomBuild) if (project.mGeneralOptions.mTargetType == .BeefLib)
newString.Append(".exe"); newString.Append(".lib");
#else else if (project.mGeneralOptions.mTargetType == .BeefDynLib)
if (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib) newString.Append(".dll");
newString.Append(".so"); else if (project.mGeneralOptions.mTargetType != .CustomBuild)
#endif newString.Append(".exe");
case .macOS:
if (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib)
newString.Append(".dylib");
default:
if (project.mGeneralOptions.mTargetType == Project.TargetType.BeefLib)
newString.Append(".so");
}
} }
case "ProjectDir": case "ProjectDir":
if (project.IsDebugSession) if (project.IsDebugSession)
@ -8390,24 +8397,33 @@ namespace IDE
(project.mGeneralOptions.mTargetType == .BeefDynLib) || (project.mGeneralOptions.mTargetType == .BeefDynLib) ||
((options.mBuildOptions.mBuildKind == .Test) && (project == mWorkspace.mStartupProject))) ((options.mBuildOptions.mBuildKind == .Test) && (project == mWorkspace.mStartupProject)))
{ {
#if BF_PLATFORM_WINDOWS
String rtName = scope String(); let platformType = Workspace.PlatformType.GetFromName(platformName);
String dbgName = scope String(); switch (platformType)
BuildContext.GetRtLibNames(workspaceOptions, options, false, rtName, dbgName);
newString.Append(rtName);
if (!dbgName.IsEmpty)
newString.Append(" ", dbgName);
switch (workspaceOptions.mAllocType)
{ {
case .JEMalloc: case .Windows:
newString.Append(" jemalloc.lib"); String rtName = scope String();
case .TCMalloc: String dbgName = scope String();
newString.Append(" tcmalloc.lib"); BuildContext.GetRtLibNames(workspaceOptions, options, false, rtName, dbgName);
newString.Append(rtName);
if (!dbgName.IsEmpty)
newString.Append(" ", dbgName);
switch (workspaceOptions.mAllocType)
{
case .JEMalloc:
newString.Append(" jemalloc.lib");
case .TCMalloc:
newString.Append(" tcmalloc.lib");
default:
}
case .macOS:
newString.Append("./libBeefRT_d.dylib -Wl,-rpath -Wl,.");
case .iOS:
case .Linux:
newString.Append("./libBeefRT_d.so -Wl,-rpath -Wl,$ORIGIN");
default: default:
} }
#else
newString.Append("./libBeefRT_d.so -Wl,-rpath -Wl,.");
#endif
} }
case "VSToolPath": case "VSToolPath":
if (Workspace.PlatformType.GetPtrSizeByName(platformName) == 4) if (Workspace.PlatformType.GetPtrSizeByName(platformName) == 4)
@ -9255,6 +9271,9 @@ namespace IDE
{ {
canCompile = false; canCompile = false;
} }
//TODO:
canCompile = true;
if (!canCompile) if (!canCompile)
{ {

View file

@ -99,7 +99,7 @@ namespace IDE
{ {
String fileName = scope String(); String fileName = scope String();
GetUserDirectFileName(fileName); GetUserDirectFileName(fileName);
File.WriteAllLines(fileName, mCustomDictionaryWordList.GetEnumerator()); File.WriteAllLines(fileName, mCustomDictionaryWordList.GetEnumerator()).IgnoreError();
} }

View file

@ -20,31 +20,13 @@ namespace IDE
ObjectAndIRCode ObjectAndIRCode
} }
public enum MachineType
{
case x86;
case x64;
public int32 PtrSize
{
get
{
switch (this)
{
case .x86:
return 4;
case .x64:
return 8;
}
}
}
}
public enum PlatformType public enum PlatformType
{ {
case Unknown; case Unknown;
case Windows; case Windows;
case Linux; case Linux;
case macOS;
case iOS;
public static PlatformType GetFromName(String name) public static PlatformType GetFromName(String name)
{ {
@ -52,6 +34,8 @@ namespace IDE
{ {
case "Win32", "Win64": return .Windows; case "Win32", "Win64": return .Windows;
case "Linux32", "Linux64": return .Linux; case "Linux32", "Linux64": return .Linux;
case "macOS": return .macOS;
case "iOS": return .iOS;
default: return .Unknown; default: return .Unknown;
} }
} }
@ -66,6 +50,10 @@ namespace IDE
return .Linux; return .Linux;
#endif #endif
#if BF_PLATFORM_MACOS
return .Linux;
#endif
#unwarn #unwarn
return .Unknown; return .Unknown;
} }
@ -585,6 +573,9 @@ namespace IDE
{ {
var options = platformKeyValue.value; var options = platformKeyValue.value;
var platformName = platformKeyValue.key; var platformName = platformKeyValue.key;
let platformType = PlatformType.GetFromName(platformName);
using (data.CreateObject(platformName)) using (data.CreateObject(platformName))
{ {
using (data.CreateArray("PreprocessorMacros")) using (data.CreateArray("PreprocessorMacros"))
@ -597,11 +588,10 @@ namespace IDE
data.ConditionalAdd("Toolset", options.mToolsetType, ToolsetType.Default); data.ConditionalAdd("Toolset", options.mToolsetType, ToolsetType.Default);
data.ConditionalAdd("BuildKind", options.mBuildKind, isTest ? .Test : .Normal); data.ConditionalAdd("BuildKind", options.mBuildKind, isTest ? .Test : .Normal);
data.ConditionalAdd("BfSIMDSetting", options.mBfSIMDSetting, .SSE2); data.ConditionalAdd("BfSIMDSetting", options.mBfSIMDSetting, .SSE2);
#if BF_PLATFORM_WINDOWS if (platformType == .Windows)
data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0); data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
#else else
data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : .O0); data.ConditionalAdd("BfOptimizationLevel", options.mBfOptimizationLevel, isRelease ? .O2 : .O0);
#endif
data.ConditionalAdd("LTOType", options.mLTOType, .None); data.ConditionalAdd("LTOType", options.mLTOType, .None);
data.ConditionalAdd("AllocType", options.mAllocType, isRelease ? .CRT : .Debug); data.ConditionalAdd("AllocType", options.mAllocType, isRelease ? .CRT : .Debug);
data.ConditionalAdd("AllocMalloc", options.mAllocMalloc, ""); data.ConditionalAdd("AllocMalloc", options.mAllocMalloc, "");
@ -705,15 +695,19 @@ namespace IDE
#unwarn #unwarn
bool isParanoid = configName.Contains("Paranoid"); bool isParanoid = configName.Contains("Paranoid");
bool isTest = configName.Contains("Test"); bool isTest = configName.Contains("Test");
let platformType = PlatformType.GetFromName(platformName);
options.mBfSIMDSetting = .SSE2; options.mBfSIMDSetting = .SSE2;
#if BF_PLATFORM_WINDOWS if (platformType == .Windows)
options.mBfOptimizationLevel = isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0; {
options.mToolsetType = .Microsoft; options.mBfOptimizationLevel = isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0;
#else options.mToolsetType = .Microsoft;
options.mBfOptimizationLevel = isRelease ? .O2 : .O0; }
options.mToolsetType = .GNU; else
#endif {
options.mBfOptimizationLevel = isRelease ? .O2 : .O0;
options.mToolsetType = .GNU;
}
options.mAllocType = isRelease ? .CRT : .Debug; options.mAllocType = isRelease ? .CRT : .Debug;
options.mEmitDebugInfo = .Yes; options.mEmitDebugInfo = .Yes;
@ -726,13 +720,16 @@ namespace IDE
options.mEnableObjectDebugFlags = !isRelease; options.mEnableObjectDebugFlags = !isRelease;
options.mEmitObjectAccessCheck = !isRelease; options.mEmitObjectAccessCheck = !isRelease;
#if BF_PLATFORM_WINDOWS if (platformType == .Windows)
options.mEnableRealtimeLeakCheck = !isRelease; {
options.mEnableSideStack = isParanoid; options.mEnableRealtimeLeakCheck = !isRelease;
#else options.mEnableSideStack = isParanoid;
options.mEnableRealtimeLeakCheck = false; }
options.mEnableSideStack = false; else
#endif {
options.mEnableRealtimeLeakCheck = false;
options.mEnableSideStack = false;
}
options.mAllowHotSwapping = !isRelease; options.mAllowHotSwapping = !isRelease;
options.mIncrementalBuild = !isRelease; options.mIncrementalBuild = !isRelease;
@ -784,6 +781,7 @@ namespace IDE
{ {
Options options = new Options(); Options options = new Options();
let platformName = new String(platformNameKey); let platformName = new String(platformNameKey);
let platformType = PlatformType.GetFromName(platformName);
config.mPlatforms[platformName] = options; config.mPlatforms[platformName] = options;
SetupDefault(options, configName, platformName); SetupDefault(options, configName, platformName);
@ -798,11 +796,11 @@ namespace IDE
options.mToolsetType = data.GetEnum<ToolsetType>("Toolset", ToolsetType.Default); options.mToolsetType = data.GetEnum<ToolsetType>("Toolset", ToolsetType.Default);
options.mBuildKind = data.GetEnum<BuildKind>("BuildKind", isTest ? .Test : .Normal); options.mBuildKind = data.GetEnum<BuildKind>("BuildKind", isTest ? .Test : .Normal);
options.mBfSIMDSetting = data.GetEnum<BuildOptions.SIMDSetting>("BfSIMDSetting", .SSE2); options.mBfSIMDSetting = data.GetEnum<BuildOptions.SIMDSetting>("BfSIMDSetting", .SSE2);
#if BF_PLATFORM_WINDOWS if (platformType == .Windows)
options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0); options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : (platformName == "Win64") ? .OgPlus : .O0);
#else else
options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : .O0); options.mBfOptimizationLevel = data.GetEnum<BuildOptions.BfOptimizationLevel>("BfOptimizationLevel", isRelease ? .O2 : .O0);
#endif
options.mLTOType = data.GetEnum<BuildOptions.LTOType>("LTOType", .None); options.mLTOType = data.GetEnum<BuildOptions.LTOType>("LTOType", .None);
options.mAllocType = data.GetEnum<AllocType>("AllocType", isRelease ? .CRT : .Debug); options.mAllocType = data.GetEnum<AllocType>("AllocType", isRelease ? .CRT : .Debug);
data.GetString("AllocMalloc", options.mAllocMalloc); data.GetString("AllocMalloc", options.mAllocMalloc);

View file

@ -494,7 +494,6 @@ namespace IDE.ui
var (category, propEntry) = AddPropertiesItem(root, "General"); var (category, propEntry) = AddPropertiesItem(root, "General");
category.mIsBold = true; category.mIsBold = true;
category.mTextColor = cHeaderColor; category.mTextColor = cHeaderColor;
AddPropertiesItem(category, "Machine Type", "mMachineType");
AddPropertiesItem(category, "Toolset", "mToolsetType"); AddPropertiesItem(category, "Toolset", "mToolsetType");
AddPropertiesItem(category, "Build Type", "mBuildKind"); AddPropertiesItem(category, "Build Type", "mBuildKind");

View file

@ -4717,9 +4717,9 @@ bool COFF::CvParseDBI(int wantAge)
uint8* data = CvReadStream(3); uint8* data = CvReadStream(3);
uint8* sectionData = data; uint8* sectionData = data;
defer defer
{ (
delete sectionData; delete sectionData;
}; );
// Header // Header
GET_INTO(int32, signature); GET_INTO(int32, signature);
@ -5578,22 +5578,7 @@ bool COFF::ParseCv(DataStream& pdbFS, uint8* rootDirData, int pageSize, uint8 wa
if (mParseKind == ParseKind_Header) if (mParseKind == ParseKind_Header)
return true; 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"); BP_ZONE("COFF::ParseCv_ReadStrTable");
if (mStringTable.mStream != -1) 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++) for (int compileUnitId = 0; compileUnitId < (int)mCvModuleInfo.size(); compileUnitId++)
{ {
//ParseCompileUnit(compileUnitId);
ScanCompileUnit(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; return true;
} }
@ -5764,9 +5733,6 @@ bool COFF::TryLoadPDB(const String& pdbPath, uint8 wantGuid[16], int32 wantAge)
return false; return false;
} }
//FixTypes(startingTypeIdx);
//MapTypes(startingTypeIdx);
if (mCvDataStream->mFailed) if (mCvDataStream->mFailed)
return false; return false;
@ -5928,24 +5894,13 @@ void COFF::ProcessDebugInfo()
GET_INTO(uint32, infoType); GET_INTO(uint32, infoType);
BF_ASSERT(infoType == CV_SIGNATURE_C13); BF_ASSERT(infoType == CV_SIGNATURE_C13);
CvInitStreamRaw(mCvTypeSectionReader, entry.mData + 4, entry.mSize - 4); CvInitStreamRaw(mCvTypeSectionReader, entry.mData + 4, entry.mSize - 4);
//ParseTypeData(data, mCvTypeSectionDataSize - sizeof(uint32));
ParseTypeData(mCvTypeSectionReader, 0); ParseTypeData(mCvTypeSectionReader, 0);
} }
FixTypes(startingTypeIdx); FixTypes(startingTypeIdx);
linkedModule->MapTypes(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; CvCompileUnit* compileUnit = NULL;
for (auto entry : mCvCompileUnitData) for (auto entry : mCvCompileUnitData)
{ {

View file

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

View file

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

View file

@ -956,31 +956,6 @@ void BfModule::FinishInit()
mBfIRBuilder->Module_SetTargetTriple(mCompiler->mOptions.mTargetTriple); 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()); mBfIRBuilder->SetBackend(IsTargetingBeefBackend());
if (moduleOptions.mOptLevel == BfOptLevel_OgPlus) if (moduleOptions.mOptLevel == BfOptLevel_OgPlus)
@ -991,15 +966,6 @@ void BfModule::FinishInit()
mHasFullDebugInfo = moduleOptions.mEmitDebugInfo == 1; 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)) if ((!mCompiler->mIsResolveOnly) && (!mIsScratchModule) && (moduleOptions.mEmitDebugInfo != 0) && (mIsReified))
{ {
mBfIRBuilder->DbgInit(); mBfIRBuilder->DbgInit();

View file

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

View file

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

View file

@ -123,6 +123,8 @@ void free_resources(Find_Result *result) {
// Defer macro/thing. // Defer macro/thing.
#undef defer
#define CONCAT_INTERNAL(x,y) x##y #define CONCAT_INTERNAL(x,y) x##y
#define CONCAT(x,y) CONCAT_INTERNAL(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); DbgModule* dbgModule = mDebugTarget->FindDbgModuleForAddress(address);
DbgModuleMemoryCache* memCache = NULL; DbgModuleMemoryCache* memCache = NULL;
defer defer
{ (
if (dbgModule == NULL) if (dbgModule == NULL)
delete memCache; delete memCache;
}; );
if ((dbgModule != NULL) && (dbgModule->mOrigImageData == NULL)) if ((dbgModule != NULL) && (dbgModule->mOrigImageData == NULL))
dbgModule = NULL; dbgModule = NULL;

View file

@ -41,11 +41,11 @@ cmake --build .
cd ../IDE/dist cd ../IDE/dist
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
LIBEXT=dylib LIBEXT=dylib
LINKOPTS= LINKOPTS="-Wl,-rpath -Wl,."
else else
LIBEXT=so LIBEXT=so
LINKOPTS=-ltinfo LINKOPTS="-ltinfo -Wl,-rpath -Wl,\$ORIGIN"
fi fi
if [ ! -L libBeefRT_d.$LIBEXT ]; then if [ ! -L libBeefRT_d.$LIBEXT ]; then
@ -61,7 +61,7 @@ fi
### DEBUG ### ### DEBUG ###
echo Building BeefBuild_bootd echo Building BeefBuild_bootd
../../jbuild_d/Debug/bin/BeefBoot --out="BeefBuild_bootd" --src=../src --src=../../BeefBuild/src --src=../../BeefLibs/corlib/src --src=../../BeefLibs/Beefy2D/src --define=CLI --define=DEBUG --startup=BeefBuild.Program --linkparams="./libBeefRT_d.$LIBEXT ./libIDEHelper_d.$LIBEXT ./libBeefySysLib_d.$LIBEXT ../../extern/llvm_linux_8_0_0/lib/libLLVMCore.a ../../extern/llvm_linux_8_0_0/lib/libLLVMMC.a ../../extern/llvm_linux_8_0_0/lib/libLLVMMCParser.a ../../extern/llvm_linux_8_0_0/lib/libLLVMCodeGen.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86Disassembler.a ../../extern/llvm_linux_8_0_0/lib/libLLVMMCDisassembler.a ../../extern/llvm_linux_8_0_0/lib/libLLVMSupport.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86Info.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86Utils.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86AsmPrinter.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86Desc.a ../../extern/llvm_linux_8_0_0/lib/libLLVMObject.a ../../extern/llvm_linux_8_0_0/lib/libLLVMBitReader.a ../../extern/llvm_linux_8_0_0/lib/libLLVMAsmParser.a ../../extern/llvm_linux_8_0_0/lib/libLLVMTarget.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86CodeGen.a ../../extern/llvm_linux_8_0_0/lib/libLLVMScalarOpts.a ../../extern/llvm_linux_8_0_0/lib/libLLVMInstCombine.a ../../extern/llvm_linux_8_0_0/lib/libLLVMSelectionDAG.a ../../extern/llvm_linux_8_0_0/lib/libLLVMProfileData.a ../../extern/llvm_linux_8_0_0/lib/libLLVMTransformUtils.a ../../extern/llvm_linux_8_0_0/lib/libLLVMAnalysis.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86AsmParser.a ../../extern/llvm_linux_8_0_0/lib/libLLVMAsmPrinter.a ../../extern/llvm_linux_8_0_0/lib/libLLVMBitWriter.a ../../extern/llvm_linux_8_0_0/lib/libLLVMVectorize.a ../../extern/llvm_linux_8_0_0/lib/libLLVMipo.a ../../extern/llvm_linux_8_0_0/lib/libLLVMInstrumentation.a ../../extern/llvm_linux_8_0_0/lib/libLLVMDebugInfoDWARF.a ../../extern/llvm_linux_8_0_0/lib/libLLVMDebugInfoPDB.a ../../extern/llvm_linux_8_0_0/lib/libLLVMDebugInfoCodeView.a ../../extern/llvm_linux_8_0_0/lib/libLLVMGlobalISel.a ../../extern/llvm_linux_8_0_0/lib/libLLVMBinaryFormat.a ../../extern/llvm_linux_8_0_0/lib/libLLVMDemangle.a $LINKOPTS -Wl,-rpath -Wl,\$ORIGIN" ../../jbuild_d/Debug/bin/BeefBoot --out="BeefBuild_bootd" --src=../src --src=../../BeefBuild/src --src=../../BeefLibs/corlib/src --src=../../BeefLibs/Beefy2D/src --define=CLI --define=DEBUG --startup=BeefBuild.Program --linkparams="./libBeefRT_d.$LIBEXT ./libIDEHelper_d.$LIBEXT ./libBeefySysLib_d.$LIBEXT ../../extern/llvm_linux_8_0_0/lib/libLLVMCore.a ../../extern/llvm_linux_8_0_0/lib/libLLVMMC.a ../../extern/llvm_linux_8_0_0/lib/libLLVMMCParser.a ../../extern/llvm_linux_8_0_0/lib/libLLVMCodeGen.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86Disassembler.a ../../extern/llvm_linux_8_0_0/lib/libLLVMMCDisassembler.a ../../extern/llvm_linux_8_0_0/lib/libLLVMSupport.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86Info.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86Utils.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86AsmPrinter.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86Desc.a ../../extern/llvm_linux_8_0_0/lib/libLLVMObject.a ../../extern/llvm_linux_8_0_0/lib/libLLVMBitReader.a ../../extern/llvm_linux_8_0_0/lib/libLLVMAsmParser.a ../../extern/llvm_linux_8_0_0/lib/libLLVMTarget.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86CodeGen.a ../../extern/llvm_linux_8_0_0/lib/libLLVMScalarOpts.a ../../extern/llvm_linux_8_0_0/lib/libLLVMInstCombine.a ../../extern/llvm_linux_8_0_0/lib/libLLVMSelectionDAG.a ../../extern/llvm_linux_8_0_0/lib/libLLVMProfileData.a ../../extern/llvm_linux_8_0_0/lib/libLLVMTransformUtils.a ../../extern/llvm_linux_8_0_0/lib/libLLVMAnalysis.a ../../extern/llvm_linux_8_0_0/lib/libLLVMX86AsmParser.a ../../extern/llvm_linux_8_0_0/lib/libLLVMAsmPrinter.a ../../extern/llvm_linux_8_0_0/lib/libLLVMBitWriter.a ../../extern/llvm_linux_8_0_0/lib/libLLVMVectorize.a ../../extern/llvm_linux_8_0_0/lib/libLLVMipo.a ../../extern/llvm_linux_8_0_0/lib/libLLVMInstrumentation.a ../../extern/llvm_linux_8_0_0/lib/libLLVMDebugInfoDWARF.a ../../extern/llvm_linux_8_0_0/lib/libLLVMDebugInfoPDB.a ../../extern/llvm_linux_8_0_0/lib/libLLVMDebugInfoCodeView.a ../../extern/llvm_linux_8_0_0/lib/libLLVMGlobalISel.a ../../extern/llvm_linux_8_0_0/lib/libLLVMBinaryFormat.a ../../extern/llvm_linux_8_0_0/lib/libLLVMDemangle.a $LINKOPTS"
echo Building BeefBuild_d echo Building BeefBuild_d
./BeefBuild_bootd -clean -proddir=../../BeefBuild -config=Debug -platform=Linux64 ./BeefBuild_bootd -clean -proddir=../../BeefBuild -config=Debug -platform=Linux64
#./BeefBuild_d -proddir=../../TestApp #./BeefBuild_d -proddir=../../TestApp