Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions IDE/src/Compiler/BfPassInstance.bf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace IDE.Compiler

[CallingConvention(.Stdcall), CLink]
static extern bool BfPassInstance_HadSignatureChanges(void* mNativeResolvePassData);

[CallingConvention(.Stdcall), CLink]
static extern void BfPassInstance_SetOnComptimeOutput(void* mNativeResolvePassData, function void(void* userData, char8* ptr, int32 len) mOnComptimeOutput, void* userData);

public class BfError
{
Expand Down Expand Up @@ -161,5 +164,10 @@ namespace IDE.Compiler
{
return BfPassInstance_HadSignatureChanges(mNativeBfPassInstance);
}

public void SetOnComptimeOutput(function void(void* userData, char8* ptr, int32 len) mOnComptimeOutput, void* userData)
{
BfPassInstance_SetOnComptimeOutput(mNativeBfPassInstance, mOnComptimeOutput, userData);
}
}
}
42 changes: 10 additions & 32 deletions IDE/src/IDEApp.bf
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ namespace IDE
public bool mDbgTimeAutocomplete;
public bool mDbgPerfAutocomplete;
public bool mStopPending;
public String mDeferredCompilerText = new .() ~ delete _;
public BeefConfig mBeefConfig = new BeefConfig() ~ delete _;
public List<String> mDeferredFails = new .() ~ DeleteContainerAndItems!(_);
public String mInitialCWD = new .() ~ delete _;
Expand Down Expand Up @@ -9938,7 +9937,6 @@ namespace IDE

CompileResult(buildCompletedCmd.mHotProjectName, !buildCompletedCmd.mFailed);

FlushDeferredCompilerText(true);
if (buildCompletedCmd.mFailed)
OutputLineSmart("ERROR: BUILD FAILED. Total build time: {0:0.00}s", buildCompletedCmd.mStopwatch.ElapsedMilliseconds / 1000.0f);
else if ((mVerbosity >= .Detailed) && (buildCompletedCmd.mStopwatch != null))
Expand Down Expand Up @@ -10698,6 +10696,16 @@ namespace IDE
BfSystem bfSystem = mBfBuildSystem;
BfCompiler bfCompiler = mBfBuildCompiler;
BfPassInstance passInstance = bfSystem.CreatePassInstance();
passInstance.SetOnComptimeOutput((userData, ptr, len) =>
#if CLI
{
Console.Write(StringView(ptr, len));
}, null);
#else
{
((OutputPanel)Internal.UnsafeCastToObject(userData)).WriteColoredText(StringView(ptr, len), .BuildText);
}, Internal.UnsafeCastToPtr(mOutputPanel));
#endif
bfCompiler.QueueSetPassInstance(passInstance);

bfCompiler.QueueSetWorkspaceOptions(hotProject, hotIdx);
Expand Down Expand Up @@ -11832,28 +11840,6 @@ namespace IDE
}
}

void FlushDeferredCompilerText(bool flushAll)
{
if (mDeferredCompilerText.IsEmpty)
return;

for (var line in mDeferredCompilerText.Split('\n'))
{
if ((!flushAll) && (!@line.HasMore))
{
if (line.Length < mDeferredCompilerText.Length)
{
// Put fragment back
mDeferredCompilerText.Set(line);
}
return;
}

mOutputPanel.WriteColoredTextLine(line, .BuildText);
}
mDeferredCompilerText.Clear();
}

void ProcessBeefCompileResults(BfPassInstance passInstance, CompileKind compileKind, Project hotProject, Stopwatch startStopWatch)
{
bool didCompileSucceed = true;
Expand Down Expand Up @@ -11891,12 +11877,6 @@ namespace IDE
wantsDisp = mVerbosity >= .Detailed;
else if (msgType == ":med")
wantsDisp = mVerbosity >= .Normal;
else if ((msgType == ":text") || (msgType == ":text_line"))
{
mDeferredCompilerText.Append(str.Substring(spacePos + 1));
FlushDeferredCompilerText(msgType == ":text_line");
continue;
}

if (!wantsDisp)
continue;
Expand All @@ -11905,8 +11885,6 @@ namespace IDE
}
}

FlushDeferredCompilerText(true);

str.Append("\n");
OutputSmart(str);
//OutputLine(str);
Expand Down
5 changes: 2 additions & 3 deletions IDE/src/ui/OutputPanel.bf
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ namespace IDE.ui
mOutputWidget.Content.AppendText(mQueuedText);
mOutputWidget.Content.mAutoHorzScroll = true;
mOutputWidget.Content.mEnsureCursorVisibleOnModify = true;
Debug.Assert(editData.mTextLength == startLen + mQueuedText.Length);
//Debug.Assert(editData.mTextLength == startLen + mQueuedText.Length);

for (var queuedDisplayChange in mQueuedDisplayChanges)
{
Expand Down Expand Up @@ -321,11 +321,10 @@ namespace IDE.ui
}
}

public void WriteColoredTextLine(StringView text, SourceElementType elementType)
public void WriteColoredText(StringView text, SourceElementType elementType)
{
mQueuedDisplayChanges.Add(QueuedDisplayChange(mQueuedText.Length, text.Length, (.)elementType));
Write(text);
Write("\n");
}

public void AddInlineWidget(Widget widget)
Expand Down
11 changes: 11 additions & 0 deletions IDEHelper/Compiler/BfSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,11 @@ void BfPassInstance::OutputLine(const StringImpl& str)
mOutStream.push_back(str);
}

void BfPassInstance::ComptimeOutput(const StringImpl& str)
{
mOnComptimeOutput(mOnComptimeOutputUserData, str.GetPtr(), str.GetLength());
}

bool BfPassInstance::PopOutString(String* outString)
{
if (mOutStream.size() == 0)
Expand Down Expand Up @@ -4425,6 +4430,12 @@ BF_EXPORT bool BF_CALLTYPE BfPassInstance_HadSignatureChanges(BfPassInstance* bf
return bfPassInstance->mHadSignatureChanges;
}

BF_EXPORT void BF_CALLTYPE BfPassInstance_SetOnComptimeOutput(BfPassInstance* bfPassInstance, void (*mOnComptimeOutput)(void* userData, const char* ptr, int len), void* userData)
{
bfPassInstance->mOnComptimeOutput = mOnComptimeOutput;
bfPassInstance->mOnComptimeOutputUserData = userData;
}

BF_EXPORT void BF_CALLTYPE BfPassInstance_Delete(BfPassInstance* bfPassInstance)
{
delete bfPassInstance;
Expand Down
5 changes: 5 additions & 0 deletions IDEHelper/Compiler/BfSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,8 @@ class BfPassInstance
uint8 mClassifierPassId;
HashSet<BfSourceData*> mFilterErrorsTo;
bool mHadSignatureChanges;
void (*mOnComptimeOutput)(void* userData, const char* ptr, int len);
void* mOnComptimeOutputUserData;

public:
BfPassInstance(BfSystem* bfSystem)
Expand All @@ -1647,6 +1649,8 @@ class BfPassInstance
mDeferredErrorCount = 0;
mIgnoreCount = 0;
mHadSignatureChanges = false;
mOnComptimeOutput = NULL;
mOnComptimeOutputUserData = NULL;
}

~BfPassInstance();
Expand All @@ -1658,6 +1662,7 @@ class BfPassInstance
bool HasFailed();
bool HasMessages();
void OutputLine(const StringImpl& str);
void ComptimeOutput(const StringImpl& str);
bool PopOutString(String* outString);
bool WantsRangeRecorded(BfSourceData* bfSource, int srcIdx, int srcLen, bool isWarning, bool isDeferred = false);
bool WantsRangeDisplayed(BfSourceData* bfSource, int srcIdx, int srcLen, bool isWarning, bool isDeferred = false);
Expand Down
21 changes: 2 additions & 19 deletions IDEHelper/Compiler/CeMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7067,25 +7067,8 @@ bool CeContext::Execute(CeFunction* startFunction, uint8* startStackPtr, uint8*
return false;
}

auto frame = _GetCurFrame();

int curPos = 0;

while (curPos < str.length())
{
int crPos = str.IndexOf('\n', curPos);
if (crPos == -1)
{
mCeMachine->mCompiler->mPassInstance->OutputLine(":text " + str.Substring(curPos));
break;
}

int endPos = crPos;
if ((endPos > 0) && (str[endPos - 1] == '\r'))
endPos--;
mCeMachine->mCompiler->mPassInstance->OutputLine(":text_line " + str.Substring(curPos, endPos - curPos));
curPos = crPos + 1;
}
if (!str.IsEmpty())
mCeMachine->mCompiler->mPassInstance->ComptimeOutput(str);
}
else if (checkFunction->mFunctionKind == CeFunctionKind_Sleep)
{
Expand Down
Loading