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

Use StackHelper for very long if/else chains

This commit is contained in:
Brian Fiete 2024-03-18 05:44:02 -04:00
parent 22b0aba954
commit 084566cdc6
7 changed files with 68 additions and 7 deletions

View file

@ -2,6 +2,7 @@
#include "../Beef/BfCommon.h"
#include "../Compiler/BfUtil.h"
#include "BeefySysLib/util/BeefPerf.h"
#include "BeefySysLib/util/StackHelper.h"
#include "../Compiler/BfIRCodeGen.h"
#include "BeefySysLib/util/AllocDebug.h"
@ -1031,8 +1032,27 @@ void BeDbgEnumType::SetMembers(SizedArrayImpl<BeMDNode*>& members)
//////////////////////////////////////////////////////////////////////////
void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, bool mdDrillDown)
void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, bool mdDrillDown, bool checkStack)
{
if (checkStack)
{
BP_ZONE("CreateValueFromExpression:CheckStack");
StackHelper stackHelper;
if (!stackHelper.CanStackExpand(64 * 1024))
{
if (!stackHelper.Execute([&]()
{
ToString(str, value, showType, mdDrillDown, false);
}))
{
//Fail("Expression too complex to compile", expr);
str += "!!!FAILED!!!";
}
return;
}
}
if (value == NULL)
{
str += "<null>";
@ -1105,7 +1125,7 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo
str += StrFormat("%d@", lexBlock->mId);
ToString(str, lexBlock->mFile);
str += ":";
ToString(str, lexBlock->mScope);
ToString(str, lexBlock->mScope, true, false, true);
return;
}

View file

@ -1554,7 +1554,7 @@ public:
Dictionary<BeValue*, String> mValueNameMap;
Dictionary<String, int> mSeenNames;
void ToString(StringImpl& str, BeValue* value, bool showType = true, bool mdDrillDown = false);
void ToString(StringImpl& str, BeValue* value, bool showType = true, bool mdDrillDown = false, bool checkStack = false);
void ToString(StringImpl& str, BeType* type);
void ToString(StringImpl& str, BeDbgFunction* dbgFunction, bool showScope);
static void ToString(StringImpl& str, int val);