1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-17 15:46:05 +02:00

Show comptime emits as embedded sourceviews

This commit is contained in:
Brian Fiete 2022-04-16 06:27:54 -07:00
parent ee27f6fd02
commit 4d1e14a1c3
65 changed files with 3360 additions and 633 deletions

View file

@ -58,10 +58,10 @@ namespace IDE.Compiler
static extern bool BfCompiler_VerifyTypeName(void* bfCompiler, char8* typeName, int32 cursorPos);
[CallingConvention(.Stdcall), CLink]
static extern bool BfCompiler_ClassifySource(void* bfCompiler, void* bfPassInstance, void* bfParser, void* bfResolvePassData, void* char8Data);
static extern bool BfCompiler_ClassifySource(void* bfCompiler, void* bfPassInstance, void* bfResolvePassData);
[CallingConvention(.Stdcall), CLink]
static extern char8* BfCompiler_GetCollapseRegions(void* bfCompiler, void* bfParser);
static extern char8* BfCompiler_GetCollapseRegions(void* bfCompiler, void* bfParser, void* bfResolvePassData, char8* explicitEmitTypeNames);
[CallingConvention(.Stdcall), CLink]
static extern char8* BfCompiler_GetAutocompleteInfo(void* bfCompiler);
@ -135,6 +135,12 @@ namespace IDE.Compiler
[CallingConvention(.Stdcall), CLink]
static extern char8* BfCompiler_GetTypeInfo(void* bfCompiler, char8* typeName);
[CallingConvention(.Stdcall), CLink]
static extern char8* BfCompiler_GetGenericTypeInstances(void* bfCompiler, char8* typeName);
[CallingConvention(.Stdcall), CLink]
static extern int32 BfCompiler_GetTypeId(void* bfCompiler, char8* typeName);
[CallingConvention(.Stdcall), CLink]
static extern void BfCompiler_SetOptions(void* bfCompiler,
void* hotProject, int32 hotIdx, char8* targetTriple, char8* targetCPU, int32 toolsetType, int32 simdSetting, int32 allocStackCount, int32 maxWorkerThreads,
@ -149,6 +155,12 @@ namespace IDE.Compiler
[CallingConvention(.Stdcall), CLink]
static extern int32 BfCompiler_GetEmitSourceVersion(void* bfCompiler, char8* fileName);
[CallingConvention(.Stdcall), CLink]
static extern char8* BfCompiler_GetEmitLocation(void* bfCompiler, char8* typeName, int32 line, out int32 embedLine, out int32 embedLineChar);
[CallingConvention(.Stdcall), CLink]
static extern void BfCompiler_WriteEmitData(void* bfCompiler, char8* filePath, void* bfProject);
public enum HotTypeFlags
{
None = 0,
@ -260,18 +272,17 @@ namespace IDE.Compiler
BfCompiler_ClearResults(mNativeBfCompiler);
}
public bool ClassifySource(BfPassInstance bfPassInstance, BfParser parser, BfResolvePassData resolvePassData, EditWidgetContent.CharData[] char8Data)
public bool ClassifySource(BfPassInstance bfPassInstance, BfResolvePassData resolvePassData)
{
void* nativeResolvePassData = null;
if (resolvePassData != null)
nativeResolvePassData = resolvePassData.mNativeResolvePassData;
EditWidgetContent.CharData* char8DataPtr = (char8Data != null) ? char8Data.CArray() : null;
return BfCompiler_ClassifySource(mNativeBfCompiler, bfPassInstance.mNativeBfPassInstance, (parser != null) ? parser.mNativeBfParser : null, nativeResolvePassData, char8DataPtr);
return BfCompiler_ClassifySource(mNativeBfCompiler, bfPassInstance.mNativeBfPassInstance, nativeResolvePassData);
}
public void GetCollapseRegions(BfParser parser, String outData)
public void GetCollapseRegions(BfParser parser, BfResolvePassData resolvePassData, String explicitEmitTypeNames, String outData)
{
outData.Append(BfCompiler_GetCollapseRegions(mNativeBfCompiler, (parser != null) ? parser.mNativeBfParser : null));
outData.Append(BfCompiler_GetCollapseRegions(mNativeBfCompiler, (parser != null) ? parser.mNativeBfParser : null, resolvePassData.mNativeResolvePassData, explicitEmitTypeNames));
}
public bool VerifyTypeName(String typeName, int cursorPos)
@ -344,6 +355,15 @@ namespace IDE.Compiler
return BfCompiler_GetEmitSourceVersion(mNativeBfCompiler, fileName.ToScopeCStr!());
}
public void GetEmitLocation(StringView typeName, int line, String outFilePath, out int embedLine, out int embedLineChar)
{
int32 embedLine32;
int32 embedLineChar32;
outFilePath.Append(BfCompiler_GetEmitLocation(mNativeBfCompiler, typeName.ToScopeCStr!(), (.)line, out embedLine32, out embedLineChar32));
embedLine = embedLine32;
embedLineChar = embedLineChar32;
}
public void QueueSetPassInstance(BfPassInstance passInstance)
{
SetPassInstanceCommand command = new SetPassInstanceCommand();
@ -588,7 +608,7 @@ namespace IDE.Compiler
var resolvePassData = BfResolvePassData.Create(ResolveType.Classify);
// If we get canceled then try again after waiting a couple updates
if (!ClassifySource(passInstance, null, resolvePassData, null))
if (!ClassifySource(passInstance, resolvePassData))
QueueDeferredResolveAll();
UpdateRebuildFileWatches();
@ -808,11 +828,21 @@ namespace IDE.Compiler
outStr.Append(BfCompiler_GetTypeDefInfo(mNativeBfCompiler, typeDefName));
}
public void GetGenericTypeInstances(String typeName, String outStr)
{
outStr.Append(BfCompiler_GetGenericTypeInstances(mNativeBfCompiler, typeName));
}
public void GetTypeInfo(String typeDefName, String outStr)
{
outStr.Append(BfCompiler_GetTypeInfo(mNativeBfCompiler, typeDefName));
}
public int GetTypeId(String typeName)
{
return BfCompiler_GetTypeId(mNativeBfCompiler, typeName);
}
public void ClearBuildCache()
{
BfCompiler_ClearBuildCache(mNativeBfCompiler);
@ -943,5 +973,10 @@ namespace IDE.Compiler
dirChangedCommand.mDir.Set(str);
QueueCommand(dirChangedCommand);
}
public void WriteEmitData(String filePath, BfProject bfProject)
{
BfCompiler_WriteEmitData(mNativeBfCompiler, filePath, bfProject.mNativeBfProject);
}
}
}

View file

@ -29,29 +29,50 @@ namespace IDE.Compiler
public enum ResolveType
{
None,
Classify,
ClassifyFullRefresh,
Autocomplete,
Autocomplete_HighPri,
GoToDefinition,
GetSymbolInfo,
RenameSymbol,
ShowFileSymbolReferences,
GetNavigationData,
GetCurrentLocation,
GetFixits,
GetTypeDefList,
GetTypeDefInto,
GetResultString
case None,
Classify,
ClassifyFullRefresh,
Autocomplete,
Autocomplete_HighPri,
GoToDefinition,
GetSymbolInfo,
RenameSymbol,
ShowFileSymbolReferences,
GetNavigationData,
GetCurrentLocation,
GetFixits,
GetTypeDefList,
GetTypeDefInto,
GetResultString;
public bool IsClassify => (this == .Classify) || (this == .ClassifyFullRefresh);
}
public enum SourceEmbedKind
{
None,
Type,
Method
}
public class ResolveParams
{
public class Embed
{
public String mTypeName ~ delete _;
public int32 mRevision = -1;
public int32 mCursorIdx = -1;
public EditWidgetContent.CharData[] mCharData ~ delete _;
}
public ResolveType mResolveType;
public int32 mOverrideCursorPos = -1;
public bool mInDeferredList;
public EditWidgetContent.CharData[] mCharData ~ delete _;
public IdSpan mCharIdSpan ~ _.Dispose();
public BfParser mParser;
public int32 mLocalId = -1;
public String mReplaceStr ~ delete _;
public String mTypeDef ~ delete _;
@ -71,9 +92,7 @@ namespace IDE.Compiler
public WaitEvent mWaitEvent ~ delete _;
public BfPassInstance mPassInstance ~ delete _;
public EditWidgetContent.CharData[] mCharData ~ delete _;
public IdSpan mCharIdSpan ~ _.Dispose();
public BfParser mParser;
public List<Embed> mEmitEmbeds = new .() ~ DeleteContainerAndItems!(_);
public String mDocumentationName ~ delete _;
public bool mCancelled;
public int32 mTextVersion = -1;
@ -108,13 +127,16 @@ namespace IDE.Compiler
static extern void BfParser_SetNextRevision(void* bfParser, void* nextParser);
[CallingConvention(.Stdcall), CLink]
static extern bool BfParser_SetCursorIdx(void* bfParser, int32 cursorIdx);
static extern void BfParser_SetCursorIdx(void* bfParser, int32 cursorIdx);
[CallingConvention(.Stdcall), CLink]
static extern bool BfParser_SetAutocomplete(void* bfParser, int32 cursorIdx);
static extern void BfParser_SetAutocomplete(void* bfParser, int32 cursorIdx);
[CallingConvention(.Stdcall), CLink]
static extern void BfParser_SetEmbedKind(void* bfParser, SourceEmbedKind embedKind);
[CallingConvention(.Stdcall), CLink]
static extern bool BfParser_SetIsClassifying(void* bfParser);
static extern void BfParser_SetIsClassifying(void* bfParser);
[CallingConvention(.Stdcall), CLink]
static extern bool BfParser_Parse(void* bfParser, void* bfPassInstance, bool compatMode);
@ -140,6 +162,12 @@ namespace IDE.Compiler
[CallingConvention(.Stdcall), CLink]
static extern void BfParser_ClassifySource(void* bfParser, void* elementTypeArray, bool preserveFlags);
[CallingConvention(.Stdcall), CLink]
static extern void BfParser_CreateClassifier(void* bfParser, void* passInstance, void* resolvePassData, void* elementTypeArray);
[CallingConvention(.Stdcall), CLink]
static extern void BfParser_FinishClassifier(void* bfParser, void* resolvePassData);
[CallingConvention(.Stdcall), CLink]
static extern void BfParser_GenerateAutoCompletionFrom(void* bfParser, int32 srcPosition);
@ -168,11 +196,11 @@ namespace IDE.Compiler
mNativeBfParser = null;
}
public void SetSource(String data, String fileName)
public void SetSource(StringView data, String fileName)
{
Debug.Assert(!mIsUsed);
mIsUsed = true;
BfParser_SetSource(mNativeBfParser, data, (int32)data.Length, fileName);
BfParser_SetSource(mNativeBfParser, data.Ptr, (int32)data.Length, fileName);
}
public void SetCharIdData(ref IdSpan char8IdData)
@ -192,6 +220,11 @@ namespace IDE.Compiler
BfParser_SetAutocomplete(mNativeBfParser, (int32)cursorIdx);
}
public void SetEmbedKind(SourceEmbedKind embedKind)
{
BfParser_SetEmbedKind(mNativeBfParser, embedKind);
}
public void SetIsClassifying()
{
BfParser_SetIsClassifying(mNativeBfParser);
@ -247,6 +280,17 @@ namespace IDE.Compiler
BfParser_ClassifySource(mNativeBfParser, char8DataPtr, preserveFlags);
}
public void CreateClassifier(BfPassInstance passInstance, BfResolvePassData bfResolvePassData, EditWidgetContent.CharData[] charDataArr)
{
EditWidgetContent.CharData* charDataPtr = charDataArr.CArray();
BfParser_CreateClassifier(mNativeBfParser, passInstance.mNativeBfPassInstance, bfResolvePassData.mNativeResolvePassData, charDataPtr);
}
public void FinishClassifier(BfResolvePassData bfResolvePassData)
{
BfParser_FinishClassifier(mNativeBfParser, bfResolvePassData.mNativeResolvePassData);
}
public void SetNextRevision(BfParser nextRevision)
{
BfParser_SetNextRevision(mNativeBfParser, nextRevision.mNativeBfParser);

View file

@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Text;
using System.Threading.Tasks;
using Beefy.widgets;
namespace IDE.Compiler
{
@ -37,6 +38,12 @@ namespace IDE.Compiler
[CallingConvention(.Stdcall), CLink]
static extern void BfResolvePassData_SetDocumentationRequest(void* bfResolvePassData, char8* entryName);
[CallingConvention(.Stdcall), CLink]
static extern void BfResolvePassData_AddEmitEmbed(void* bfResolvePassData, char8* typeName, int32 cursorIdx);
[CallingConvention(.Stdcall), CLink]
static extern void* BfResolvePassData_GetEmitEmbedData(void* bfResolvePassData, char8* typeName, out int32 srcLength, out int32 revision);
//
//[CallingConvention(.Stdcall), CLink]
@ -100,5 +107,15 @@ namespace IDE.Compiler
resolvePassData.mNativeResolvePassData = BfParser.[Friend]BfParser_CreateResolvePassData(null, (int32)resolveType, doFuzzyAutoComplete);
return resolvePassData;
}
public void AddEmitEmbed(char8* typeName, int32 cursorIdx)
{
BfResolvePassData_AddEmitEmbed(mNativeResolvePassData, typeName, cursorIdx);
}
public EditWidgetContent.CharData* GetEmitEmbedData(char8* typeName, out int32 srcLength, out int32 revision)
{
return (.)BfResolvePassData_GetEmitEmbedData(mNativeResolvePassData, typeName, out srcLength, out revision);
}
}
}