mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Add BfParser_GetLineCharAtIdx, include fields in document symbols and optionally include location in type defs
This commit is contained in:
parent
9daae6baa6
commit
852d11c6c3
5 changed files with 282 additions and 211 deletions
|
@ -124,10 +124,10 @@ namespace IDE.Compiler
|
||||||
static extern char8* BfCompiler_GetGeneratorGenData(void* bfCompiler, char8* typeDefName, char8* args);
|
static extern char8* BfCompiler_GetGeneratorGenData(void* bfCompiler, char8* typeDefName, char8* args);
|
||||||
|
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern char8* BfCompiler_GetTypeDefList(void* bfCompiler);
|
static extern char8* BfCompiler_GetTypeDefList(void* bfCompiler, bool includeLocation);
|
||||||
|
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern char8* BfCompiler_GetTypeDefMatches(void* bfCompiler, char8* searchStr);
|
static extern char8* BfCompiler_GetTypeDefMatches(void* bfCompiler, char8* searchStr, bool includeLocation);
|
||||||
|
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern char8* BfCompiler_GetTypeDefInfo(void* bfCompiler, char8* typeDefName);
|
static extern char8* BfCompiler_GetTypeDefInfo(void* bfCompiler, char8* typeDefName);
|
||||||
|
@ -846,14 +846,14 @@ namespace IDE.Compiler
|
||||||
outStr.Append(BfCompiler_GetGeneratorGenData(mNativeBfCompiler, typeDefName, args));
|
outStr.Append(BfCompiler_GetGeneratorGenData(mNativeBfCompiler, typeDefName, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetTypeDefList(String outStr)
|
public void GetTypeDefList(String outStr, bool includeLocation = false)
|
||||||
{
|
{
|
||||||
outStr.Append(BfCompiler_GetTypeDefList(mNativeBfCompiler));
|
outStr.Append(BfCompiler_GetTypeDefList(mNativeBfCompiler, includeLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetTypeDefMatches(String searchStr, String outStr)
|
public void GetTypeDefMatches(String searchStr, String outStr, bool includeLocation = false)
|
||||||
{
|
{
|
||||||
outStr.Append(BfCompiler_GetTypeDefMatches(mNativeBfCompiler, searchStr));
|
outStr.Append(BfCompiler_GetTypeDefMatches(mNativeBfCompiler, searchStr, includeLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetTypeDefInfo(String typeDefName, String outStr)
|
public void GetTypeDefInfo(String typeDefName, String outStr)
|
||||||
|
|
|
@ -175,6 +175,9 @@ namespace IDE.Compiler
|
||||||
[CallingConvention(.Stdcall), CLink]
|
[CallingConvention(.Stdcall), CLink]
|
||||||
static extern void BfParser_SetCompleteParse(void* bfParser);
|
static extern void BfParser_SetCompleteParse(void* bfParser);
|
||||||
|
|
||||||
|
[CallingConvention(.Stdcall), CLink]
|
||||||
|
static extern void BfParser_GetLineCharAtIdx(void* bfParser, int32 idx, int32* line, int32* lineChar);
|
||||||
|
|
||||||
public BfSystem mSystem;
|
public BfSystem mSystem;
|
||||||
public void* mNativeBfParser;
|
public void* mNativeBfParser;
|
||||||
public bool mIsUsed;
|
public bool mIsUsed;
|
||||||
|
@ -419,5 +422,14 @@ namespace IDE.Compiler
|
||||||
var md5Hash;
|
var md5Hash;
|
||||||
BfParser_SetHashMD5(mNativeBfParser, ref md5Hash);
|
BfParser_SetHashMD5(mNativeBfParser, ref md5Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public (int, int) GetLineCharAtIdx(int idx) {
|
||||||
|
int32 line = 0;
|
||||||
|
int32 char = 0;
|
||||||
|
|
||||||
|
BfParser_GetLineCharAtIdx(mNativeBfParser, (.) idx, &line, &char);
|
||||||
|
|
||||||
|
return (line, char);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4077,6 +4077,27 @@ void BfCompiler::ProcessAutocompleteTempType()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto fieldDef : tempTypeDef->mFields)
|
||||||
|
{
|
||||||
|
auto fieldDeclaration = BfNodeDynCast<BfFieldDeclaration>(fieldDef->mFieldDeclaration);
|
||||||
|
if ((fieldDeclaration == NULL) || (fieldDeclaration->mNameNode == NULL) || (BfNodeIsA<BfPropertyDeclaration>(fieldDef->mFieldDeclaration)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String fieldText = fieldDef->mName;
|
||||||
|
if (typeName != "@")
|
||||||
|
fieldText = typeName + "." + fieldText;
|
||||||
|
|
||||||
|
if (!autoCompleteResultString.empty())
|
||||||
|
autoCompleteResultString += "\n";
|
||||||
|
|
||||||
|
BfAstNode* refNode = fieldDeclaration->mNameNode;
|
||||||
|
module->UpdateSrcPos(refNode, (BfSrcPosFlags)(BfSrcPosFlag_NoSetDebugLoc | BfSrcPosFlag_Force));
|
||||||
|
|
||||||
|
fieldText += StrFormat("\tfield\t%d\t%d", module->mCurFilePosition.mCurLine, module->mCurFilePosition.mCurColumn);
|
||||||
|
|
||||||
|
autoCompleteResultString += fieldText;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto propDef : tempTypeDef->mProperties)
|
for (auto propDef : tempTypeDef->mProperties)
|
||||||
{
|
{
|
||||||
auto propDeclaration = BfNodeDynCast<BfPropertyDeclaration>(propDef->mFieldDeclaration);
|
auto propDeclaration = BfNodeDynCast<BfPropertyDeclaration>(propDef->mFieldDeclaration);
|
||||||
|
@ -8447,203 +8468,6 @@ void BfCompiler::GenerateAutocompleteInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String BfCompiler::GetTypeDefList()
|
|
||||||
{
|
|
||||||
String result;
|
|
||||||
|
|
||||||
BfProject* curProject = NULL;
|
|
||||||
Dictionary<BfProject*, int> projectIds;
|
|
||||||
|
|
||||||
for (auto typeDef : mSystem->mTypeDefs)
|
|
||||||
{
|
|
||||||
if (typeDef->mProject != curProject)
|
|
||||||
{
|
|
||||||
curProject = typeDef->mProject;
|
|
||||||
int* projectIdPtr;
|
|
||||||
if (projectIds.TryAdd(curProject, NULL, &projectIdPtr))
|
|
||||||
{
|
|
||||||
*projectIdPtr = (int)projectIds.size() - 1;
|
|
||||||
result += '+';
|
|
||||||
result += curProject->mName;
|
|
||||||
result += '\n';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char str[32];
|
|
||||||
sprintf(str, "=%d\n", *projectIdPtr);
|
|
||||||
result += str;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (((!typeDef->mIsPartial) || (typeDef->mIsCombinedPartial)))
|
|
||||||
{
|
|
||||||
if (typeDef->IsGlobalsContainer())
|
|
||||||
{
|
|
||||||
result += 'g';
|
|
||||||
if (!typeDef->mNamespace.IsEmpty())
|
|
||||||
{
|
|
||||||
typeDef->mNamespace.ToString(result);
|
|
||||||
result += '.';
|
|
||||||
}
|
|
||||||
result += ":static\n";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if (typeDef->mTypeCode == BfTypeCode_Interface)
|
|
||||||
result += 'i';
|
|
||||||
else if (typeDef->mTypeCode == BfTypeCode_Object)
|
|
||||||
result += 'c';
|
|
||||||
else
|
|
||||||
result += 'v';
|
|
||||||
result += BfTypeUtils::TypeToString(typeDef, BfTypeNameFlag_InternalName) + "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
String BfCompiler::GetGeneratorString(BfTypeDef* typeDef, BfTypeInstance* typeInst, const StringImpl& generatorMethodName, const StringImpl* args)
|
|
||||||
{
|
|
||||||
if (typeInst == NULL)
|
|
||||||
{
|
|
||||||
auto type = mContext->mUnreifiedModule->ResolveTypeDef(typeDef, BfPopulateType_BaseType);
|
|
||||||
if (type != NULL)
|
|
||||||
typeInst = type->ToTypeInstance();
|
|
||||||
if (typeInst == NULL)
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
BfTypeVector typeVector;
|
|
||||||
typeVector.Add(typeInst);
|
|
||||||
|
|
||||||
auto generatorTypeInst = mContext->mUnreifiedModule->ResolveTypeDef(mCompilerGeneratorTypeDef)->ToTypeInstance();
|
|
||||||
auto methodDef = generatorTypeInst->mTypeDef->GetMethodByName(generatorMethodName);
|
|
||||||
auto moduleMethodInstance = mContext->mUnreifiedModule->GetMethodInstance(generatorTypeInst, methodDef, typeVector);
|
|
||||||
|
|
||||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mContext->mUnreifiedModule->mCurMethodInstance, moduleMethodInstance.mMethodInstance);
|
|
||||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mContext->mUnreifiedModule->mCurTypeInstance, typeInst);
|
|
||||||
|
|
||||||
BfExprEvaluator exprEvaluator(mContext->mUnreifiedModule);
|
|
||||||
exprEvaluator.mBfEvalExprFlags = (BfEvalExprFlags)(BfEvalExprFlags_Comptime | BfEvalExprFlags_NoCeRebuildFlags);
|
|
||||||
|
|
||||||
SizedArray<BfIRValue, 1> irArgs;
|
|
||||||
if (args != NULL)
|
|
||||||
irArgs.Add(mContext->mUnreifiedModule->GetStringObjectValue(*args));
|
|
||||||
auto callResult = exprEvaluator.CreateCall(NULL, moduleMethodInstance.mMethodInstance, moduleMethodInstance.mFunc, false, irArgs, NULL, BfCreateCallFlags_None);
|
|
||||||
|
|
||||||
if (callResult.mValue.IsConst())
|
|
||||||
{
|
|
||||||
auto stringPtr = mContext->mUnreifiedModule->GetStringPoolString(callResult.mValue, mContext->mUnreifiedModule->mBfIRBuilder);
|
|
||||||
if (stringPtr != NULL)
|
|
||||||
return *stringPtr;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
void BfCompiler::HandleGeneratorErrors(StringImpl& result)
|
|
||||||
{
|
|
||||||
if ((mPassInstance->mErrors.IsEmpty()) && (mPassInstance->mOutStream.IsEmpty()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
result.Clear();
|
|
||||||
|
|
||||||
for (auto& msg : mPassInstance->mOutStream)
|
|
||||||
{
|
|
||||||
String error = msg;
|
|
||||||
error.Replace('\n', '\r');
|
|
||||||
result += "!error\t";
|
|
||||||
result += error;
|
|
||||||
result += "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String BfCompiler::GetGeneratorTypeDefList()
|
|
||||||
{
|
|
||||||
String result;
|
|
||||||
|
|
||||||
BfProject* curProject = NULL;
|
|
||||||
Dictionary<BfProject*, int> projectIds;
|
|
||||||
|
|
||||||
BfResolvePassData resolvePassData;
|
|
||||||
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
|
||||||
BfPassInstance passInstance(mSystem);
|
|
||||||
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
|
||||||
|
|
||||||
for (auto typeDef : mSystem->mTypeDefs)
|
|
||||||
{
|
|
||||||
if (typeDef->mProject->mDisabled)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (typeDef->mIsPartial)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
auto type = mContext->mUnreifiedModule->ResolveTypeDef(typeDef, BfPopulateType_BaseType);
|
|
||||||
if ((type != NULL) && (type->IsTypeInstance()))
|
|
||||||
{
|
|
||||||
auto typeInst = type->ToTypeInstance();
|
|
||||||
if ((typeInst->mBaseType != NULL) && (typeInst->mBaseType->IsInstanceOf(mCompilerGeneratorTypeDef)))
|
|
||||||
{
|
|
||||||
result += typeDef->mProject->mName;
|
|
||||||
result += ":";
|
|
||||||
result += BfTypeUtils::TypeToString(typeDef, BfTypeNameFlag_InternalName);
|
|
||||||
String nameString = GetGeneratorString(typeDef, typeInst, "GetName", NULL);
|
|
||||||
if (!nameString.IsEmpty())
|
|
||||||
result += "\t" + nameString;
|
|
||||||
result += "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleGeneratorErrors(result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
String BfCompiler::GetGeneratorInitData(const StringImpl& typeName, const StringImpl& args)
|
|
||||||
{
|
|
||||||
BfResolvePassData resolvePassData;
|
|
||||||
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
|
||||||
BfPassInstance passInstance(mSystem);
|
|
||||||
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
|
||||||
|
|
||||||
Array<BfTypeDef*> typeDefs;
|
|
||||||
GetTypeDefs(typeName, typeDefs);
|
|
||||||
|
|
||||||
String result;
|
|
||||||
for (auto typeDef : typeDefs)
|
|
||||||
{
|
|
||||||
result += GetGeneratorString(typeDef, NULL, "InitUI", &args);
|
|
||||||
if (!result.IsEmpty())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleGeneratorErrors(result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
String BfCompiler::GetGeneratorGenData(const StringImpl& typeName, const StringImpl& args)
|
|
||||||
{
|
|
||||||
BfResolvePassData resolvePassData;
|
|
||||||
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
|
||||||
BfPassInstance passInstance(mSystem);
|
|
||||||
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
|
||||||
|
|
||||||
Array<BfTypeDef*> typeDefs;
|
|
||||||
GetTypeDefs(typeName, typeDefs);
|
|
||||||
|
|
||||||
String result;
|
|
||||||
for (auto typeDef : typeDefs)
|
|
||||||
{
|
|
||||||
result += GetGeneratorString(typeDef, NULL, "Generate", &args);
|
|
||||||
if (!result.IsEmpty())
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HandleGeneratorErrors(result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct TypeDefMatchHelper
|
struct TypeDefMatchHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -8916,7 +8740,218 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr)
|
String BfCompiler::GetTypeDefList(bool includeLocation)
|
||||||
|
{
|
||||||
|
String result;
|
||||||
|
TypeDefMatchHelper matchHelper(result);
|
||||||
|
|
||||||
|
BfProject* curProject = NULL;
|
||||||
|
Dictionary<BfProject*, int> projectIds;
|
||||||
|
|
||||||
|
for (auto typeDef : mSystem->mTypeDefs)
|
||||||
|
{
|
||||||
|
if (typeDef->mProject != curProject)
|
||||||
|
{
|
||||||
|
curProject = typeDef->mProject;
|
||||||
|
int* projectIdPtr;
|
||||||
|
if (projectIds.TryAdd(curProject, NULL, &projectIdPtr))
|
||||||
|
{
|
||||||
|
*projectIdPtr = (int)projectIds.size() - 1;
|
||||||
|
result += '+';
|
||||||
|
result += curProject->mName;
|
||||||
|
result += '\n';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char str[32];
|
||||||
|
sprintf(str, "=%d\n", *projectIdPtr);
|
||||||
|
result += str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (((!typeDef->mIsPartial) || (typeDef->mIsCombinedPartial)))
|
||||||
|
{
|
||||||
|
if (typeDef->IsGlobalsContainer())
|
||||||
|
{
|
||||||
|
result += 'g';
|
||||||
|
if (!typeDef->mNamespace.IsEmpty())
|
||||||
|
{
|
||||||
|
typeDef->mNamespace.ToString(result);
|
||||||
|
result += '.';
|
||||||
|
}
|
||||||
|
result += ":static\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (typeDef->mTypeCode == BfTypeCode_Interface)
|
||||||
|
result += 'i';
|
||||||
|
else if (typeDef->mTypeCode == BfTypeCode_Object)
|
||||||
|
result += 'c';
|
||||||
|
else
|
||||||
|
result += 'v';
|
||||||
|
|
||||||
|
String typeName = BfTypeUtils::TypeToString(typeDef, BfTypeNameFlag_InternalName);
|
||||||
|
|
||||||
|
if (includeLocation)
|
||||||
|
{
|
||||||
|
result += typeName + "\t";
|
||||||
|
|
||||||
|
matchHelper.AddLocation(typeDef->GetRefNode());
|
||||||
|
result += "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += typeName + "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String BfCompiler::GetGeneratorString(BfTypeDef* typeDef, BfTypeInstance* typeInst, const StringImpl& generatorMethodName, const StringImpl* args)
|
||||||
|
{
|
||||||
|
if (typeInst == NULL)
|
||||||
|
{
|
||||||
|
auto type = mContext->mUnreifiedModule->ResolveTypeDef(typeDef, BfPopulateType_BaseType);
|
||||||
|
if (type != NULL)
|
||||||
|
typeInst = type->ToTypeInstance();
|
||||||
|
if (typeInst == NULL)
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
BfTypeVector typeVector;
|
||||||
|
typeVector.Add(typeInst);
|
||||||
|
|
||||||
|
auto generatorTypeInst = mContext->mUnreifiedModule->ResolveTypeDef(mCompilerGeneratorTypeDef)->ToTypeInstance();
|
||||||
|
auto methodDef = generatorTypeInst->mTypeDef->GetMethodByName(generatorMethodName);
|
||||||
|
auto moduleMethodInstance = mContext->mUnreifiedModule->GetMethodInstance(generatorTypeInst, methodDef, typeVector);
|
||||||
|
|
||||||
|
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mContext->mUnreifiedModule->mCurMethodInstance, moduleMethodInstance.mMethodInstance);
|
||||||
|
SetAndRestoreValue<BfTypeInstance*> prevTypeInstance(mContext->mUnreifiedModule->mCurTypeInstance, typeInst);
|
||||||
|
|
||||||
|
BfExprEvaluator exprEvaluator(mContext->mUnreifiedModule);
|
||||||
|
exprEvaluator.mBfEvalExprFlags = (BfEvalExprFlags)(BfEvalExprFlags_Comptime | BfEvalExprFlags_NoCeRebuildFlags);
|
||||||
|
|
||||||
|
SizedArray<BfIRValue, 1> irArgs;
|
||||||
|
if (args != NULL)
|
||||||
|
irArgs.Add(mContext->mUnreifiedModule->GetStringObjectValue(*args));
|
||||||
|
auto callResult = exprEvaluator.CreateCall(NULL, moduleMethodInstance.mMethodInstance, moduleMethodInstance.mFunc, false, irArgs, NULL, BfCreateCallFlags_None);
|
||||||
|
|
||||||
|
if (callResult.mValue.IsConst())
|
||||||
|
{
|
||||||
|
auto stringPtr = mContext->mUnreifiedModule->GetStringPoolString(callResult.mValue, mContext->mUnreifiedModule->mBfIRBuilder);
|
||||||
|
if (stringPtr != NULL)
|
||||||
|
return *stringPtr;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
void BfCompiler::HandleGeneratorErrors(StringImpl& result)
|
||||||
|
{
|
||||||
|
if ((mPassInstance->mErrors.IsEmpty()) && (mPassInstance->mOutStream.IsEmpty()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
result.Clear();
|
||||||
|
|
||||||
|
for (auto& msg : mPassInstance->mOutStream)
|
||||||
|
{
|
||||||
|
String error = msg;
|
||||||
|
error.Replace('\n', '\r');
|
||||||
|
result += "!error\t";
|
||||||
|
result += error;
|
||||||
|
result += "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String BfCompiler::GetGeneratorTypeDefList()
|
||||||
|
{
|
||||||
|
String result;
|
||||||
|
|
||||||
|
BfProject* curProject = NULL;
|
||||||
|
Dictionary<BfProject*, int> projectIds;
|
||||||
|
|
||||||
|
BfResolvePassData resolvePassData;
|
||||||
|
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
||||||
|
BfPassInstance passInstance(mSystem);
|
||||||
|
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
||||||
|
|
||||||
|
for (auto typeDef : mSystem->mTypeDefs)
|
||||||
|
{
|
||||||
|
if (typeDef->mProject->mDisabled)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (typeDef->mIsPartial)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto type = mContext->mUnreifiedModule->ResolveTypeDef(typeDef, BfPopulateType_BaseType);
|
||||||
|
if ((type != NULL) && (type->IsTypeInstance()))
|
||||||
|
{
|
||||||
|
auto typeInst = type->ToTypeInstance();
|
||||||
|
if ((typeInst->mBaseType != NULL) && (typeInst->mBaseType->IsInstanceOf(mCompilerGeneratorTypeDef)))
|
||||||
|
{
|
||||||
|
result += typeDef->mProject->mName;
|
||||||
|
result += ":";
|
||||||
|
result += BfTypeUtils::TypeToString(typeDef, BfTypeNameFlag_InternalName);
|
||||||
|
String nameString = GetGeneratorString(typeDef, typeInst, "GetName", NULL);
|
||||||
|
if (!nameString.IsEmpty())
|
||||||
|
result += "\t" + nameString;
|
||||||
|
result += "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HandleGeneratorErrors(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String BfCompiler::GetGeneratorInitData(const StringImpl& typeName, const StringImpl& args)
|
||||||
|
{
|
||||||
|
BfResolvePassData resolvePassData;
|
||||||
|
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
||||||
|
BfPassInstance passInstance(mSystem);
|
||||||
|
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
||||||
|
|
||||||
|
Array<BfTypeDef*> typeDefs;
|
||||||
|
GetTypeDefs(typeName, typeDefs);
|
||||||
|
|
||||||
|
String result;
|
||||||
|
for (auto typeDef : typeDefs)
|
||||||
|
{
|
||||||
|
result += GetGeneratorString(typeDef, NULL, "InitUI", &args);
|
||||||
|
if (!result.IsEmpty())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HandleGeneratorErrors(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String BfCompiler::GetGeneratorGenData(const StringImpl& typeName, const StringImpl& args)
|
||||||
|
{
|
||||||
|
BfResolvePassData resolvePassData;
|
||||||
|
SetAndRestoreValue<BfResolvePassData*> prevResolvePassData(mResolvePassData, &resolvePassData);
|
||||||
|
BfPassInstance passInstance(mSystem);
|
||||||
|
SetAndRestoreValue<BfPassInstance*> prevPassInstance(mPassInstance, &passInstance);
|
||||||
|
|
||||||
|
Array<BfTypeDef*> typeDefs;
|
||||||
|
GetTypeDefs(typeName, typeDefs);
|
||||||
|
|
||||||
|
String result;
|
||||||
|
for (auto typeDef : typeDefs)
|
||||||
|
{
|
||||||
|
result += GetGeneratorString(typeDef, NULL, "Generate", &args);
|
||||||
|
if (!result.IsEmpty())
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
HandleGeneratorErrors(result);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr, bool includeLocation)
|
||||||
{
|
{
|
||||||
String result;
|
String result;
|
||||||
TypeDefMatchHelper matchHelper(result);
|
TypeDefMatchHelper matchHelper(result);
|
||||||
|
@ -9026,6 +9061,9 @@ String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr)
|
||||||
{
|
{
|
||||||
for (auto fieldDef : typeDef->mFields)
|
for (auto fieldDef : typeDef->mFields)
|
||||||
{
|
{
|
||||||
|
if (BfNodeIsA<BfPropertyDeclaration>(fieldDef->mFieldDeclaration))
|
||||||
|
continue;
|
||||||
|
|
||||||
matchHelper.ClearResults();
|
matchHelper.ClearResults();
|
||||||
|
|
||||||
bool hasMatch = false;
|
bool hasMatch = false;
|
||||||
|
@ -9216,8 +9254,19 @@ String BfCompiler::GetTypeDefMatches(const StringImpl& searchStr)
|
||||||
result += "c";
|
result += "c";
|
||||||
else
|
else
|
||||||
result += "v";
|
result += "v";
|
||||||
|
|
||||||
|
if (includeLocation)
|
||||||
|
{
|
||||||
|
result += typeName + "\t";
|
||||||
|
|
||||||
|
matchHelper.AddLocation(typeDef->GetRefNode());
|
||||||
|
result += "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
result += typeName + "\n";
|
result += typeName + "\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -10356,19 +10405,19 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetGeneratorGenData(BfCompiler* bfC
|
||||||
return outString.c_str();
|
return outString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetTypeDefList(BfCompiler* bfCompiler)
|
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetTypeDefList(BfCompiler* bfCompiler, bool includeLocation)
|
||||||
{
|
{
|
||||||
String& outString = *gTLStrReturn.Get();
|
String& outString = *gTLStrReturn.Get();
|
||||||
outString.clear();
|
outString.clear();
|
||||||
outString = bfCompiler->GetTypeDefList();
|
outString = bfCompiler->GetTypeDefList(includeLocation);
|
||||||
return outString.c_str();
|
return outString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetTypeDefMatches(BfCompiler* bfCompiler, const char* searchStr)
|
BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetTypeDefMatches(BfCompiler* bfCompiler, const char* searchStr, bool includeLocation)
|
||||||
{
|
{
|
||||||
String& outString = *gTLStrReturn.Get();
|
String& outString = *gTLStrReturn.Get();
|
||||||
outString.clear();
|
outString.clear();
|
||||||
outString = bfCompiler->GetTypeDefMatches(searchStr);
|
outString = bfCompiler->GetTypeDefMatches(searchStr, includeLocation);
|
||||||
return outString.c_str();
|
return outString.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -541,13 +541,13 @@ public:
|
||||||
void GetSymbolReferences();
|
void GetSymbolReferences();
|
||||||
void Cancel();
|
void Cancel();
|
||||||
void RequestFastFinish();
|
void RequestFastFinish();
|
||||||
String GetTypeDefList();
|
String GetTypeDefList(bool includeLocation);
|
||||||
String GetGeneratorString(BfTypeDef* typeDef, BfTypeInstance* typeInst, const StringImpl& generatorMethodName, const StringImpl* args);
|
String GetGeneratorString(BfTypeDef* typeDef, BfTypeInstance* typeInst, const StringImpl& generatorMethodName, const StringImpl* args);
|
||||||
void HandleGeneratorErrors(StringImpl& result);
|
void HandleGeneratorErrors(StringImpl& result);
|
||||||
String GetGeneratorTypeDefList();
|
String GetGeneratorTypeDefList();
|
||||||
String GetGeneratorInitData(const StringImpl& typeName, const StringImpl& args);
|
String GetGeneratorInitData(const StringImpl& typeName, const StringImpl& args);
|
||||||
String GetGeneratorGenData(const StringImpl& typeName, const StringImpl& args);
|
String GetGeneratorGenData(const StringImpl& typeName, const StringImpl& args);
|
||||||
String GetTypeDefMatches(const StringImpl& searchSrc);
|
String GetTypeDefMatches(const StringImpl& searchSrc, bool includeLocation);
|
||||||
void GetTypeDefs(const StringImpl& typeName, Array<BfTypeDef*>& typeDefs);
|
void GetTypeDefs(const StringImpl& typeName, Array<BfTypeDef*>& typeDefs);
|
||||||
String GetTypeDefInfo(const StringImpl& typeName);
|
String GetTypeDefInfo(const StringImpl& typeName);
|
||||||
int GetTypeId(const StringImpl& typeName);
|
int GetTypeId(const StringImpl& typeName);
|
||||||
|
|
|
@ -4171,3 +4171,13 @@ BF_EXPORT void BF_CALLTYPE BfParser_SetCompleteParse(BfParser* bfParser)
|
||||||
{
|
{
|
||||||
bfParser->mCompleteParse = true;
|
bfParser->mCompleteParse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BF_EXPORT void BF_CALLTYPE BfParser_GetLineCharAtIdx(BfParser* bfParser, int idx, int* line, int* lineChar)
|
||||||
|
{
|
||||||
|
int _line, _lineChar;
|
||||||
|
|
||||||
|
bfParser->GetLineCharAtIdx(idx, _line, _lineChar);
|
||||||
|
|
||||||
|
*line = _line;
|
||||||
|
*lineChar = _lineChar;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue