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

Improvements to emit markers on emits only in specialized types

This commit is contained in:
Brian Fiete 2022-05-02 07:48:29 -07:00
parent 01112c54fe
commit 5271f5e2fd
14 changed files with 342 additions and 68 deletions

View file

@ -221,6 +221,12 @@ namespace IDE.Compiler
class RefreshViewCommand : Command class RefreshViewCommand : Command
{ {
public ViewRefreshKind mRefreshKind;
public this(ViewRefreshKind refreshKind)
{
mRefreshKind = refreshKind;
}
} }
class SetWorkspaceOptionsCommand : Command class SetWorkspaceOptionsCommand : Command
@ -237,6 +243,7 @@ namespace IDE.Compiler
public void* mNativeBfCompiler; public void* mNativeBfCompiler;
public bool mIsResolveOnly; public bool mIsResolveOnly;
public bool mWantsResolveAllCollapseRefresh;
public BfSystem mBfSystem; public BfSystem mBfSystem;
bool mWantsRemoveOldData; bool mWantsRemoveOldData;
public Dictionary<String, String> mRebuildWatchingFiles = new .() ~ delete _; public Dictionary<String, String> mRebuildWatchingFiles = new .() ~ delete _;
@ -392,9 +399,9 @@ namespace IDE.Compiler
QueueCommand(command); QueueCommand(command);
} }
public void QueueRefreshViewCommand() public void QueueRefreshViewCommand(ViewRefreshKind viewRefreshKind = .FullRefresh)
{ {
QueueCommand(new RefreshViewCommand()); QueueCommand(new RefreshViewCommand(viewRefreshKind));
} }
public void QueueSetWorkspaceOptions(Project hotProject, int32 hotIdx) public void QueueSetWorkspaceOptions(Project hotProject, int32 hotIdx)
@ -608,8 +615,31 @@ namespace IDE.Compiler
var resolvePassData = BfResolvePassData.Create(ResolveType.Classify); var resolvePassData = BfResolvePassData.Create(ResolveType.Classify);
// If we get canceled then try again after waiting a couple updates // If we get canceled then try again after waiting a couple updates
if (!ClassifySource(passInstance, resolvePassData))
bool wantsCollapseRefresh = false;
if (ClassifySource(passInstance, resolvePassData))
{
Debug.WriteLine($"ClassifySource success {mWantsResolveAllCollapseRefresh} {resolvePassData.HadEmits}");
if (mWantsResolveAllCollapseRefresh)
{
mWantsResolveAllCollapseRefresh = false;
wantsCollapseRefresh = true;
}
}
else
{
Debug.WriteLine($"ClassifySource partial {resolvePassData.HadEmits}");
QueueDeferredResolveAll(); QueueDeferredResolveAll();
}
if (resolvePassData.HadEmits)
wantsCollapseRefresh = true;
if (wantsCollapseRefresh)
QueueRefreshViewCommand(.Collapse);
UpdateRebuildFileWatches(); UpdateRebuildFileWatches();
delete resolvePassData; delete resolvePassData;
@ -632,7 +662,8 @@ namespace IDE.Compiler
if (command is RefreshViewCommand) if (command is RefreshViewCommand)
{ {
mWantsActiveViewRefresh = true; var refreshViewCommand = (RefreshViewCommand)command;
mWantsActiveViewRefresh = Math.Max(mWantsActiveViewRefresh, refreshViewCommand.mRefreshKind);
} }
if (var dirChangedCommand = command as RebuildFileChangedCommand) if (var dirChangedCommand = command as RebuildFileChangedCommand)

View file

@ -44,12 +44,16 @@ namespace IDE.Compiler
[CallingConvention(.Stdcall), CLink] [CallingConvention(.Stdcall), CLink]
static extern void* BfResolvePassData_GetEmitEmbedData(void* bfResolvePassData, char8* typeName, out int32 srcLength, out int32 revision); static extern void* BfResolvePassData_GetEmitEmbedData(void* bfResolvePassData, char8* typeName, out int32 srcLength, out int32 revision);
[CallingConvention(.Stdcall), CLink]
static extern bool BfResolvePassData_GetHadEmits(void* bfResolvePassData);
// //
//[CallingConvention(.Stdcall), CLink] //[CallingConvention(.Stdcall), CLink]
//static extern void* BfParser_CreateResolvePassData(void* bfSystem, int32 resolveType); //static extern void* BfParser_CreateResolvePassData(void* bfSystem, int32 resolveType);
public void* mNativeResolvePassData; public void* mNativeResolvePassData;
public bool HadEmits => BfResolvePassData_GetHadEmits(mNativeResolvePassData);
public ~this() public ~this()
{ {

View file

@ -13,9 +13,16 @@ namespace IDE.Compiler
{ {
public abstract class CompilerBase : CommandQueueManager public abstract class CompilerBase : CommandQueueManager
{ {
public enum ViewRefreshKind
{
None,
Collapse,
FullRefresh
}
public int32 mResolveAllWait; public int32 mResolveAllWait;
protected List<String> mQueuedOutput = new List<String>() ~ DeleteContainerAndItems!(_); protected List<String> mQueuedOutput = new List<String>() ~ DeleteContainerAndItems!(_);
public bool mWantsActiveViewRefresh; public ViewRefreshKind mWantsActiveViewRefresh;
public volatile int32 mThreadYieldCount = 0; // Whether our thread wants to be yielded to, and for how many ticks public volatile int32 mThreadYieldCount = 0; // Whether our thread wants to be yielded to, and for how many ticks
@ -157,10 +164,10 @@ namespace IDE.Compiler
{ {
CheckThreadDone(); CheckThreadDone();
if (mWantsActiveViewRefresh) if (mWantsActiveViewRefresh != .None)
{ {
IDEApp.sApp.RefreshVisibleViews(); IDEApp.sApp.RefreshVisibleViews();
mWantsActiveViewRefresh = false; mWantsActiveViewRefresh = .None;
} }
if (mThreadYieldCount > 0) if (mThreadYieldCount > 0)

View file

@ -1372,12 +1372,17 @@ namespace IDE
return activePanel as TextPanel; return activePanel as TextPanel;
} }
public void RefreshVisibleViews(SourceViewPanel excludeSourceViewPanel = null) public void RefreshVisibleViews(SourceViewPanel excludeSourceViewPanel = null, CompilerBase.ViewRefreshKind viewRefreshKind = .FullRefresh)
{ {
WithSourceViewPanels(scope (sourceViewPanel) => WithSourceViewPanels(scope (sourceViewPanel) =>
{ {
if ((sourceViewPanel.mParent != null) && (sourceViewPanel != excludeSourceViewPanel)) if ((sourceViewPanel.mParent != null) && (sourceViewPanel != excludeSourceViewPanel))
{
if (viewRefreshKind ==.Collapse)
sourceViewPanel.QueueFullRefresh(true); sourceViewPanel.QueueFullRefresh(true);
else
sourceViewPanel.QueueCollapseRefresh();
}
}); });
} }
@ -9459,7 +9464,7 @@ namespace IDE
} }
mBfResolveCompiler.QueueDeferredResolveAll(); mBfResolveCompiler.QueueDeferredResolveAll();
mBfResolveCompiler.QueueRefreshViewCommand(); mBfResolveCompiler.QueueRefreshViewCommand(.FullRefresh);
return; return;
} }

View file

@ -203,7 +203,7 @@ namespace IDE.ui
public SourceViewPanel mSourceViewPanel; public SourceViewPanel mSourceViewPanel;
public DarkComboBox mGenericTypeCombo; public DarkComboBox mGenericTypeCombo;
public DarkComboBox mGenericMethodCombo; public DarkComboBox mGenericMethodCombo;
public String mGenericTypeFilter; public String mGenericTypeFilter ~ delete _;
public float mWantHeight; public float mWantHeight;
public float? mMouseDownY; public float? mMouseDownY;
public float? mDownWantHeight; public float? mDownWantHeight;
@ -268,14 +268,15 @@ namespace IDE.ui
if (mIgnoreChange) if (mIgnoreChange)
return; return;
var editWidget = (EditWidget)theEvent.mSender; if (mGenericTypeFilter == null)
var searchText = scope String(); mGenericTypeFilter = new .();
editWidget.GetText(searchText); else
searchText.Trim(); mGenericTypeFilter.Clear();
mGenericTypeFilter = searchText; var editWidget = (EditWidget)theEvent.mSender;
editWidget.GetText(mGenericTypeFilter);
mGenericTypeFilter.Trim();
mGenericTypeCombo.ShowDropdown(); mGenericTypeCombo.ShowDropdown();
mGenericTypeFilter = null;
} }
void EditKeyDownHandler(KeyDownEvent evt) void EditKeyDownHandler(KeyDownEvent evt)
@ -293,6 +294,7 @@ namespace IDE.ui
typeName = explicitTypeName; typeName = explicitTypeName;
} }
DeleteAndNullify!(mGenericTypeFilter);
mIgnoreChange = true; mIgnoreChange = true;
int colonPos = typeName.IndexOf(':'); int colonPos = typeName.IndexOf(':');
if (colonPos != -1) if (colonPos != -1)
@ -305,7 +307,7 @@ namespace IDE.ui
void PopulateTypeData(Menu menu) void PopulateTypeData(Menu menu)
{ {
List<StringView> findStrs = null; List<StringView> findStrs = null;
if (mGenericTypeFilter != null) if ((mGenericTypeFilter != null) && (!mGenericTypeFilter.IsWhiteSpace))
findStrs = scope:: List<StringView>(mGenericTypeFilter.Split(' ')); findStrs = scope:: List<StringView>(mGenericTypeFilter.Split(' '));
using (mMonitor.Enter()) using (mMonitor.Enter())
@ -561,6 +563,7 @@ namespace IDE.ui
case Type = 'T'; case Type = 'T';
case UsingNamespaces = 'U'; case UsingNamespaces = 'U';
case Unknown = '?'; case Unknown = '?';
case HasUncertainEmits = '~';
case Emit = 'e'; case Emit = 'e';
case EmitAddType = '+'; case EmitAddType = '+';
@ -597,6 +600,9 @@ namespace IDE.ui
public int32 mAnchorIdx; public int32 mAnchorIdx;
public int32 mStartLine; public int32 mStartLine;
public int32 mEndLine; public int32 mEndLine;
public bool mOnlyInResolveAll;
public bool mIncludedInClassify;
public bool mIncludedInResolveAll;
public int32 mAnchorId; public int32 mAnchorId;
} }
@ -613,7 +619,18 @@ namespace IDE.ui
public void Clear() public void Clear()
{ {
ClearCollapse();
ClearEmit();
}
public void ClearCollapse()
{
mCollapseData.Clear(); mCollapseData.Clear();
}
public void ClearEmit()
{
mEmitData.Clear(); mEmitData.Clear();
ClearAndDeleteItems(mTypeNames); ClearAndDeleteItems(mTypeNames);
} }
@ -6264,22 +6281,76 @@ namespace IDE.ui
RehupLineCoords(); RehupLineCoords();
} }
public void ParseCollapseRegions(String collapseText, int32 textVersion, ref IdSpan idSpan) public void ParseCollapseRegions(String collapseText, int32 textVersion, ref IdSpan idSpan, ResolveType resolveType)
{ {
/*if (resolveType == .None)
return;*/
IdSpan.LookupContext lookupCtx = scope .(idSpan); IdSpan.LookupContext lookupCtx = scope .(idSpan);
var data = PreparedData; var data = PreparedData;
data.Clear(); if (resolveType != .None)
{
data.ClearCollapse();
}
List<int32> typeNameIdxMap = scope .();
Dictionary<StringView, int32> typeNameMap = scope .();
Dictionary<int32, int32> emitAnchorIds = scope .();
bool hasUncertainEmits = false;
bool emitInitialized = false;
void CheckInitEmit()
{
if (emitInitialized)
return;
emitInitialized = true;
if ((hasUncertainEmits) || (resolveType == .None))
{
// Leave emits alone
for (var typeName in data.mTypeNames)
typeNameMap[typeName] = (.)@typeName.Index;
for (var emitData in ref data.mEmitData)
{
emitAnchorIds[emitData.mAnchorId] = (.)@emitData.Index;
if (resolveType == .None)
emitData.mIncludedInResolveAll = false;
else
emitData.mIncludedInClassify = false;
}
return;
}
hasUncertainEmits = false;
data.ClearEmit();
}
for (var line in collapseText.Split('\n', .RemoveEmptyEntries)) for (var line in collapseText.Split('\n', .RemoveEmptyEntries))
{ {
SourceEditWidgetContent.CollapseEntry.Kind kind = (.)line[0]; SourceEditWidgetContent.CollapseEntry.Kind kind = (.)line[0];
line.RemoveFromStart(1); line.RemoveFromStart(1);
if (kind == .HasUncertainEmits)
{
hasUncertainEmits = true;
continue;
}
if ((kind == .EmitAddType) || (kind.IsEmit))
{
CheckInitEmit();
}
if (kind == .EmitAddType) if (kind == .EmitAddType)
{
if (typeNameMap.TryAdd(line, var keyPtr, var valuePtr))
{ {
data.mTypeNames.Add(new String(line)); data.mTypeNames.Add(new String(line));
*valuePtr = (.)data.mTypeNames.Count - 1;
}
typeNameIdxMap.Add(*valuePtr);
continue; continue;
} }
@ -6288,15 +6359,40 @@ namespace IDE.ui
{ {
EmitData emitData; EmitData emitData;
emitData.mKind = kind; emitData.mKind = kind;
emitData.mTypeNameIdx = int32.Parse(itr.GetNext().Value); int typeNameIdx = int32.Parse(itr.GetNext().Value);
emitData.mTypeNameIdx = typeNameIdxMap[typeNameIdx];
emitData.mAnchorIdx = int32.Parse(itr.GetNext().Value); emitData.mAnchorIdx = int32.Parse(itr.GetNext().Value);
emitData.mStartLine = int32.Parse(itr.GetNext().Value); emitData.mStartLine = int32.Parse(itr.GetNext().Value);
emitData.mEndLine = int32.Parse(itr.GetNext().Value); emitData.mEndLine = int32.Parse(itr.GetNext().Value);
emitData.mAnchorId = lookupCtx.GetIdAtIndex(emitData.mAnchorIdx); emitData.mAnchorId = lookupCtx.GetIdAtIndex(emitData.mAnchorIdx);
emitData.mOnlyInResolveAll = resolveType == .None;
emitData.mIncludedInClassify = resolveType != .None;
emitData.mIncludedInResolveAll = resolveType == .None;
if (emitAnchorIds.TryGetValue(emitData.mAnchorId, var idx))
{
var curEmitData = ref data.mEmitData[idx];
if (resolveType == .None)
{
curEmitData.mIncludedInResolveAll = true;
}
else
{
emitData.mIncludedInClassify |= curEmitData.mIncludedInClassify;
curEmitData = emitData;
}
continue;
}
data.mEmitData.Add(emitData); data.mEmitData.Add(emitData);
continue; continue;
} }
if (resolveType == .None)
continue;
CollapseData collapseData; CollapseData collapseData;
collapseData.mAnchorIdx = int32.Parse(itr.GetNext().Value); collapseData.mAnchorIdx = int32.Parse(itr.GetNext().Value);
@ -6322,6 +6418,23 @@ namespace IDE.ui
data.mCollapseData.Add(collapseData); data.mCollapseData.Add(collapseData);
} }
CheckInitEmit();
for (var emitData in ref data.mEmitData)
{
if (((emitData.mOnlyInResolveAll) && (!emitData.mIncludedInResolveAll)) ||
((!emitData.mOnlyInResolveAll) && (!emitData.mIncludedInClassify)))
{
@emitData.RemoveFast();
continue;
}
if ((emitData.mOnlyInResolveAll) && (!emitData.mIncludedInClassify))
{
gApp.mBfResolveCompiler.mWantsResolveAllCollapseRefresh = true;
}
}
data.mCollapseParseRevision++; data.mCollapseParseRevision++;
data.mCollapseTextVersionId = textVersion; data.mCollapseTextVersionId = textVersion;
} }

View file

@ -369,6 +369,7 @@ namespace IDE.ui
public String mData = new .() ~ delete _; public String mData = new .() ~ delete _;
public int32 mTextVersion; public int32 mTextVersion;
public IdSpan mCharIdSpan ~ _.Dispose(); public IdSpan mCharIdSpan ~ _.Dispose();
public ResolveType mResolveType;
} }
class QueuedEmitShowData class QueuedEmitShowData
@ -424,6 +425,7 @@ namespace IDE.ui
bool mWantsFastClassify; bool mWantsFastClassify;
bool mWantsFullClassify; // This triggers a classify bool mWantsFullClassify; // This triggers a classify
bool mWantsFullRefresh; // If mWantsFullClassify is set, mWantsFullRefresh makes the whole thing refresh bool mWantsFullRefresh; // If mWantsFullClassify is set, mWantsFullRefresh makes the whole thing refresh
bool mWantsCollapseRefresh;
bool mRefireMouseOverAfterRefresh; bool mRefireMouseOverAfterRefresh;
bool mWantsBackgroundAutocomplete; bool mWantsBackgroundAutocomplete;
QueuedAutoComplete mQueuedAutoComplete ~ delete _; QueuedAutoComplete mQueuedAutoComplete ~ delete _;
@ -636,7 +638,6 @@ namespace IDE.ui
AddWidget(mNavigationBar); AddWidget(mNavigationBar);
} }
} }
public ~this() public ~this()
{ {
if (mInPostRemoveUpdatePanels) if (mInPostRemoveUpdatePanels)
@ -889,6 +890,11 @@ namespace IDE.ui
//mDidClangSource = false; //mDidClangSource = false;
} }
public void QueueCollapseRefresh()
{
mWantsCollapseRefresh = true;
}
public override bool EscapeHandler() public override bool EscapeHandler()
{ {
if (IDEApp.sApp.mSymbolReferenceHelper != null) if (IDEApp.sApp.mSymbolReferenceHelper != null)
@ -1174,7 +1180,7 @@ namespace IDE.ui
useResolveType = ResolveType.Autocomplete; useResolveType = ResolveType.Autocomplete;
} }
bool doBackground = (useResolveType == ResolveType.Classify) || (useResolveType == ResolveType.ClassifyFullRefresh); bool doBackground = (useResolveType == .Classify) || (useResolveType == .ClassifyFullRefresh);
if (mAsyncAutocomplete) if (mAsyncAutocomplete)
{ {
if ((useResolveType == .Autocomplete) || (useResolveType == .GetCurrentLocation) || (useResolveType == .GetSymbolInfo) || if ((useResolveType == .Autocomplete) || (useResolveType == .GetCurrentLocation) || (useResolveType == .GetSymbolInfo) ||
@ -1438,6 +1444,31 @@ namespace IDE.ui
bfSystem.Unlock(); bfSystem.Unlock();
} }
public void DoRefreshCollapse(BfParser parser, int32 textVersion, IdSpan charIdSpan)
{
var bfCompiler = BfResolveCompiler;
String explicitEmitTypeNames = scope .();
for (var explicitType in mExplicitEmitTypes)
{
explicitEmitTypeNames.Append(explicitType);
explicitEmitTypeNames.Append("\n");
}
var resolvePassData = parser.CreateResolvePassData(.None);
defer delete resolvePassData;
var collapseData = bfCompiler.GetCollapseRegions(parser, resolvePassData, explicitEmitTypeNames, .. scope .());
using (mMonitor.Enter())
{
DeleteAndNullify!(mQueuedCollapseData);
mQueuedCollapseData = new .();
mQueuedCollapseData.mData.Set(collapseData);
mQueuedCollapseData.mTextVersion = textVersion;
mQueuedCollapseData.mCharIdSpan = charIdSpan;
}
}
public void DoFullClassify(ResolveParams resolveParams) public void DoFullClassify(ResolveParams resolveParams)
{ {
var bfCompiler = BfResolveCompiler; var bfCompiler = BfResolveCompiler;
@ -1457,7 +1488,7 @@ namespace IDE.ui
public void DoFastClassify() public void DoFastClassify()
{ {
if (!mIsSourceCode) if ((!mIsSourceCode) || (mEmbedKind != .None))
return; return;
//Debug.WriteLine("DoFastClassify"); //Debug.WriteLine("DoFastClassify");
@ -1911,7 +1942,8 @@ namespace IDE.ui
var bfCompiler = BfResolveCompiler; var bfCompiler = BfResolveCompiler;
//var compiler = ResolveCompiler; //var compiler = ResolveCompiler;
bool isBackground = (resolveType == .Classify) || (resolveType == .ClassifyFullRefresh) || (resolveType == .GetResultString) || (resolveType == .GoToDefinition); bool isBackground = (resolveType == .Classify) || (resolveType == .ClassifyFullRefresh) ||
(resolveType == .GetResultString) || (resolveType == .GoToDefinition);
bool fullRefresh = resolveType == ResolveType.ClassifyFullRefresh; bool fullRefresh = resolveType == ResolveType.ClassifyFullRefresh;
if (!isBackground) if (!isBackground)
@ -2142,11 +2174,6 @@ namespace IDE.ui
{ {
parser.CreateClassifier(passInstance, resolvePassData, charData); parser.CreateClassifier(passInstance, resolvePassData, charData);
if (resolveType == .ClassifyFullRefresh)
{
NOP!();
}
if (resolveParams != null) if (resolveParams != null)
{ {
for (var emitEmbedData in resolveParams.mEmitEmbeds) for (var emitEmbedData in resolveParams.mEmitEmbeds)
@ -2157,7 +2184,7 @@ namespace IDE.ui
if (bfCompiler.ClassifySource(passInstance, resolvePassData)) if (bfCompiler.ClassifySource(passInstance, resolvePassData))
{ {
if ((resolveType == ResolveType.Classify) || (resolveType == ResolveType.ClassifyFullRefresh)) if ((resolveType == .Classify) || (resolveType == .ClassifyFullRefresh))
{ {
String explicitEmitTypeNames = scope .(); String explicitEmitTypeNames = scope .();
for (var explicitType in mExplicitEmitTypes) for (var explicitType in mExplicitEmitTypes)
@ -2166,6 +2193,9 @@ namespace IDE.ui
explicitEmitTypeNames.Append("\n"); explicitEmitTypeNames.Append("\n");
} }
bool allowCollapseData = resolveType == .ClassifyFullRefresh;
if (allowCollapseData)
{
var collapseData = bfCompiler.GetCollapseRegions(parser, resolvePassData, explicitEmitTypeNames, .. scope .()); var collapseData = bfCompiler.GetCollapseRegions(parser, resolvePassData, explicitEmitTypeNames, .. scope .());
using (mMonitor.Enter()) using (mMonitor.Enter())
{ {
@ -2174,6 +2204,12 @@ namespace IDE.ui
mQueuedCollapseData.mData.Set(collapseData); mQueuedCollapseData.mData.Set(collapseData);
mQueuedCollapseData.mTextVersion = resolveParams.mTextVersion; mQueuedCollapseData.mTextVersion = resolveParams.mTextVersion;
mQueuedCollapseData.mCharIdSpan = resolveParams.mCharIdSpan.Duplicate(); mQueuedCollapseData.mCharIdSpan = resolveParams.mCharIdSpan.Duplicate();
mQueuedCollapseData.mResolveType = resolveType;
}
}
else
{
QueueFullRefresh(false);
} }
} }
@ -6446,9 +6482,37 @@ namespace IDE.ui
{ {
mWantsFullClassify = false; mWantsFullClassify = false;
mWantsFullRefresh = false; mWantsFullRefresh = false;
mWantsCollapseRefresh = false;
} }
canDoBackground = false; canDoBackground = false;
} }
}
else if (mWantsCollapseRefresh)
{
if (!compiler.IsPerformingBackgroundOperation())
{
bfSystem?.Log("SourceViewPanel handling mWantsCollapseRefresh");
mWantsCollapseRefresh = false;
/*Classify(.GetCollapse);*/
if ((projectSource != null) && (mIsBeefSource))
do
{
var bfProject = bfSystem.GetBfProject(projectSource.mProject);
if (bfProject.mDisabled)
break;
var bfParser = bfSystem.FindParser(projectSource);
if (bfParser == null)
break;
var data = mEditWidget.mEditWidgetContent.mData;
compiler.DoBackground(new () =>
{
DoRefreshCollapse(bfParser, data.mCurTextVersionId, data.mTextIdData.Duplicate());
});
}
}
} }
else if (mWantsParserCleanup) else if (mWantsParserCleanup)
{ {
@ -6734,7 +6798,7 @@ namespace IDE.ui
using (mMonitor.Enter()) using (mMonitor.Enter())
{ {
if (mQueuedCollapseData != null) if (mQueuedCollapseData != null)
ewc.ParseCollapseRegions(mQueuedCollapseData.mData, mQueuedCollapseData.mTextVersion, ref mQueuedCollapseData.mCharIdSpan); ewc.ParseCollapseRegions(mQueuedCollapseData.mData, mQueuedCollapseData.mTextVersion, ref mQueuedCollapseData.mCharIdSpan, mQueuedCollapseData.mResolveType);
DeleteAndNullify!(mQueuedCollapseData); DeleteAndNullify!(mQueuedCollapseData);
} }
@ -6967,7 +7031,7 @@ namespace IDE.ui
} }
else else
{ {
mNavigationBar.mVisible = false; mNavigationBar?.mVisible = false;
} }
// Always leave enough to read the first 3 lines // Always leave enough to read the first 3 lines

View file

@ -7200,8 +7200,6 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
bool didWork = false; bool didWork = false;
UpdateDependencyMap(mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_ResolveUnused, didWork); UpdateDependencyMap(mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_ResolveUnused, didWork);
if (mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_AlwaysInclude)
{
// If UpdateDependencyMap caused methods to be reified, then we need to run PopulateReified again- // If UpdateDependencyMap caused methods to be reified, then we need to run PopulateReified again-
// because those methods may be virtual and we need to reify overrides (for example). // because those methods may be virtual and we need to reify overrides (for example).
// We use the DoWorkLoop result to determine if there were actually any changes from UpdateDependencyMap // We use the DoWorkLoop result to determine if there were actually any changes from UpdateDependencyMap
@ -7210,7 +7208,6 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
PopulateReified(); PopulateReified();
} }
} }
}
if (!mContext->mHasReifiedQueuedRebuildTypes) if (!mContext->mHasReifiedQueuedRebuildTypes)
break; break;
@ -9814,6 +9811,8 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
}; };
Dictionary<BfTypeDef*, Dictionary<int, _EmitSource>> emitLocMap; Dictionary<BfTypeDef*, Dictionary<int, _EmitSource>> emitLocMap;
bool mayHaveMissedEmits = false;
for (auto type : bfCompiler->mContext->mResolvedTypes) for (auto type : bfCompiler->mContext->mResolvedTypes)
{ {
auto typeInst = type->ToTypeInstance(); auto typeInst = type->ToTypeInstance();
@ -9825,6 +9824,12 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
if (typeInst->mCeTypeInfo == NULL) if (typeInst->mCeTypeInfo == NULL)
continue; continue;
if ((typeInst->mCeTypeInfo->mMayHaveUniqueEmitLocations) && (!mayHaveMissedEmits))
{
outString += "~\n";
mayHaveMissedEmits = true;
}
for (auto& kv : typeInst->mCeTypeInfo->mEmitSourceMap) for (auto& kv : typeInst->mCeTypeInfo->mEmitSourceMap)
{ {
int partialIdx = (int)(kv.mKey >> 32); int partialIdx = (int)(kv.mKey >> 32);

View file

@ -2091,6 +2091,9 @@ void BfModule::SetTypeOptions(BfTypeInstance* typeInstance)
BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef* declaringType, const StringImpl& src, BfAstNode* refNode, BfCeTypeEmitSourceKind emitSourceKind) BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef* declaringType, const StringImpl& src, BfAstNode* refNode, BfCeTypeEmitSourceKind emitSourceKind)
{ {
if (mCompiler->mResolvePassData != NULL)
mCompiler->mResolvePassData->mHadEmits = true;
BfCEParseContext ceParseContext; BfCEParseContext ceParseContext;
ceParseContext.mFailIdx = mCompiler->mPassInstance->mFailedIdx; ceParseContext.mFailIdx = mCompiler->mPassInstance->mFailedIdx;
ceParseContext.mWarnIdx = mCompiler->mPassInstance->mWarnIdx; ceParseContext.mWarnIdx = mCompiler->mPassInstance->mWarnIdx;
@ -2114,10 +2117,20 @@ BfCEParseContext BfModule::CEEmitParse(BfTypeInstance* typeInstance, BfTypeDef*
} }
else else
{ {
ceTypeInfo->mEmitSourceMap.TryAdd(emitSourceMapKey, NULL, &ceEmitSource); if (ceTypeInfo->mEmitSourceMap.TryAdd(emitSourceMapKey, NULL, &ceEmitSource))
{
if (typeInstance->IsSpecializedType())
{
auto unspecializedType = GetUnspecializedTypeInstance(typeInstance);
if ((unspecializedType->mCeTypeInfo == NULL) || (!unspecializedType->mCeTypeInfo->mEmitSourceMap.ContainsKey(emitSourceMapKey)))
ceTypeInfo->mMayHaveUniqueEmitLocations = true;
}
}
ceEmitSource->mKind = emitSourceKind; ceEmitSource->mKind = emitSourceKind;
} }
BfLogSysM("CEEmitParse type %p ceTypeInfo %p\n", typeInstance, ceTypeInfo);
int emitSrcStart = 0; int emitSrcStart = 0;
BfEmitEmbedEntry* emitEmbedEntry = NULL; BfEmitEmbedEntry* emitEmbedEntry = NULL;
@ -4748,6 +4761,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
{ {
if (typeInstance->mCeTypeInfo->mNext != NULL) if (typeInstance->mCeTypeInfo->mNext != NULL)
{ {
BfLogSysM("Type %p injecting next ceTypeInfo %p into ceTypeInfo %p\n", typeInstance, typeInstance->mCeTypeInfo->mNext, typeInstance->mCeTypeInfo);
auto ceInfo = typeInstance->mCeTypeInfo->mNext; auto ceInfo = typeInstance->mCeTypeInfo->mNext;
HashContext hashCtx; HashContext hashCtx;
@ -5825,6 +5840,36 @@ void BfModule::DoTypeInstanceMethodProcessing(BfTypeInstance* typeInstance)
if (TypeIsSubTypeOf(typeInstance, mCompiler->mAttributeTypeDef)) if (TypeIsSubTypeOf(typeInstance, mCompiler->mAttributeTypeDef))
wantsOnDemandMethods = false; wantsOnDemandMethods = false;
if ((mCompiler->mResolvePassData != NULL) && (!mCompiler->mResolvePassData->mEmitEmbedEntries.IsEmpty()) && (typeInstance->IsSpecializedType()))
{
bool isCurrentEntry = false;
auto _CheckEntry = [&](BfTypeDef* typeDef)
{
auto parser = typeDef->mTypeDeclaration->GetParser();
if (parser != NULL)
if (mCompiler->mResolvePassData->GetSourceClassifier(parser) != NULL)
isCurrentEntry = true;
};
_CheckEntry(typeInstance->mTypeDef);
for (auto& partial : typeInstance->mTypeDef->mPartials)
_CheckEntry(partial);
if (isCurrentEntry)
{
String typeName;
typeName += typeInstance->mTypeDef->mProject->mName;
typeName += ":";
typeName += TypeToString(typeInstance, BfTypeNameFlags_None);
if (mCompiler->mResolvePassData->mEmitEmbedEntries.ContainsKey(typeName))
{
wantsOnDemandMethods = false;
}
}
}
//bool allDeclsRequired = (mIsReified) && (mCompiler->mOptions.mEmitDebugInfo) && (); //bool allDeclsRequired = (mIsReified) && (mCompiler->mOptions.mEmitDebugInfo) && ();
bool allDeclsRequired = false; bool allDeclsRequired = false;
//if ((mIsReified) && (mCompiler->mOptions.mEmitDebugInfo) && (!mCompiler->mWantsDeferMethodDecls)) //if ((mIsReified) && (mCompiler->mOptions.mEmitDebugInfo) && (!mCompiler->mWantsDeferMethodDecls))
@ -10210,9 +10255,9 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
auto directStrTypeRef = BfNodeDynCastExact<BfDirectStrTypeReference>(typeRef); auto directStrTypeRef = BfNodeDynCastExact<BfDirectStrTypeReference>(typeRef);
if (((namedTypeRef != NULL) && (namedTypeRef->mNameNode != NULL)) || (directStrTypeRef != NULL)) if (((namedTypeRef != NULL) && (namedTypeRef->mNameNode != NULL)) || (directStrTypeRef != NULL))
{ {
StringT<128> findName; StringView findName;
if (namedTypeRef != NULL) if (namedTypeRef != NULL)
namedTypeRef->mNameNode->ToString(findName); findName = namedTypeRef->mNameNode->ToStringView();
else else
findName = directStrTypeRef->mTypeName; findName = directStrTypeRef->mTypeName;
if (findName == "Self") if (findName == "Self")

View file

@ -21,6 +21,7 @@ BfResolvePassData::BfResolvePassData()
mResolveType = BfResolveType_None; mResolveType = BfResolveType_None;
mIsClassifying = false; mIsClassifying = false;
mHasCursorIdx = false; mHasCursorIdx = false;
mHadEmits = false;
} }
BfResolvePassData::~BfResolvePassData() BfResolvePassData::~BfResolvePassData()

View file

@ -83,6 +83,7 @@ public:
int mSymbolTypeGenericParamIdx; int mSymbolTypeGenericParamIdx;
bool mIsClassifying; bool mIsClassifying;
bool mHasCursorIdx; bool mHasCursorIdx;
bool mHadEmits;
typedef Dictionary<BfParserData*, String> FoundSymbolReferencesParserDataMap; typedef Dictionary<BfParserData*, String> FoundSymbolReferencesParserDataMap;
FoundSymbolReferencesParserDataMap mFoundSymbolReferencesParserData; FoundSymbolReferencesParserDataMap mFoundSymbolReferencesParserData;

View file

@ -1766,11 +1766,6 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
_CheckConst(); _CheckConst();
if (isStatic)
{
NOP;
}
if ((initValue.mKind == BfTypedValueKind_TempAddr) && (!initHandled)) if ((initValue.mKind == BfTypedValueKind_TempAddr) && (!initHandled))
{ {
BF_ASSERT(initValue.IsAddr()); BF_ASSERT(initValue.IsAddr());

View file

@ -4013,6 +4013,11 @@ BF_EXPORT void* BfResolvePassData_GetEmitEmbedData(BfResolvePassData* resolvePas
return emitEmbedEntry->mParser->mSourceClassifier->mCharData; return emitEmbedEntry->mParser->mSourceClassifier->mCharData;
} }
BF_EXPORT bool BfResolvePassData_GetHadEmits(BfResolvePassData* resolvePassData)
{
return resolvePassData->mHadEmits;
}
BF_EXPORT BfParser* BF_CALLTYPE BfSystem_CreateParser(BfSystem* bfSystem, BfProject* bfProject) BF_EXPORT BfParser* BF_CALLTYPE BfSystem_CreateParser(BfSystem* bfSystem, BfProject* bfProject)
{ {
return bfSystem->CreateParser(bfProject); return bfSystem->CreateParser(bfProject);

View file

@ -3287,10 +3287,6 @@ void CeBuilder::Build()
if (mCeFunction->mGenError.IsEmpty()) if (mCeFunction->mGenError.IsEmpty())
mCeFunction->mFailed = false; mCeFunction->mFailed = false;
else
{
NOP;
}
mCeFunction->mFrameSize = mFrameSize; mCeFunction->mFrameSize = mFrameSize;
} }

View file

@ -1012,12 +1012,14 @@ public:
Dictionary<CeRebuildKey, CeRebuildValue> mRebuildMap; Dictionary<CeRebuildKey, CeRebuildValue> mRebuildMap;
Val128 mHash; Val128 mHash;
bool mFailed; bool mFailed;
bool mMayHaveUniqueEmitLocations;
BfCeTypeInfo* mNext; BfCeTypeInfo* mNext;
public: public:
BfCeTypeInfo() BfCeTypeInfo()
{ {
mFailed = false; mFailed = false;
mMayHaveUniqueEmitLocations = false;
mNext = NULL; mNext = NULL;
} }
}; };