mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed Emit marker in generic types where unspecialized has no emission
This commit is contained in:
parent
1abccdedf8
commit
7ddec857f6
6 changed files with 179 additions and 77 deletions
|
@ -825,6 +825,10 @@ namespace Beefy.theme.dark
|
||||||
base.PhysCursorMoved(moveKind);
|
base.PhysCursorMoved(moveKind);
|
||||||
|
|
||||||
if (mLineRange != null)
|
if (mLineRange != null)
|
||||||
|
{
|
||||||
|
if (mLineRange.Value.Length == 0)
|
||||||
|
CursorLineAndColumn = .(0, 0);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
var lineAndColumn = CursorLineAndColumn;
|
var lineAndColumn = CursorLineAndColumn;
|
||||||
if (lineAndColumn.mLine < mLineRange.Value.Start)
|
if (lineAndColumn.mLine < mLineRange.Value.Start)
|
||||||
|
@ -833,6 +837,7 @@ namespace Beefy.theme.dark
|
||||||
CursorLineAndColumn = .(mLineRange.Value.End - 1, lineAndColumn.mColumn);
|
CursorLineAndColumn = .(mLineRange.Value.End - 1, lineAndColumn.mColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool GetLineCharAtCoord(float x, float y, out int line, out int lineChar, out float overflowX)
|
public override bool GetLineCharAtCoord(float x, float y, out int line, out int lineChar, out float overflowX)
|
||||||
{
|
{
|
||||||
|
|
|
@ -229,7 +229,6 @@ namespace IDE.ui
|
||||||
|
|
||||||
mSourceViewPanel.Show(emitPath, false, null);
|
mSourceViewPanel.Show(emitPath, false, null);
|
||||||
mSourceViewPanel.mEditWidget.mEditWidgetContent.mIsReadOnly = true;
|
mSourceViewPanel.mEditWidget.mEditWidgetContent.mIsReadOnly = true;
|
||||||
mSourceViewPanel.mEmitRevision = emitEmbed.mRevision;
|
|
||||||
AddWidget(mSourceViewPanel);
|
AddWidget(mSourceViewPanel);
|
||||||
|
|
||||||
mSourceViewPanel.mEditWidget.mOnGotFocus.Add(new (val1) =>
|
mSourceViewPanel.mEditWidget.mOnGotFocus.Add(new (val1) =>
|
||||||
|
@ -381,7 +380,8 @@ namespace IDE.ui
|
||||||
mAwaitingLoad = true;
|
mAwaitingLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mSourceViewPanel.mEditWidget.mEditWidgetContent.mData.mTextLength == 0)
|
var ewc = (SourceEditWidgetContent)mSourceViewPanel.mEditWidget.mEditWidgetContent;
|
||||||
|
if ((ewc.mLineRange.GetValueOrDefault().Length != 0) && (mSourceViewPanel.mEditWidget.mEditWidgetContent.mData.mTextLength == 0))
|
||||||
mAwaitingLoad = true;
|
mAwaitingLoad = true;
|
||||||
|
|
||||||
if ((mAwaitingLoad) && (gApp.mUpdateCnt % 4 == 0))
|
if ((mAwaitingLoad) && (gApp.mUpdateCnt % 4 == 0))
|
||||||
|
@ -499,8 +499,6 @@ namespace IDE.ui
|
||||||
public float mOpenPct;
|
public float mOpenPct;
|
||||||
public int32 mAnchorId;
|
public int32 mAnchorId;
|
||||||
public int32 mCollapseIndex;
|
public int32 mCollapseIndex;
|
||||||
public int32 mRevision;
|
|
||||||
public int32 mPartialIdx;
|
|
||||||
public int32 mStartLine;
|
public int32 mStartLine;
|
||||||
public int32 mEndLine;
|
public int32 mEndLine;
|
||||||
public View mView;
|
public View mView;
|
||||||
|
@ -563,11 +561,10 @@ namespace IDE.ui
|
||||||
case Type = 'T';
|
case Type = 'T';
|
||||||
case UsingNamespaces = 'U';
|
case UsingNamespaces = 'U';
|
||||||
case Unknown = '?';
|
case Unknown = '?';
|
||||||
case EmitInType = 't';
|
case Emit = 'e';
|
||||||
case EmitInMethod = 'm';
|
|
||||||
case EmitAddType = '+';
|
case EmitAddType = '+';
|
||||||
|
|
||||||
public bool IsEmit => (this == .EmitInType) || (this == .EmitInMethod);
|
public bool IsEmit => (this == .Emit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Kind mKind;
|
public Kind mKind;
|
||||||
|
@ -597,8 +594,6 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
public SourceEditWidgetContent.CollapseEntry.Kind mKind;
|
public SourceEditWidgetContent.CollapseEntry.Kind mKind;
|
||||||
public int32 mTypeNameIdx;
|
public int32 mTypeNameIdx;
|
||||||
public int32 mRevision;
|
|
||||||
public int32 mPartialIdx;
|
|
||||||
public int32 mAnchorIdx;
|
public int32 mAnchorIdx;
|
||||||
public int32 mStartLine;
|
public int32 mStartLine;
|
||||||
public int32 mEndLine;
|
public int32 mEndLine;
|
||||||
|
@ -5706,8 +5701,6 @@ namespace IDE.ui
|
||||||
emitEmbed.mAnchorId = emitData.mAnchorId;
|
emitEmbed.mAnchorId = emitData.mAnchorId;
|
||||||
emitEmbed.mEmitKind = emitData.mKind;
|
emitEmbed.mEmitKind = emitData.mKind;
|
||||||
emitEmbed.mTypeName = mCollapseTypeNames[emitData.mTypeNameIdx];
|
emitEmbed.mTypeName = mCollapseTypeNames[emitData.mTypeNameIdx];
|
||||||
emitEmbed.mRevision = emitData.mRevision;
|
|
||||||
emitEmbed.mPartialIdx = emitData.mPartialIdx;
|
|
||||||
|
|
||||||
if (emitEmbed.mView != null)
|
if (emitEmbed.mView != null)
|
||||||
{
|
{
|
||||||
|
@ -6296,8 +6289,6 @@ namespace IDE.ui
|
||||||
EmitData emitData;
|
EmitData emitData;
|
||||||
emitData.mKind = kind;
|
emitData.mKind = kind;
|
||||||
emitData.mTypeNameIdx = int32.Parse(itr.GetNext().Value);
|
emitData.mTypeNameIdx = int32.Parse(itr.GetNext().Value);
|
||||||
emitData.mRevision = int32.Parse(itr.GetNext().Value);
|
|
||||||
emitData.mPartialIdx = int32.Parse(itr.GetNext().Value);
|
|
||||||
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);
|
||||||
|
|
|
@ -2182,15 +2182,15 @@ namespace IDE.ui
|
||||||
for (var emitEmbedData in resolveParams.mEmitEmbeds)
|
for (var emitEmbedData in resolveParams.mEmitEmbeds)
|
||||||
{
|
{
|
||||||
var data = resolvePassData.GetEmitEmbedData(emitEmbedData.mTypeName, var srcLength, var revision);
|
var data = resolvePassData.GetEmitEmbedData(emitEmbedData.mTypeName, var srcLength, var revision);
|
||||||
if (srcLength > 0)
|
if (srcLength < 0)
|
||||||
{
|
srcLength = 0;
|
||||||
|
|
||||||
emitEmbedData.mCharData = new EditWidgetContent.CharData[srcLength+1] (?);
|
emitEmbedData.mCharData = new EditWidgetContent.CharData[srcLength+1] (?);
|
||||||
emitEmbedData.mCharData[srcLength] = default;
|
emitEmbedData.mCharData[srcLength] = default;
|
||||||
Internal.MemCpy(emitEmbedData.mCharData.Ptr, data, srcLength * strideof(EditWidgetContent.CharData));
|
Internal.MemCpy(emitEmbedData.mCharData.Ptr, data, srcLength * strideof(EditWidgetContent.CharData));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//DeleteAndNullify!(mProcessResolveCharData);
|
//DeleteAndNullify!(mProcessResolveCharData);
|
||||||
|
|
|
@ -9759,8 +9759,54 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
||||||
SetAndRestoreValue<BfResolvePassData*> prevCompilerResolvePassData(bfCompiler->mResolvePassData, resolvePassData);
|
SetAndRestoreValue<BfResolvePassData*> prevCompilerResolvePassData(bfCompiler->mResolvePassData, resolvePassData);
|
||||||
SetAndRestoreValue<BfPassInstance*> prevPassInstance(bfCompiler->mPassInstance, &bfPassInstance);
|
SetAndRestoreValue<BfPassInstance*> prevPassInstance(bfCompiler->mPassInstance, &bfPassInstance);
|
||||||
|
|
||||||
|
HashSet<BfTypeDef*> typeHashSet;
|
||||||
|
for (auto typeDef : bfParser->mTypeDefs)
|
||||||
|
typeHashSet.Add(typeDef);
|
||||||
|
|
||||||
Dictionary<int, int> foundTypeIds;
|
Dictionary<int, int> foundTypeIds;
|
||||||
|
|
||||||
|
struct _EmitSource
|
||||||
|
{
|
||||||
|
BfParser* mEmitParser;
|
||||||
|
bool mIsPrimary;
|
||||||
|
};
|
||||||
|
Dictionary<BfTypeDef*, Dictionary<int, _EmitSource>> emitLocMap;
|
||||||
|
|
||||||
|
for (auto type : bfCompiler->mContext->mResolvedTypes)
|
||||||
|
{
|
||||||
|
auto typeInst = type->ToTypeInstance();
|
||||||
|
if (typeInst == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (typeHashSet.Contains(typeInst->mTypeDef->GetLatest()))
|
||||||
|
{
|
||||||
|
if (typeInst->IsSpecializedType())
|
||||||
|
{
|
||||||
|
if (typeInst->mCeTypeInfo == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (auto& kv : typeInst->mCeTypeInfo->mEmitSourceMap)
|
||||||
|
{
|
||||||
|
int partialIdx = (int)(kv.mKey >> 32);
|
||||||
|
int charIdx = (int)(kv.mKey & 0xFFFFFFFF);
|
||||||
|
|
||||||
|
auto typeDef = typeInst->mTypeDef;
|
||||||
|
if (partialIdx > 0)
|
||||||
|
typeDef = typeDef->mPartials[partialIdx];
|
||||||
|
|
||||||
|
auto emitParser = typeInst->mTypeDef->GetLastSource()->ToParser();
|
||||||
|
|
||||||
|
Dictionary<int, _EmitSource>* map = NULL;
|
||||||
|
emitLocMap.TryAdd(typeDef->GetLatest(), NULL, &map);
|
||||||
|
_EmitSource emitSource;
|
||||||
|
emitSource.mEmitParser = emitParser;
|
||||||
|
emitSource.mIsPrimary = false;
|
||||||
|
(*map)[charIdx] = emitSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto typeDef : bfParser->mTypeDefs)
|
for (auto typeDef : bfParser->mTypeDefs)
|
||||||
{
|
{
|
||||||
auto useTypeDef = typeDef;
|
auto useTypeDef = typeDef;
|
||||||
|
@ -9771,6 +9817,34 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto _GetTypeEmbedId = [&](BfTypeInstance* typeInst, BfParser* emitParser)
|
||||||
|
{
|
||||||
|
int* keyPtr = NULL;
|
||||||
|
int* valuePtr = NULL;
|
||||||
|
if (foundTypeIds.TryAdd(typeInst->mTypeId, &keyPtr, &valuePtr))
|
||||||
|
{
|
||||||
|
*valuePtr = foundTypeIds.mCount - 1;
|
||||||
|
outString += "+";
|
||||||
|
|
||||||
|
if (emitParser == NULL)
|
||||||
|
{
|
||||||
|
String typeName;
|
||||||
|
outString += typeInst->mTypeDef->mProject->mName;
|
||||||
|
outString += ":";
|
||||||
|
outString += bfCompiler->mContext->mScratchModule->TypeToString(typeInst, BfTypeNameFlags_None);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int dollarPos = (int)emitParser->mFileName.LastIndexOf('$');
|
||||||
|
if (dollarPos == -1)
|
||||||
|
return -1;
|
||||||
|
outString += emitParser->mFileName.Substring(dollarPos + 1);
|
||||||
|
}
|
||||||
|
outString += "\n";
|
||||||
|
}
|
||||||
|
return *valuePtr;
|
||||||
|
};
|
||||||
|
|
||||||
auto type = bfCompiler->mContext->mScratchModule->ResolveTypeDef(useTypeDef);
|
auto type = bfCompiler->mContext->mScratchModule->ResolveTypeDef(useTypeDef);
|
||||||
if (type == NULL)
|
if (type == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
@ -9778,9 +9852,6 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
||||||
{
|
{
|
||||||
auto origTypeInst = typeInst;
|
auto origTypeInst = typeInst;
|
||||||
|
|
||||||
if (typeInst->mCeTypeInfo == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (auto checkIdx = explicitEmitTypes.mSize - 1; checkIdx >= 0; checkIdx--)
|
for (auto checkIdx = explicitEmitTypes.mSize - 1; checkIdx >= 0; checkIdx--)
|
||||||
{
|
{
|
||||||
auto checkType = explicitEmitTypes[checkIdx];
|
auto checkType = explicitEmitTypes[checkIdx];
|
||||||
|
@ -9792,6 +9863,8 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeInst->mCeTypeInfo != NULL)
|
||||||
|
{
|
||||||
for (auto& kv : typeInst->mCeTypeInfo->mEmitSourceMap)
|
for (auto& kv : typeInst->mCeTypeInfo->mEmitSourceMap)
|
||||||
{
|
{
|
||||||
int partialIdx = (int)(kv.mKey >> 32);
|
int partialIdx = (int)(kv.mKey >> 32);
|
||||||
|
@ -9808,10 +9881,20 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
||||||
if (!FileNameEquals(parser->mFileName, bfParser->mFileName))
|
if (!FileNameEquals(parser->mFileName, bfParser->mFileName))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
auto bfParser = typeDef->GetLastSource()->ToParser();
|
||||||
auto emitParser = typeInst->mTypeDef->GetLastSource()->ToParser();
|
auto emitParser = typeInst->mTypeDef->GetLastSource()->ToParser();
|
||||||
if (emitParser == NULL)
|
if (emitParser == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Dictionary<int, _EmitSource>* map = NULL;
|
||||||
|
if (emitLocMap.TryGetValue(typeDef, &map))
|
||||||
|
{
|
||||||
|
_EmitSource emitSource;
|
||||||
|
emitSource.mEmitParser = emitParser;
|
||||||
|
emitSource.mIsPrimary = true;
|
||||||
|
(*map)[charIdx] = emitSource;
|
||||||
|
}
|
||||||
|
|
||||||
int startLine = 0;
|
int startLine = 0;
|
||||||
int startLineChar = 0;
|
int startLineChar = 0;
|
||||||
emitParser->GetLineCharAtIdx(kv.mValue.mSrcStart, startLine, startLineChar);
|
emitParser->GetLineCharAtIdx(kv.mValue.mSrcStart, startLine, startLineChar);
|
||||||
|
@ -9825,26 +9908,50 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetCollapseRegions(BfCompiler* bfCo
|
||||||
srcEnd--;
|
srcEnd--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int embedId = _GetTypeEmbedId(typeInst, emitParser);
|
||||||
|
if (embedId == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
int endLine = 0;
|
int endLine = 0;
|
||||||
int endLineChar = 0;
|
int endLineChar = 0;
|
||||||
emitParser->GetLineCharAtIdx(srcEnd, endLine, endLineChar);
|
emitParser->GetLineCharAtIdx(srcEnd, endLine, endLineChar);
|
||||||
|
outString += StrFormat("e%d,%d,%d,%d\n", embedId, charIdx, startLine, endLine + 1);
|
||||||
int dollarPos = (int)emitParser->mFileName.LastIndexOf('$');
|
}
|
||||||
if (dollarPos == -1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int* keyPtr = NULL;
|
|
||||||
int* valuePtr = NULL;
|
|
||||||
if (foundTypeIds.TryAdd(typeInst->mTypeId, &keyPtr, &valuePtr))
|
|
||||||
{
|
|
||||||
*valuePtr = foundTypeIds.mCount - 1;
|
|
||||||
outString += "+";
|
|
||||||
outString += emitParser->mFileName.Substring(dollarPos + 1);
|
|
||||||
outString += "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
outString += (kv.mValue.mKind == BfCeTypeEmitSourceKind_Method) ? 'm' : 't';
|
if (typeInst->IsGenericTypeInstance())
|
||||||
outString += StrFormat("%d,%d,%d,%d,%d,%d\n", *valuePtr, typeInst->mRevision, partialIdx, charIdx, startLine, endLine + 1);
|
{
|
||||||
|
String emitName;
|
||||||
|
|
||||||
|
auto _CheckTypeDef = [&](BfTypeDef* typeDef)
|
||||||
|
{
|
||||||
|
auto parser = typeDef->GetDefinition()->GetLastSource()->ToParser();
|
||||||
|
if (parser == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!FileNameEquals(parser->mFileName, bfParser->mFileName))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Dictionary<int, _EmitSource>* map = NULL;
|
||||||
|
if (emitLocMap.TryGetValue(typeDef, &map))
|
||||||
|
{
|
||||||
|
for (auto kv : *map)
|
||||||
|
{
|
||||||
|
if (kv.mValue.mIsPrimary)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int embedId = _GetTypeEmbedId(typeInst, NULL);
|
||||||
|
if (embedId == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
outString += StrFormat("e%d,%d,%d,%d\n", embedId, kv.mKey, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_CheckTypeDef(typeInst->mTypeDef);
|
||||||
|
for (auto partialTypeDef : typeInst->mTypeDef->mPartials)
|
||||||
|
_CheckTypeDef(partialTypeDef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5869,8 +5869,7 @@ void BfExprEvaluator::ResolveArgValues(BfResolvedArgs& resolvedArgs, BfResolveAr
|
||||||
auto argValue = exprEvaluator.mResult;
|
auto argValue = exprEvaluator.mResult;
|
||||||
if (argValue)
|
if (argValue)
|
||||||
{
|
{
|
||||||
//resolvedArg.mResolvedType = mModule->ResolveGenericType(argValue.mType);
|
mModule->mBfIRBuilder->PopulateType(argValue.mType);
|
||||||
|
|
||||||
resolvedArg.mResolvedType = argValue.mType;
|
resolvedArg.mResolvedType = argValue.mType;
|
||||||
if (resolvedArg.mResolvedType->IsRef())
|
if (resolvedArg.mResolvedType->IsRef())
|
||||||
argValue.mKind = BfTypedValueKind_Value;
|
argValue.mKind = BfTypedValueKind_Value;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue